Add e2e case for missing worktree after crash
This commit is contained in:
parent
b69d0f3bac
commit
1a5daeaf43
3
main.go
3
main.go
|
|
@ -1681,6 +1681,9 @@ func (git *repoSync) SyncRepo(ctx context.Context, refreshCreds func(context.Con
|
|||
// Regular cleanup will happen in the outer loop, to catch stale
|
||||
// worktrees.
|
||||
|
||||
// We can end up here with no current hash but (the expectation of) a
|
||||
// current worktree (e.g. the hash was synced but the worktree does not
|
||||
// exist).
|
||||
if currentHash != "" && currentWorktree != git.worktreeFor(currentHash) {
|
||||
// The old worktree might have come from a prior version, and so
|
||||
// not get caught by the normal cleanup.
|
||||
|
|
|
|||
33
test_e2e.sh
33
test_e2e.sh
|
|
@ -1297,7 +1297,7 @@ function e2e::sync_sha_once_sync_different_sha_unknown() {
|
|||
##############################################
|
||||
# Test syncing after a crash
|
||||
##############################################
|
||||
function e2e::sync_crash_cleanup_retry() {
|
||||
function e2e::sync_crash_no_link_cleanup_retry() {
|
||||
# First sync
|
||||
echo "$FUNCNAME 1" > "$REPO/file"
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 1"
|
||||
|
|
@ -1325,6 +1325,37 @@ function e2e::sync_crash_cleanup_retry() {
|
|||
assert_file_eq "$ROOT/link/file" "$FUNCNAME 1"
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test syncing after a crash
|
||||
##############################################
|
||||
function e2e::sync_crash_no_worktree_cleanup_retry() {
|
||||
# First sync
|
||||
echo "$FUNCNAME 1" > "$REPO/file"
|
||||
git -C "$REPO" commit -qam "$FUNCNAME 1"
|
||||
|
||||
GIT_SYNC \
|
||||
--one-time \
|
||||
--repo="file://$REPO" \
|
||||
--root="$ROOT" \
|
||||
--link="link"
|
||||
assert_link_exists "$ROOT/link"
|
||||
assert_file_exists "$ROOT/link/file"
|
||||
assert_file_eq "$ROOT/link/file" "$FUNCNAME 1"
|
||||
|
||||
# Corrupt it
|
||||
rm -rf "$ROOT/.worktrees/"
|
||||
|
||||
# Try again
|
||||
GIT_SYNC \
|
||||
--one-time \
|
||||
--repo="file://$REPO" \
|
||||
--root="$ROOT" \
|
||||
--link="link"
|
||||
assert_link_exists "$ROOT/link"
|
||||
assert_file_exists "$ROOT/link/file"
|
||||
assert_file_eq "$ROOT/link/file" "$FUNCNAME 1"
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test changing repos with storage intact
|
||||
##############################################
|
||||
|
|
|
|||
Loading…
Reference in New Issue