Merge pull request #67 from thockin/master

Fix one-shot sync of a rev
This commit is contained in:
Tim Hockin 2017-09-15 10:31:22 -07:00 committed by GitHub
commit 28254d864a
2 changed files with 25 additions and 3 deletions

View File

@ -179,6 +179,9 @@ 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)
@ -186,9 +189,6 @@ func main() {
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
}

View File

@ -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"