Merge pull request #350 from thockin/readlink-is-api-v3

Change the symlink targets to just the SHA
This commit is contained in:
Kubernetes Prow Robot 2021-03-12 03:04:17 -08:00 committed by GitHub
commit a34327d9a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -602,7 +602,7 @@ func addWorktreeAndSwap(ctx context.Context, gitRoot, dest, branch, rev string,
}
// Make a worktree for this exact git hash.
worktreePath := filepath.Join(gitRoot, "rev-"+hash)
worktreePath := filepath.Join(gitRoot, hash)
_, err := runCommand(ctx, gitRoot, *flGitCmd, "worktree", "add", worktreePath, "origin/"+branch)
log.V(0).Info("adding worktree", "path", worktreePath, "branch", fmt.Sprintf("origin/%s", branch))
if err != nil {

View File

@ -33,6 +33,13 @@ function assert_link_exists() {
fi
}
function assert_link_eq() {
if [[ $(readlink "$1") == "$2" ]]; then
return
fi
fail "link $1 does not point to '$2': $(readlink $1)"
}
function assert_file_exists() {
if ! [[ -f "$1" ]]; then
fail "$1 does not exist"
@ -255,6 +262,38 @@ assert_file_eq "$ROOT"/link/file "$TESTCASE 1"
# Wrap up
pass
##############################################
# Test readlink
##############################################
testcase "readlink"
# First sync
echo "$TESTCASE 1" > "$REPO"/file
git -C "$REPO" commit -qam "$TESTCASE 1"
GIT_SYNC \
--wait=0.1 \
--repo="file://$REPO" \
--branch=e2e-branch \
--rev=HEAD \
--root="$ROOT" \
--dest="link" \
> "$DIR"/log."$TESTCASE" 2>&1 &
sleep 3
assert_link_exists "$ROOT"/link
assert_link_eq "$ROOT"/link $(git -C "$REPO" rev-parse HEAD)
# Move HEAD forward
echo "$TESTCASE 2" > "$REPO"/file
git -C "$REPO" commit -qam "$TESTCASE 2"
sleep 3
assert_link_exists "$ROOT"/link
assert_link_eq "$ROOT"/link $(git -C "$REPO" rev-parse HEAD)
# Move HEAD backward
git -C "$REPO" reset -q --hard HEAD^
sleep 3
assert_link_exists "$ROOT"/link
assert_link_eq "$ROOT"/link $(git -C "$REPO" rev-parse HEAD)
# Wrap up
pass
##############################################
# Test branch syncing
##############################################