Skip to content

Commit 3d9752a

Browse files
authored
fix(script):cleanup per-repo .git after processing (#1884)
Signed-off-by: MYUU <1405758738@qq.com>
1 parent 32d4129 commit 3d9752a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

scripts/import-buck2-deps/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The Mega relative path is derived starting from the first `third-party/` path co
1111
- Automatically discovers import targets by scanning the directory tree and identifying version directories containing a `BUCK` file (by default, version directories must look like `x.y.z`)
1212
- Skips directories that already have a Git repository somewhere above them to avoid duplicate imports
1313
- For each import target, automatically runs: repo init, branch create/switch, initial commit, remote configuration, and push to Mega
14+
- Always removes the per-repo `.git` directory after processing so reruns rediscover candidates
1415
- Optionally rewrites `//third-party/...` dependency labels in `BUCK` to `//...` (for buckal generated artifacts)
1516
- Supports concurrent imports (`--jobs`)
1617
- Supports an interactive UI (`--ui`): rich (if available) or plain; in rich mode, logs keep only the most recent 12 lines and show a Results summary at the end
@@ -79,6 +80,7 @@ python3 scripts/import-buck2-deps/import-buck2-deps.py --dry-run
7980
- (Optional) Rewrite `BUCK` dependency labels (`--buckal-generated`)
8081
- If the repo has no commits yet, create an initial commit (by default includes `-s -S`)
8182
- Configure/update the remote and push to `<git-base-url>/<rel-path>`
83+
- Remove the local `.git` directory under the version directory
8284
4. If `--retry` is set, retry only the failed repos for up to N additional attempts
8385
5. Under the rich UI, show a Results summary at the end: Succeeded/Failed/Total, and list failed repos with reasons
8486

@@ -94,6 +96,7 @@ python3 scripts/import-buck2-deps/import-buck2-deps.py --dry-run
9496
- If the scan root does not exist, is not a directory, or is not readable: print an Error and exit with code 2
9597
- If a child directory cannot be accessed during scanning: print a Warning and continue scanning other directories
9698
- If a single repo import fails: list the failed repo and reason in the rich UI Results
99+
- After each repo attempt (success or failure), the script removes the local `.git` directory under that repo directory so retries/reruns start cleanly
97100
- With `--fail-fast`: stop after the first failure; skipped tasks are not counted as Failed
98101
- With `--retry N`: retry failed repos up to N times; exit non-zero if still failing after retries
99102

scripts/import-buck2-deps/import-buck2-deps.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,16 +814,13 @@ def process_one(s: RepoSpec) -> None:
814814
except Exception as e:
815815
err_text = str(e)
816816
emit({"type": "log", "level": "error", "msg": f"{s.rel_path}: {_one_line(err_text, 10000)}"})
817-
818-
# Cleanup .git on failure so we can retry cleanly
819-
cleanup_git(s.repo_dir)
820-
821817
with failures_lock:
822818
failures.append((s, str(e)))
823819
if args.fail_fast:
824820
stop_event.set()
825821
emit({"type": "done", "rel": s.rel_path})
826822
finally:
823+
cleanup_git(s.repo_dir)
827824
emit({"type": "clear", "slot": slot})
828825
slot_pool.put(slot)
829826

0 commit comments

Comments
 (0)