3 5565365c 2024-03-27 op # Copyright (c) 2024 Omar Polo <op@openbsd.org>
5 5565365c 2024-03-27 op # Permission to use, copy, modify, and distribute this software for any
6 5565365c 2024-03-27 op # purpose with or without fee is hereby granted, provided that the above
7 5565365c 2024-03-27 op # copyright notice and this permission notice appear in all copies.
9 5565365c 2024-03-27 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 5565365c 2024-03-27 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 5565365c 2024-03-27 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 5565365c 2024-03-27 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 5565365c 2024-03-27 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 5565365c 2024-03-27 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 5565365c 2024-03-27 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 5565365c 2024-03-27 op . ../cmdline/common.sh
20 050c0b8c 2024-04-16 op # flan:password encoded in base64
21 050c0b8c 2024-04-16 op AUTH="ZmxhbjpwYXNzd29yZA=="
23 5565365c 2024-03-27 op test_file_changed() {
24 5565365c 2024-03-27 op local testroot=`test_init file_changed 1`
26 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
28 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
29 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
30 5565365c 2024-03-27 op test_done "$testroot" 1
34 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
36 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
37 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
38 5565365c 2024-03-27 op test_done "$testroot" 1
42 5565365c 2024-03-27 op echo "change alpha" > $testroot/wt/alpha
43 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
44 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
45 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
47 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
48 5565365c 2024-03-27 op > $testroot/stdout &
50 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
52 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
53 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
54 5565365c 2024-03-27 op test_done "$testroot" "1"
58 5565365c 2024-03-27 op wait %1 # wait for the http "server"
60 87890bc2 2024-03-28 op touch "$testroot/stdout.expected"
61 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
63 87890bc2 2024-03-28 op {"notifications":[{
64 93623901 2024-03-28 op "type":"commit",
65 87890bc2 2024-03-28 op "short":false,
66 c1003102 2024-04-15 op "repo":"test-repo",
67 87890bc2 2024-03-28 op "id":"$commit_id",
69 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
70 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
71 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
72 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
75 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
76 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
77 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
78 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
80 939d3016 2024-04-23 op "date":$author_time,
81 ac0a4dfc 2024-03-28 op "short_message":"make changes",
82 87890bc2 2024-03-28 op "message":"make changes\n",
85 763b7f49 2024-03-28 op "action":"modified",
86 763b7f49 2024-03-28 op "file":"alpha",
101 ea5e974d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
103 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
104 ea5e974d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
105 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
109 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
112 ea5e974d 2024-03-28 op test_bad_utf8() {
113 ea5e974d 2024-03-28 op local testroot=`test_init bad_utf8 1`
115 ea5e974d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
117 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
118 ea5e974d 2024-03-28 op echo "got clone failed unexpectedly" >&2
119 ea5e974d 2024-03-28 op test_done "$testroot" 1
123 ea5e974d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
125 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
126 ea5e974d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
127 ea5e974d 2024-03-28 op test_done "$testroot" 1
130 cdaefb15 2024-03-28 stsp # invalid utf8 sequence
131 ea5e974d 2024-03-28 op commit_msg="make$(printf '\xED\xA0\x80')changes"
133 ea5e974d 2024-03-28 op echo "changed" > $testroot/wt/alpha
134 ea5e974d 2024-03-28 op (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
135 ea5e974d 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
136 ea5e974d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone`
138 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
139 ea5e974d 2024-03-28 op > $testroot/stdout &
141 ea5e974d 2024-03-28 op got send -b main -q -r $testroot/repo-clone
143 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
144 ea5e974d 2024-03-28 op echo "got send failed unexpectedly" >&2
145 ea5e974d 2024-03-28 op test_done "$testroot" "1"
149 ea5e974d 2024-03-28 op wait %1 # wait for the http "server"
151 ea5e974d 2024-03-28 op touch "$testroot/stdout.expected"
152 ea5e974d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
154 ea5e974d 2024-03-28 op {"notifications":[{
155 93623901 2024-03-28 op "type":"commit",
156 ea5e974d 2024-03-28 op "short":false,
157 c1003102 2024-04-15 op "repo":"test-repo",
158 ea5e974d 2024-03-28 op "id":"$commit_id",
160 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
161 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
162 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
163 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
165 ac0a4dfc 2024-03-28 op "committer":{
166 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
167 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
168 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
169 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
171 939d3016 2024-04-23 op "date":$author_time,
172 ac0a4dfc 2024-03-28 op "short_message":"make\uFFFD\uFFFDchanges",
173 ea5e974d 2024-03-28 op "message":"make\uFFFD\uFFFDchanges\n",
176 763b7f49 2024-03-28 op "action":"modified",
177 763b7f49 2024-03-28 op "file":"alpha",
192 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
194 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
195 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
196 5565365c 2024-03-27 op test_done "$testroot" "$ret"
200 5565365c 2024-03-27 op test_done "$testroot" "$ret"
203 5565365c 2024-03-27 op test_many_commits_not_summarized() {
204 5565365c 2024-03-27 op local testroot=`test_init many_commits_not_summarized 1`
206 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
208 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
209 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
210 5565365c 2024-03-27 op test_done "$testroot" 1
214 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
216 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
217 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
218 5565365c 2024-03-27 op test_done "$testroot" 1
222 5565365c 2024-03-27 op for i in `seq 1 24`; do
223 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
224 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
225 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
226 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
227 939d3016 2024-04-23 op set -- "$@" "$commit_id $author_time"
230 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
231 5565365c 2024-03-27 op > $testroot/stdout &
233 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
235 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
236 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
237 5565365c 2024-03-27 op test_done "$testroot" "1"
241 5565365c 2024-03-27 op wait %1 # wait for the http "server"
243 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
245 5565365c 2024-03-27 op for i in `seq 1 24`; do
246 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
247 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
248 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
250 87890bc2 2024-03-28 op echo "$comma"
255 93623901 2024-03-28 op "type":"commit",
256 87890bc2 2024-03-28 op "short":false,
257 c1003102 2024-04-15 op "repo":"test-repo",
258 87890bc2 2024-03-28 op "id":"$commit_id",
260 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
261 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
262 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
263 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
265 ac0a4dfc 2024-03-28 op "committer":{
266 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
267 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
268 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
269 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
271 939d3016 2024-04-23 op "date":$commit_time,
272 ac0a4dfc 2024-03-28 op "short_message":"make changes",
273 87890bc2 2024-03-28 op "message":"make changes\n",
276 763b7f49 2024-03-28 op "action":"modified",
277 763b7f49 2024-03-28 op "file":"alpha",
288 5565365c 2024-03-27 op done >> $testroot/stdout.expected
289 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
290 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
295 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
297 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
298 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
299 5565365c 2024-03-27 op test_done "$testroot" "$ret"
303 5565365c 2024-03-27 op test_done "$testroot" "$ret"
306 5565365c 2024-03-27 op test_many_commits_summarized() {
307 5565365c 2024-03-27 op local testroot=`test_init many_commits_summarized 1`
309 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
311 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
312 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
313 5565365c 2024-03-27 op test_done "$testroot" 1
317 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
319 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
320 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
321 5565365c 2024-03-27 op test_done "$testroot" 1
325 5565365c 2024-03-27 op for i in `seq 1 51`; do
326 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
327 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
328 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
329 5565365c 2024-03-27 op local short_commit_id=`trim_obj_id 33 $commit_id`
330 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
331 939d3016 2024-04-23 op set -- "$@" "$short_commit_id $author_time"
334 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
335 5565365c 2024-03-27 op > $testroot/stdout &
337 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
339 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
340 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
341 5565365c 2024-03-27 op test_done "$testroot" "1"
345 5565365c 2024-03-27 op wait %1 # wait for the http "server"
347 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
349 5565365c 2024-03-27 op for i in `seq 1 51`; do
350 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
351 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
352 939d3016 2024-04-23 op commit_time=$(echo "$s" | cut -d' ' -f2)
354 87890bc2 2024-03-28 op echo "$comma"
359 93623901 2024-03-28 op "type":"commit",
360 87890bc2 2024-03-28 op "short":true,
361 c1003102 2024-04-15 op "repo":"test-repo",
362 87890bc2 2024-03-28 op "id":"$commit_id",
363 ac0a4dfc 2024-03-28 op "committer":{
364 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_8"
366 939d3016 2024-04-23 op "date":$commit_time,
367 ac0a4dfc 2024-03-28 op "short_message":"make changes"
370 5565365c 2024-03-27 op done >> $testroot/stdout.expected
371 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
372 914bfd3d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
377 914bfd3d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
379 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
380 914bfd3d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
381 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
385 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
388 914bfd3d 2024-03-28 op test_branch_created() {
389 914bfd3d 2024-03-28 op local testroot=`test_init branch_created 1`
391 914bfd3d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
393 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
394 914bfd3d 2024-03-28 op echo "got clone failed unexpectedly" >&2
395 914bfd3d 2024-03-28 op test_done "$testroot" 1
399 914bfd3d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
401 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
402 914bfd3d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
403 914bfd3d 2024-03-28 op test_done "$testroot" 1
407 914bfd3d 2024-03-28 op (cd $testroot/wt && got branch newbranch > /dev/null)
409 914bfd3d 2024-03-28 op echo "change alpha on branch" > $testroot/wt/alpha
410 914bfd3d 2024-03-28 op (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
411 914bfd3d 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
412 914bfd3d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
414 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
415 914bfd3d 2024-03-28 op > $testroot/stdout &
417 914bfd3d 2024-03-28 op got send -b newbranch -q -r $testroot/repo-clone
419 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
420 914bfd3d 2024-03-28 op echo "got send failed unexpectedly" >&2
421 914bfd3d 2024-03-28 op test_done "$testroot" "1"
425 914bfd3d 2024-03-28 op wait %1 # wait for the http "server"
427 914bfd3d 2024-03-28 op # in the future it should contain something like this too
429 914bfd3d 2024-03-28 op # "type":"new-branch",
430 914bfd3d 2024-03-28 op # "user":"${GOTD_DEVUSER}",
431 914bfd3d 2024-03-28 op # "ref":"refs/heads/newbranch"
434 914bfd3d 2024-03-28 op touch "$testroot/stdout.expected"
435 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
437 914bfd3d 2024-03-28 op {"notifications":[
439 914bfd3d 2024-03-28 op "type":"commit",
440 914bfd3d 2024-03-28 op "short":false,
441 c1003102 2024-04-15 op "repo":"test-repo",
442 914bfd3d 2024-03-28 op "id":"$commit_id",
444 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
445 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
446 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
447 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
449 914bfd3d 2024-03-28 op "committer":{
450 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
451 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
452 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
453 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
455 939d3016 2024-04-23 op "date":$author_time,
456 914bfd3d 2024-03-28 op "short_message":"newbranch",
457 914bfd3d 2024-03-28 op "message":"newbranch\n",
460 763b7f49 2024-03-28 op "action":"modified",
461 763b7f49 2024-03-28 op "file":"alpha",
477 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
479 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
480 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
481 5565365c 2024-03-27 op test_done "$testroot" "$ret"
485 5565365c 2024-03-27 op test_done "$testroot" "$ret"
488 d6057084 2024-03-28 op test_branch_removed() {
489 d6057084 2024-03-28 op local testroot=`test_init branch_removed 1`
491 d6057084 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
493 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
494 d6057084 2024-03-28 op echo "got clone failed unexpectedly" >&2
495 d6057084 2024-03-28 op test_done "$testroot" 1
499 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
500 d6057084 2024-03-28 op > $testroot/stdout &
502 d6057084 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
504 d6057084 2024-03-28 op got send -d newbranch -q -r $testroot/repo-clone
506 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
507 d6057084 2024-03-28 op echo "got send failed unexpectedly" >&2
508 d6057084 2024-03-28 op test_done "$testroot" "1"
512 d6057084 2024-03-28 op wait %1 # wait for the http "server"
514 d6057084 2024-03-28 op touch "$testroot/stdout.expected"
515 d6057084 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
517 d6057084 2024-03-28 op {"notifications":[{
518 d6057084 2024-03-28 op "type":"branch-deleted",
519 c1003102 2024-04-15 op "repo":"test-repo",
520 d6057084 2024-03-28 op "ref":"refs/heads/newbranch",
521 d6057084 2024-03-28 op "id":"$commit_id"
528 553d8347 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
530 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
531 553d8347 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
532 553d8347 2024-03-28 op test_done "$testroot" "$ret"
536 553d8347 2024-03-28 op test_done "$testroot" "$ret"
539 553d8347 2024-03-28 op test_tag_created() {
540 553d8347 2024-03-28 op local testroot=`test_init tag_created 1`
542 553d8347 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
544 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
545 553d8347 2024-03-28 op echo "got clone failed unexpectedly" >&2
546 553d8347 2024-03-28 op test_done "$testroot" 1
550 553d8347 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
551 553d8347 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
552 553d8347 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
554 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
555 553d8347 2024-03-28 op >$testroot/stdout &
557 553d8347 2024-03-28 op got send -t 1.0 -q -r $testroot/repo-clone
559 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
560 553d8347 2024-03-28 op echo "got send failed unexpectedly" >&2
561 553d8347 2024-03-28 op test_done "$testroot" "1"
565 553d8347 2024-03-28 op wait %1 # wait for the http "server"
567 553d8347 2024-03-28 op touch "$testroot/stdout.expected"
568 553d8347 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
570 553d8347 2024-03-28 op {"notifications":[{
571 553d8347 2024-03-28 op "type":"tag",
572 c1003102 2024-04-15 op "repo":"test-repo",
573 553d8347 2024-03-28 op "tag":"refs/tags/1.0",
575 553d8347 2024-03-28 op "full":"$GOT_AUTHOR",
576 553d8347 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
577 553d8347 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
578 553d8347 2024-03-28 op "user":"$GOT_AUTHOR_11"
580 939d3016 2024-04-23 op "date":$tagger_time,
582 553d8347 2024-03-28 op "type":"commit",
583 553d8347 2024-03-28 op "id":"$commit_id"
585 553d8347 2024-03-28 op "message":"new tag\n\n"
592 d6057084 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
594 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
595 d6057084 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
596 d6057084 2024-03-28 op test_done "$testroot" "$ret"
600 d6057084 2024-03-28 op test_done "$testroot" "$ret"
603 cd182532 2024-03-28 op test_tag_changed() {
604 cd182532 2024-03-28 op local testroot=`test_init tag_changed 1`
606 cd182532 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
608 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
609 cd182532 2024-03-28 op echo "got clone failed unexpectedly" >&2
610 cd182532 2024-03-28 op test_done "$testroot" 1
614 cd182532 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
616 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
617 cd182532 2024-03-28 op echo "got checkout failed unexpectedly" >&2
618 cd182532 2024-03-28 op test_done "$testroot" 1
622 cd182532 2024-03-28 op echo "change alpha" > $testroot/wt/alpha
623 cd182532 2024-03-28 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
624 cd182532 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
626 cd182532 2024-03-28 op got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
627 cd182532 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
628 cd182532 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
630 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
631 cd182532 2024-03-28 op > $testroot/stdout &
633 cd182532 2024-03-28 op got send -f -t 1.0 -q -r $testroot/repo-clone
635 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
636 cd182532 2024-03-28 op echo "got send failed unexpectedly" >&2
637 cd182532 2024-03-28 op test_done "$testroot" "1"
641 cd182532 2024-03-28 op wait %1 # wait for the http "server"
643 cd182532 2024-03-28 op # XXX: at the moment this is exactly the same as the "new tag"
644 cd182532 2024-03-28 op # notification
646 cd182532 2024-03-28 op touch "$testroot/stdout.expected"
647 cd182532 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
649 cd182532 2024-03-28 op {"notifications":[{
650 cd182532 2024-03-28 op "type":"tag",
651 c1003102 2024-04-15 op "repo":"test-repo",
652 cd182532 2024-03-28 op "tag":"refs/tags/1.0",
654 cd182532 2024-03-28 op "full":"$GOT_AUTHOR",
655 cd182532 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
656 cd182532 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
657 cd182532 2024-03-28 op "user":"$GOT_AUTHOR_11"
659 939d3016 2024-04-23 op "date":$tagger_time,
661 cd182532 2024-03-28 op "type":"commit",
662 cd182532 2024-03-28 op "id":"$commit_id"
664 cd182532 2024-03-28 op "message":"new tag\n\n"
671 cd182532 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
673 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
674 cd182532 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
675 cd182532 2024-03-28 op test_done "$testroot" "$ret"
679 cd182532 2024-03-28 op test_done "$testroot" "$ret"
682 5565365c 2024-03-27 op test_parseargs "$@"
683 5565365c 2024-03-27 op run_test test_file_changed
684 ea5e974d 2024-03-28 op run_test test_bad_utf8
685 5565365c 2024-03-27 op run_test test_many_commits_not_summarized
686 5565365c 2024-03-27 op run_test test_many_commits_summarized
687 914bfd3d 2024-03-28 op run_test test_branch_created
688 d6057084 2024-03-28 op run_test test_branch_removed
689 553d8347 2024-03-28 op run_test test_tag_created
690 cd182532 2024-03-28 op run_test test_tag_changed