Removing an item from source control deletes every empty folder in the repository
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- devtools
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- ObjectScript
- Star
- 22
- Fork
- 15
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của intersystems/git-source-control
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
intersystems/git-source-control#1014 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
intersystems/git-source-control#1013 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
intersystems/git-source-control#1012 ·
Tất cả issue của intersystems/git-source-control
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ui-kit type: chore
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
schlessera/brain-kit#4598 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mloda-ai/mloda-plugin-template#206 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Beginner Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
JSPrismarine/JSPrismarine#3740 ·
Maintainer thường phản hồi trong vòng 1 ngày