3 . "$(dirname "$0")/testlib.sh"
5 begin_test "verify with retries"
9 reponame="verify-fail-2-times"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
14 git add .gitattributes
15 git commit -m "initial commit"
17 contents="send-verify-action"
18 contents_oid="$(calc_oid "$contents")"
19 contents_short_oid="$(echo "$contents_oid" | head -c 7)"
20 printf "$contents" > a.dat
23 git commit -m "add a.dat"
25 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
27 grep "Authorization: Basic * * * * *" push.log
29 [ "0" -eq "${PIPESTATUS[0]}" ]
30 [ "2" -eq "$(grep -c "verify $contents_short_oid attempt" push.log)" ]
34 begin_test "verify with retries (success without retry)"
38 reponame="verify-fail-0-times"
39 setup_remote_repo "$reponame"
40 clone_repo "$reponame" "$reponame"
43 git add .gitattributes
44 git commit -m "initial commit"
46 contents="send-verify-action"
47 contents_oid="$(calc_oid "$contents")"
48 contents_short_oid="$(echo "$contents_oid" | head -c 7)"
49 printf "$contents" > a.dat
52 git commit -m "add a.dat"
54 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
56 grep "Authorization: Basic * * * * *" push.log
58 [ "0" -eq "${PIPESTATUS[0]}" ]
59 [ "1" -eq "$(grep -c "verify $contents_short_oid attempt" push.log)" ]
63 begin_test "verify with retries (insufficient retries)"
67 reponame="verify-fail-10-times"
68 setup_remote_repo "$reponame"
69 clone_repo "$reponame" "$reponame"
72 git add .gitattributes
73 git commit -m "initial commit"
75 contents="send-verify-action"
76 contents_oid="$(calc_oid "$contents")"
77 contents_short_oid="$(echo "$contents_oid" | head -c 7)"
78 printf "$contents" > a.dat
81 git commit -m "add a.dat"
84 GIT_TRACE=1 git push origin master 2>&1 | tee push.log
85 if [ "0" -eq "${PIPESTATUS[0]}" ]; then
86 echo >&2 "verify: expected \"git push\" to fail, didn't ..."
91 [ "3" -eq "$(grep -c "verify $contents_short_oid attempt" push.log)" ]
95 begin_test "verify with retries (bad .gitconfig)"
99 reponame="bad-config-verify-fail-2-times"
100 setup_remote_repo "$reponame"
101 clone_repo "$reponame" "$reponame"
103 # Invalid `lfs.transfer.maxverifies` will default to 3.
104 git config "lfs.transfer.maxverifies" "-1"
106 git lfs track "*.dat"
107 git add .gitattributes
108 git commit -m "initial commit"
110 contents="send-verify-action"
111 contents_oid="$(calc_oid "$contents")"
112 contents_short_oid="$(echo "$contents_oid" | head -c 7)"
113 printf "$contents" > a.dat
116 git commit -m "add a.dat"
118 GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
120 grep "Authorization: Basic * * * * *" push.log
122 [ "0" -eq "${PIPESTATUS[0]}" ]
123 [ "2" -eq "$(grep -c "verify $contents_short_oid attempt" push.log)" ]