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 5a430400 2024-05-12 naddy sleep 1 # server starts up
52 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
54 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
55 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
56 5565365c 2024-03-27 op test_done "$testroot" "1"
60 5565365c 2024-03-27 op wait %1 # wait for the http "server"
62 87890bc2 2024-03-28 op touch "$testroot/stdout.expected"
63 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
65 87890bc2 2024-03-28 op {"notifications":[{
66 93623901 2024-03-28 op "type":"commit",
67 87890bc2 2024-03-28 op "short":false,
68 c1003102 2024-04-15 op "repo":"test-repo",
69 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
70 87890bc2 2024-03-28 op "id":"$commit_id",
72 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
73 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
74 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
75 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
78 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
79 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
80 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
81 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
83 939d3016 2024-04-23 op "date":$author_time,
84 ac0a4dfc 2024-03-28 op "short_message":"make changes",
85 87890bc2 2024-03-28 op "message":"make changes\n",
88 763b7f49 2024-03-28 op "action":"modified",
89 763b7f49 2024-03-28 op "file":"alpha",
104 ea5e974d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
106 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
107 ea5e974d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
108 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
112 c3cc85a3 2024-04-30 stsp # Try the same thing again with 'git push' instead of 'got send'
113 c3cc85a3 2024-04-30 stsp echo "change alpha once more" > $testroot/wt/alpha
114 c3cc85a3 2024-04-30 stsp (cd $testroot/wt && got commit -m 'make more changes' > /dev/null)
115 c3cc85a3 2024-04-30 stsp local commit_id=`git_show_head $testroot/repo-clone`
116 c3cc85a3 2024-04-30 stsp local author_time=`git_show_author_time $testroot/repo-clone`
118 c3cc85a3 2024-04-30 stsp timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
119 c3cc85a3 2024-04-30 stsp > $testroot/stdout &
121 5a430400 2024-05-12 naddy sleep 1 # server starts up
123 c3cc85a3 2024-04-30 stsp git -C $testroot/repo-clone push -q origin main
125 c3cc85a3 2024-04-30 stsp if [ $ret -ne 0 ]; then
126 c3cc85a3 2024-04-30 stsp echo "git push failed unexpectedly" >&2
127 c3cc85a3 2024-04-30 stsp test_done "$testroot" "1"
131 c3cc85a3 2024-04-30 stsp wait %1 # wait for the http "server"
133 c3cc85a3 2024-04-30 stsp echo -n > "$testroot/stdout.expected"
134 c3cc85a3 2024-04-30 stsp ed -s "$testroot/stdout.expected" <<-EOF
136 c3cc85a3 2024-04-30 stsp {"notifications":[{
137 c3cc85a3 2024-04-30 stsp "type":"commit",
138 c3cc85a3 2024-04-30 stsp "short":false,
139 c3cc85a3 2024-04-30 stsp "repo":"test-repo",
140 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
141 c3cc85a3 2024-04-30 stsp "id":"$commit_id",
143 c3cc85a3 2024-04-30 stsp "full":"$GOT_AUTHOR",
144 c3cc85a3 2024-04-30 stsp "name":"$GIT_AUTHOR_NAME",
145 c3cc85a3 2024-04-30 stsp "mail":"$GIT_AUTHOR_EMAIL",
146 c3cc85a3 2024-04-30 stsp "user":"$GOT_AUTHOR_11"
148 c3cc85a3 2024-04-30 stsp "committer":{
149 c3cc85a3 2024-04-30 stsp "full":"$GOT_AUTHOR",
150 c3cc85a3 2024-04-30 stsp "name":"$GIT_AUTHOR_NAME",
151 c3cc85a3 2024-04-30 stsp "mail":"$GIT_AUTHOR_EMAIL",
152 c3cc85a3 2024-04-30 stsp "user":"$GOT_AUTHOR_11"
154 c3cc85a3 2024-04-30 stsp "date":$author_time,
155 c3cc85a3 2024-04-30 stsp "short_message":"make more changes",
156 c3cc85a3 2024-04-30 stsp "message":"make more changes\n",
157 c3cc85a3 2024-04-30 stsp "diffstat":{
159 c3cc85a3 2024-04-30 stsp "action":"modified",
160 c3cc85a3 2024-04-30 stsp "file":"alpha",
162 c3cc85a3 2024-04-30 stsp "removed":1
166 c3cc85a3 2024-04-30 stsp "removed":1
175 c3cc85a3 2024-04-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
177 c3cc85a3 2024-04-30 stsp if [ $ret -ne 0 ]; then
178 c3cc85a3 2024-04-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
180 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
183 ea5e974d 2024-03-28 op test_bad_utf8() {
184 ea5e974d 2024-03-28 op local testroot=`test_init bad_utf8 1`
186 ea5e974d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
188 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
189 ea5e974d 2024-03-28 op echo "got clone failed unexpectedly" >&2
190 ea5e974d 2024-03-28 op test_done "$testroot" 1
194 ea5e974d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
196 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
197 ea5e974d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
198 ea5e974d 2024-03-28 op test_done "$testroot" 1
201 cdaefb15 2024-03-28 stsp # invalid utf8 sequence
202 ea5e974d 2024-03-28 op commit_msg="make$(printf '\xED\xA0\x80')changes"
204 ea5e974d 2024-03-28 op echo "changed" > $testroot/wt/alpha
205 ea5e974d 2024-03-28 op (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
206 ea5e974d 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
207 ea5e974d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone`
209 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
210 ea5e974d 2024-03-28 op > $testroot/stdout &
212 5a430400 2024-05-12 naddy sleep 1 # server starts up
214 ea5e974d 2024-03-28 op got send -b main -q -r $testroot/repo-clone
216 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
217 ea5e974d 2024-03-28 op echo "got send failed unexpectedly" >&2
218 ea5e974d 2024-03-28 op test_done "$testroot" "1"
222 ea5e974d 2024-03-28 op wait %1 # wait for the http "server"
224 ea5e974d 2024-03-28 op touch "$testroot/stdout.expected"
225 ea5e974d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
227 ea5e974d 2024-03-28 op {"notifications":[{
228 93623901 2024-03-28 op "type":"commit",
229 ea5e974d 2024-03-28 op "short":false,
230 c1003102 2024-04-15 op "repo":"test-repo",
231 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
232 ea5e974d 2024-03-28 op "id":"$commit_id",
234 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
235 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
236 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
237 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
239 ac0a4dfc 2024-03-28 op "committer":{
240 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
241 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
242 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
243 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
245 939d3016 2024-04-23 op "date":$author_time,
246 ac0a4dfc 2024-03-28 op "short_message":"make\uFFFD\uFFFDchanges",
247 ea5e974d 2024-03-28 op "message":"make\uFFFD\uFFFDchanges\n",
250 763b7f49 2024-03-28 op "action":"modified",
251 763b7f49 2024-03-28 op "file":"alpha",
266 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
268 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
269 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
270 5565365c 2024-03-27 op test_done "$testroot" "$ret"
274 5565365c 2024-03-27 op test_done "$testroot" "$ret"
277 5565365c 2024-03-27 op test_many_commits_not_summarized() {
278 5565365c 2024-03-27 op local testroot=`test_init many_commits_not_summarized 1`
280 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
282 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
283 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
284 5565365c 2024-03-27 op test_done "$testroot" 1
288 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
290 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
291 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
292 5565365c 2024-03-27 op test_done "$testroot" 1
296 5565365c 2024-03-27 op for i in `seq 1 24`; do
297 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
298 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
299 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
300 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
301 939d3016 2024-04-23 op set -- "$@" "$commit_id $author_time"
304 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
305 5565365c 2024-03-27 op > $testroot/stdout &
307 5a430400 2024-05-12 naddy sleep 1 # server starts up
309 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
311 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
312 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
313 5565365c 2024-03-27 op test_done "$testroot" "1"
317 5565365c 2024-03-27 op wait %1 # wait for the http "server"
319 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
321 5565365c 2024-03-27 op for i in `seq 1 24`; do
322 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
323 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
324 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
326 87890bc2 2024-03-28 op echo "$comma"
331 93623901 2024-03-28 op "type":"commit",
332 87890bc2 2024-03-28 op "short":false,
333 c1003102 2024-04-15 op "repo":"test-repo",
334 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
335 87890bc2 2024-03-28 op "id":"$commit_id",
337 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
338 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
339 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
340 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
342 ac0a4dfc 2024-03-28 op "committer":{
343 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
344 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
345 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
346 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
348 939d3016 2024-04-23 op "date":$commit_time,
349 ac0a4dfc 2024-03-28 op "short_message":"make changes",
350 87890bc2 2024-03-28 op "message":"make changes\n",
353 763b7f49 2024-03-28 op "action":"modified",
354 763b7f49 2024-03-28 op "file":"alpha",
365 5565365c 2024-03-27 op done >> $testroot/stdout.expected
366 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
367 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
372 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
374 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
375 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
376 5565365c 2024-03-27 op test_done "$testroot" "$ret"
380 5565365c 2024-03-27 op test_done "$testroot" "$ret"
383 5565365c 2024-03-27 op test_many_commits_summarized() {
384 5565365c 2024-03-27 op local testroot=`test_init many_commits_summarized 1`
386 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
388 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
389 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
390 5565365c 2024-03-27 op test_done "$testroot" 1
394 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
396 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
397 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
398 5565365c 2024-03-27 op test_done "$testroot" 1
402 5565365c 2024-03-27 op for i in `seq 1 51`; do
403 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
404 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
405 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
406 5565365c 2024-03-27 op local short_commit_id=`trim_obj_id 33 $commit_id`
407 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
408 939d3016 2024-04-23 op set -- "$@" "$short_commit_id $author_time"
411 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
412 5565365c 2024-03-27 op > $testroot/stdout &
414 5a430400 2024-05-12 naddy sleep 1 # server starts up
416 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
418 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
419 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
420 5565365c 2024-03-27 op test_done "$testroot" "1"
424 5565365c 2024-03-27 op wait %1 # wait for the http "server"
426 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
428 5565365c 2024-03-27 op for i in `seq 1 51`; do
429 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
430 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
431 939d3016 2024-04-23 op commit_time=$(echo "$s" | cut -d' ' -f2)
433 87890bc2 2024-03-28 op echo "$comma"
438 93623901 2024-03-28 op "type":"commit",
439 87890bc2 2024-03-28 op "short":true,
440 c1003102 2024-04-15 op "repo":"test-repo",
441 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
442 87890bc2 2024-03-28 op "id":"$commit_id",
443 ac0a4dfc 2024-03-28 op "committer":{
444 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_8"
446 939d3016 2024-04-23 op "date":$commit_time,
447 ac0a4dfc 2024-03-28 op "short_message":"make changes"
450 5565365c 2024-03-27 op done >> $testroot/stdout.expected
451 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
452 914bfd3d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
457 914bfd3d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
459 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
460 914bfd3d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
461 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
465 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
468 914bfd3d 2024-03-28 op test_branch_created() {
469 914bfd3d 2024-03-28 op local testroot=`test_init branch_created 1`
471 914bfd3d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
473 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
474 914bfd3d 2024-03-28 op echo "got clone failed unexpectedly" >&2
475 914bfd3d 2024-03-28 op test_done "$testroot" 1
479 914bfd3d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
481 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
482 914bfd3d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
483 914bfd3d 2024-03-28 op test_done "$testroot" 1
487 914bfd3d 2024-03-28 op (cd $testroot/wt && got branch newbranch > /dev/null)
489 914bfd3d 2024-03-28 op echo "change alpha on branch" > $testroot/wt/alpha
490 914bfd3d 2024-03-28 op (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
491 914bfd3d 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
492 914bfd3d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
494 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
495 914bfd3d 2024-03-28 op > $testroot/stdout &
497 5a430400 2024-05-12 naddy sleep 1 # server starts up
499 914bfd3d 2024-03-28 op got send -b newbranch -q -r $testroot/repo-clone
501 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
502 914bfd3d 2024-03-28 op echo "got send failed unexpectedly" >&2
503 914bfd3d 2024-03-28 op test_done "$testroot" "1"
507 914bfd3d 2024-03-28 op wait %1 # wait for the http "server"
509 914bfd3d 2024-03-28 op # in the future it should contain something like this too
511 914bfd3d 2024-03-28 op # "type":"new-branch",
512 914bfd3d 2024-03-28 op # "user":"${GOTD_DEVUSER}",
513 914bfd3d 2024-03-28 op # "ref":"refs/heads/newbranch"
516 914bfd3d 2024-03-28 op touch "$testroot/stdout.expected"
517 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
519 914bfd3d 2024-03-28 op {"notifications":[
521 914bfd3d 2024-03-28 op "type":"commit",
522 914bfd3d 2024-03-28 op "short":false,
523 c1003102 2024-04-15 op "repo":"test-repo",
524 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
525 914bfd3d 2024-03-28 op "id":"$commit_id",
527 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
528 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
529 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
530 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
532 914bfd3d 2024-03-28 op "committer":{
533 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
534 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
535 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
536 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
538 939d3016 2024-04-23 op "date":$author_time,
539 914bfd3d 2024-03-28 op "short_message":"newbranch",
540 914bfd3d 2024-03-28 op "message":"newbranch\n",
543 763b7f49 2024-03-28 op "action":"modified",
544 763b7f49 2024-03-28 op "file":"alpha",
560 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
562 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
563 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
564 5565365c 2024-03-27 op test_done "$testroot" "$ret"
568 5565365c 2024-03-27 op test_done "$testroot" "$ret"
571 d6057084 2024-03-28 op test_branch_removed() {
572 d6057084 2024-03-28 op local testroot=`test_init branch_removed 1`
574 d6057084 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
576 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
577 d6057084 2024-03-28 op echo "got clone failed unexpectedly" >&2
578 d6057084 2024-03-28 op test_done "$testroot" 1
582 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
583 d6057084 2024-03-28 op > $testroot/stdout &
585 5a430400 2024-05-12 naddy sleep 1 # server starts up
587 d6057084 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
589 d6057084 2024-03-28 op got send -d newbranch -q -r $testroot/repo-clone
591 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
592 d6057084 2024-03-28 op echo "got send failed unexpectedly" >&2
593 d6057084 2024-03-28 op test_done "$testroot" "1"
597 d6057084 2024-03-28 op wait %1 # wait for the http "server"
599 d6057084 2024-03-28 op touch "$testroot/stdout.expected"
600 d6057084 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
602 d6057084 2024-03-28 op {"notifications":[{
603 d6057084 2024-03-28 op "type":"branch-deleted",
604 c1003102 2024-04-15 op "repo":"test-repo",
605 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
606 d6057084 2024-03-28 op "ref":"refs/heads/newbranch",
607 d6057084 2024-03-28 op "id":"$commit_id"
614 553d8347 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
616 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
617 553d8347 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
618 553d8347 2024-03-28 op test_done "$testroot" "$ret"
622 553d8347 2024-03-28 op test_done "$testroot" "$ret"
625 553d8347 2024-03-28 op test_tag_created() {
626 553d8347 2024-03-28 op local testroot=`test_init tag_created 1`
628 553d8347 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
630 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
631 553d8347 2024-03-28 op echo "got clone failed unexpectedly" >&2
632 553d8347 2024-03-28 op test_done "$testroot" 1
636 553d8347 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
637 553d8347 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
638 553d8347 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
640 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
641 553d8347 2024-03-28 op >$testroot/stdout &
643 5a430400 2024-05-12 naddy sleep 1 # server starts up
645 553d8347 2024-03-28 op got send -t 1.0 -q -r $testroot/repo-clone
647 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
648 553d8347 2024-03-28 op echo "got send failed unexpectedly" >&2
649 553d8347 2024-03-28 op test_done "$testroot" "1"
653 553d8347 2024-03-28 op wait %1 # wait for the http "server"
655 553d8347 2024-03-28 op touch "$testroot/stdout.expected"
656 553d8347 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
658 553d8347 2024-03-28 op {"notifications":[{
659 553d8347 2024-03-28 op "type":"tag",
660 c1003102 2024-04-15 op "repo":"test-repo",
661 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
662 553d8347 2024-03-28 op "tag":"refs/tags/1.0",
664 553d8347 2024-03-28 op "full":"$GOT_AUTHOR",
665 553d8347 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
666 553d8347 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
667 553d8347 2024-03-28 op "user":"$GOT_AUTHOR_11"
669 939d3016 2024-04-23 op "date":$tagger_time,
671 553d8347 2024-03-28 op "type":"commit",
672 553d8347 2024-03-28 op "id":"$commit_id"
674 553d8347 2024-03-28 op "message":"new tag\n\n"
681 d6057084 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
683 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
684 d6057084 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
685 d6057084 2024-03-28 op test_done "$testroot" "$ret"
689 d6057084 2024-03-28 op test_done "$testroot" "$ret"
692 cd182532 2024-03-28 op test_tag_changed() {
693 cd182532 2024-03-28 op local testroot=`test_init tag_changed 1`
695 cd182532 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
697 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
698 cd182532 2024-03-28 op echo "got clone failed unexpectedly" >&2
699 cd182532 2024-03-28 op test_done "$testroot" 1
703 cd182532 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
705 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
706 cd182532 2024-03-28 op echo "got checkout failed unexpectedly" >&2
707 cd182532 2024-03-28 op test_done "$testroot" 1
711 cd182532 2024-03-28 op echo "change alpha" > $testroot/wt/alpha
712 cd182532 2024-03-28 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
713 cd182532 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
715 cd182532 2024-03-28 op got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
716 cd182532 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
717 cd182532 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
719 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
720 cd182532 2024-03-28 op > $testroot/stdout &
722 5a430400 2024-05-12 naddy sleep 1 # server starts up
724 cd182532 2024-03-28 op got send -f -t 1.0 -q -r $testroot/repo-clone
726 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
727 cd182532 2024-03-28 op echo "got send failed unexpectedly" >&2
728 cd182532 2024-03-28 op test_done "$testroot" "1"
732 cd182532 2024-03-28 op wait %1 # wait for the http "server"
734 cd182532 2024-03-28 op # XXX: at the moment this is exactly the same as the "new tag"
735 cd182532 2024-03-28 op # notification
737 cd182532 2024-03-28 op touch "$testroot/stdout.expected"
738 cd182532 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
740 cd182532 2024-03-28 op {"notifications":[{
741 cd182532 2024-03-28 op "type":"tag",
742 c1003102 2024-04-15 op "repo":"test-repo",
743 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
744 cd182532 2024-03-28 op "tag":"refs/tags/1.0",
746 cd182532 2024-03-28 op "full":"$GOT_AUTHOR",
747 cd182532 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
748 cd182532 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
749 cd182532 2024-03-28 op "user":"$GOT_AUTHOR_11"
751 939d3016 2024-04-23 op "date":$tagger_time,
753 cd182532 2024-03-28 op "type":"commit",
754 cd182532 2024-03-28 op "id":"$commit_id"
756 cd182532 2024-03-28 op "message":"new tag\n\n"
763 cd182532 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
765 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
766 cd182532 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
767 cd182532 2024-03-28 op test_done "$testroot" "$ret"
771 cd182532 2024-03-28 op test_done "$testroot" "$ret"
774 5565365c 2024-03-27 op test_parseargs "$@"
775 5565365c 2024-03-27 op run_test test_file_changed
776 ea5e974d 2024-03-28 op run_test test_bad_utf8
777 5565365c 2024-03-27 op run_test test_many_commits_not_summarized
778 5565365c 2024-03-27 op run_test test_many_commits_summarized
779 914bfd3d 2024-03-28 op run_test test_branch_created
780 d6057084 2024-03-28 op run_test test_branch_removed
781 553d8347 2024-03-28 op run_test test_tag_created
782 cd182532 2024-03-28 op run_test test_tag_changed