Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Fix one-shot sync of a rev
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Sep 15, 2017
1 parent 79c9335 commit ac0817b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/git-sync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ func main() {
continue
}
if initialSync {
if *flOneTime {
os.Exit(0)
}
if isHash, err := revIsHash(*flRev, *flRoot); err != nil {
log.Errorf("can't tell if rev %s is a git hash, exiting", *flRev)
os.Exit(1)
} else if isHash {
log.V(0).Infof("rev %s appears to be a git hash, no further sync needed", *flRev)
sleepForever()
}
if *flOneTime {
os.Exit(0)
}
initialSync = false
}

Expand Down
22 changes: 22 additions & 0 deletions test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,27 @@ pkill git-sync
wait
pass

# Test rev-sync one-time
testcase "rev-once"
# First sync
echo "$TESTCASE" > "$REPO"/file
git -C "$REPO" commit -qam "$TESTCASE"
REV=$(git -C "$REPO" rev-list -n1 HEAD)
GIT_SYNC \
--logtostderr \
--v=5 \
--wait=0.1 \
--repo="$REPO" \
--rev="$REV" \
--root="$ROOT" \
--dest="link" \
--one-time > "$DIR"/log."$TESTCASE" 2>&1
sleep 2
assert_link_exists "$ROOT"/link
assert_file_exists "$ROOT"/link/file
assert_file_eq "$ROOT"/link/file "$TESTCASE"
# Wrap up
pass

echo "cleaning up $DIR"
rm -rf "$DIR"

0 comments on commit ac0817b

Please sign in to comment.