Removing an item from source control deletes every empty folder in the repository
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- devtools
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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).
- Vorherrschende Sprache
- ObjectScript
- Sterne
- 22
- Forks
- 15
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus intersystems/git-source-control
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 55/100
intersystems/git-source-control#1014 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 18/100
intersystems/git-source-control#1013 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
intersystems/git-source-control#1012 ·
Alle Issues in intersystems/git-source-control
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
area: ui-kit type: chore
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
schlessera/brain-kit#4598 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
mloda-ai/mloda-plugin-template#206 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
Beginner Enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
JSPrismarine/JSPrismarine#3740 ·
Maintainer antworten meist innerhalb von 1 Tag