Removing an item from source control deletes every empty folder in the repository
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- devtools
Direzione di ricerca
Start in cls/SourceControl/Git/Utils.cls, especially RemoveFromSourceControl, RemoveFromServerSideSourceControl, and RemoveFolderIfEmpty at the locations cited in the issue. Trace how removal identifies the deleted item's directory, then check the pull/merge deletion path through ExportItem. Done means cleanup removes only empty parent directories made empty by the removal and preserves unrelated empty directories; the payload names no test file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: 2.18.0 (the same code is on main)
Background
After an item is removed from source control, git-source-control deletes every empty directory anywhere under the repository root, not just the ones left empty by the removal.
RemoveFromSourceControl (Utils.cls#L1097) and RemoveFromServerSideSourceControl (#L1056) both call RemoveFolderIfEmpty(..TempFolder()), which is the repository root. RemoveFolderIfEmpty (#L1936) recurses through the whole tree, skipping only .git, and removes every directory it finds empty.
RemoveFromServerSideSourceControl is also called from ExportItem when the item no longer exists, and from the pull/merge sync for deleted files. So a pull that deletes one file does the same sweep.
Steps to reproduce
- Use a namespace configured for git-source-control, with repository root
<root>. - Create an empty directory unrelated to any item:
mkdir <root>/unrelated(tracked or git-ignored, it makes no difference). - Add any item to source control, then remove it, either from the Source Control menu (Remove from Source Control) or with
do ##class(SourceControl.Git.Utils).RemoveFromSourceControl("Some.Class.cls"). <root>/unrelatedhas been deleted.
Why it matters
Empty directories in a working tree are often deliberate, and git-source-control can't know they're unused. Examples: mount points, output folders a build or test expects, or placeholders for other tools.
In our case, the repository is bind-mounted into an IRIS container and also into a separate development container. In the development container, another directory is bind-mounted on an empty folder inside the repository. From IRIS that folder is empty, so the sweep deleted it on the host. On Linux, deleting a directory that is a mount point in another mount namespace succeeds and silently detaches that mount, so the other container lost the mounted content until it was restarted, with no error anywhere.
Expected behavior
Clean up only the directories the removal itself emptied: starting from the removed file's directory, walk up towards the repository root and remove each directory only while it is empty. Leave alone any directory the operation didn't touch.
Workaround
Keep a file in any empty directory that must survive (we use a root-owned, read-only marker file).
- Lingua principale
- ObjectScript
- Stelle
- 22
- Fork
- 15
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di intersystems/git-source-control
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 55/100
intersystems/git-source-control#1014 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
intersystems/git-source-control#1013 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
intersystems/git-source-control#1012 ·
Tutte le issue di intersystems/git-source-control
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
mloda-ai/mloda-plugin-template#206 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
5hyuns/maya-workflow-kit-for-blender#568 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Yeachan-Heo/gajae-code#8058 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
qualcomm-linux/qcom-deb-images#868 ·
I maintainer di solito rispondono entro 1 giorno