Skip to content

Commit

Permalink
filter-repo: notice and signal when cleanup commands fail
Browse files Browse the repository at this point in the history
Signed-off-by: Elijah Newren <[email protected]>
  • Loading branch information
newren committed Aug 1, 2024
1 parent edadb02 commit 1fea5ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,9 @@ class RepoFilter(object):
for cmd in cleanup_cmds:
if show_debuginfo:
print("[DEBUG] Running{}: {}".format(location_info, ' '.join(cmd)))
subproc.call(cmd, cwd=repo)
ret = subproc.call(cmd, cwd=repo)
if ret != 0:
raise SystemExit("fatal: running '%s' failed!" % ' '.join(cmd))
if cmd[0:3] == 'git reflog expire'.split():
self._write_stash()

Expand Down
18 changes: 18 additions & 0 deletions t/t9390-filter-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1959,4 +1959,22 @@ test_expect_success 'rewrite stash' '
)
'

test_expect_success 'failure to run cleanup' '
test_create_repo fail_to_cleanup &&
(
cd fail_to_cleanup &&
git init &&
test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers &&
git add numbers &&
git commit -qm initial &&
chmod u-w .git/logs &&
test_must_fail git filter-repo --force \
--path-rename numbers:values 2> ../err &&
chmod u+w .git/logs &&
grep fatal.*git.reflog.expire.*failed ../err
)
'

test_done

0 comments on commit 1fea5ec

Please sign in to comment.