Removing an item from source control deletes every empty folder in the repository

Ouverte
#1,015 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Domaine
devtools

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

  1. Use a namespace configured for git-source-control, with repository root <root>.
  2. Create an empty directory unrelated to any item: mkdir <root>/unrelated (tracked or git-ignored, it makes no difference).
  3. 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").
  4. <root>/unrelated has 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).

Langage dominant
ObjectScript
Étoiles
22
Forks
15
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de intersystems/git-source-control

Toutes les issues de intersystems/git-source-control

Issues similaires

Plus d'issues DevTools

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.