Skip to content

Commit 28254d8

Browse files
authored
Merge pull request #67 from thockin/master
Fix one-shot sync of a rev
2 parents 7725869 + ac0817b commit 28254d8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

Diff for: cmd/git-sync/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,16 @@ func main() {
179179
continue
180180
}
181181
if initialSync {
182+
if *flOneTime {
183+
os.Exit(0)
184+
}
182185
if isHash, err := revIsHash(*flRev, *flRoot); err != nil {
183186
log.Errorf("can't tell if rev %s is a git hash, exiting", *flRev)
184187
os.Exit(1)
185188
} else if isHash {
186189
log.V(0).Infof("rev %s appears to be a git hash, no further sync needed", *flRev)
187190
sleepForever()
188191
}
189-
if *flOneTime {
190-
os.Exit(0)
191-
}
192192
initialSync = false
193193
}
194194

Diff for: test_e2e.sh

+22
Original file line numberDiff line numberDiff line change
@@ -369,5 +369,27 @@ pkill git-sync
369369
wait
370370
pass
371371

372+
# Test rev-sync one-time
373+
testcase "rev-once"
374+
# First sync
375+
echo "$TESTCASE" > "$REPO"/file
376+
git -C "$REPO" commit -qam "$TESTCASE"
377+
REV=$(git -C "$REPO" rev-list -n1 HEAD)
378+
GIT_SYNC \
379+
--logtostderr \
380+
--v=5 \
381+
--wait=0.1 \
382+
--repo="$REPO" \
383+
--rev="$REV" \
384+
--root="$ROOT" \
385+
--dest="link" \
386+
--one-time > "$DIR"/log."$TESTCASE" 2>&1
387+
sleep 2
388+
assert_link_exists "$ROOT"/link
389+
assert_file_exists "$ROOT"/link/file
390+
assert_file_eq "$ROOT"/link/file "$TESTCASE"
391+
# Wrap up
392+
pass
393+
372394
echo "cleaning up $DIR"
373395
rm -rf "$DIR"

0 commit comments

Comments
 (0)