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 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
68 87890bc2 2024-03-28 op "id":"$commit_id",
70 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
71 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
72 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
73 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
76 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
77 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
78 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
79 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
81 939d3016 2024-04-23 op "date":$author_time,
82 ac0a4dfc 2024-03-28 op "short_message":"make changes",
83 87890bc2 2024-03-28 op "message":"make changes\n",
86 763b7f49 2024-03-28 op "action":"modified",
87 763b7f49 2024-03-28 op "file":"alpha",
102 ea5e974d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
104 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
105 ea5e974d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
106 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
110 c3cc85a3 2024-04-30 stsp # Try the same thing again with 'git push' instead of 'got send'
111 c3cc85a3 2024-04-30 stsp echo "change alpha once more" > $testroot/wt/alpha
112 c3cc85a3 2024-04-30 stsp (cd $testroot/wt && got commit -m 'make more changes' > /dev/null)
113 c3cc85a3 2024-04-30 stsp local commit_id=`git_show_head $testroot/repo-clone`
114 c3cc85a3 2024-04-30 stsp local author_time=`git_show_author_time $testroot/repo-clone`
116 c3cc85a3 2024-04-30 stsp timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
117 c3cc85a3 2024-04-30 stsp > $testroot/stdout &
119 c3cc85a3 2024-04-30 stsp git -C $testroot/repo-clone push -q origin main
121 c3cc85a3 2024-04-30 stsp if [ $ret -ne 0 ]; then
122 c3cc85a3 2024-04-30 stsp echo "git push failed unexpectedly" >&2
123 c3cc85a3 2024-04-30 stsp test_done "$testroot" "1"
127 c3cc85a3 2024-04-30 stsp wait %1 # wait for the http "server"
129 c3cc85a3 2024-04-30 stsp echo -n > "$testroot/stdout.expected"
130 c3cc85a3 2024-04-30 stsp ed -s "$testroot/stdout.expected" <<-EOF
132 c3cc85a3 2024-04-30 stsp {"notifications":[{
133 c3cc85a3 2024-04-30 stsp "type":"commit",
134 c3cc85a3 2024-04-30 stsp "short":false,
135 c3cc85a3 2024-04-30 stsp "repo":"test-repo",
136 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
137 c3cc85a3 2024-04-30 stsp "id":"$commit_id",
139 c3cc85a3 2024-04-30 stsp "full":"$GOT_AUTHOR",
140 c3cc85a3 2024-04-30 stsp "name":"$GIT_AUTHOR_NAME",
141 c3cc85a3 2024-04-30 stsp "mail":"$GIT_AUTHOR_EMAIL",
142 c3cc85a3 2024-04-30 stsp "user":"$GOT_AUTHOR_11"
144 c3cc85a3 2024-04-30 stsp "committer":{
145 c3cc85a3 2024-04-30 stsp "full":"$GOT_AUTHOR",
146 c3cc85a3 2024-04-30 stsp "name":"$GIT_AUTHOR_NAME",
147 c3cc85a3 2024-04-30 stsp "mail":"$GIT_AUTHOR_EMAIL",
148 c3cc85a3 2024-04-30 stsp "user":"$GOT_AUTHOR_11"
150 c3cc85a3 2024-04-30 stsp "date":$author_time,
151 c3cc85a3 2024-04-30 stsp "short_message":"make more changes",
152 c3cc85a3 2024-04-30 stsp "message":"make more changes\n",
153 c3cc85a3 2024-04-30 stsp "diffstat":{
155 c3cc85a3 2024-04-30 stsp "action":"modified",
156 c3cc85a3 2024-04-30 stsp "file":"alpha",
158 c3cc85a3 2024-04-30 stsp "removed":1
162 c3cc85a3 2024-04-30 stsp "removed":1
171 c3cc85a3 2024-04-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 c3cc85a3 2024-04-30 stsp if [ $ret -ne 0 ]; then
174 c3cc85a3 2024-04-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
179 ea5e974d 2024-03-28 op test_bad_utf8() {
180 ea5e974d 2024-03-28 op local testroot=`test_init bad_utf8 1`
182 ea5e974d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
184 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
185 ea5e974d 2024-03-28 op echo "got clone failed unexpectedly" >&2
186 ea5e974d 2024-03-28 op test_done "$testroot" 1
190 ea5e974d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
192 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
193 ea5e974d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
194 ea5e974d 2024-03-28 op test_done "$testroot" 1
197 cdaefb15 2024-03-28 stsp # invalid utf8 sequence
198 ea5e974d 2024-03-28 op commit_msg="make$(printf '\xED\xA0\x80')changes"
200 ea5e974d 2024-03-28 op echo "changed" > $testroot/wt/alpha
201 ea5e974d 2024-03-28 op (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
202 ea5e974d 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
203 ea5e974d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone`
205 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
206 ea5e974d 2024-03-28 op > $testroot/stdout &
208 ea5e974d 2024-03-28 op got send -b main -q -r $testroot/repo-clone
210 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
211 ea5e974d 2024-03-28 op echo "got send failed unexpectedly" >&2
212 ea5e974d 2024-03-28 op test_done "$testroot" "1"
216 ea5e974d 2024-03-28 op wait %1 # wait for the http "server"
218 ea5e974d 2024-03-28 op touch "$testroot/stdout.expected"
219 ea5e974d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
221 ea5e974d 2024-03-28 op {"notifications":[{
222 93623901 2024-03-28 op "type":"commit",
223 ea5e974d 2024-03-28 op "short":false,
224 c1003102 2024-04-15 op "repo":"test-repo",
225 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
226 ea5e974d 2024-03-28 op "id":"$commit_id",
228 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
229 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
230 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
231 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
233 ac0a4dfc 2024-03-28 op "committer":{
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 939d3016 2024-04-23 op "date":$author_time,
240 ac0a4dfc 2024-03-28 op "short_message":"make\uFFFD\uFFFDchanges",
241 ea5e974d 2024-03-28 op "message":"make\uFFFD\uFFFDchanges\n",
244 763b7f49 2024-03-28 op "action":"modified",
245 763b7f49 2024-03-28 op "file":"alpha",
260 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
262 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
263 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
264 5565365c 2024-03-27 op test_done "$testroot" "$ret"
268 5565365c 2024-03-27 op test_done "$testroot" "$ret"
271 5565365c 2024-03-27 op test_many_commits_not_summarized() {
272 5565365c 2024-03-27 op local testroot=`test_init many_commits_not_summarized 1`
274 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
276 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
277 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
278 5565365c 2024-03-27 op test_done "$testroot" 1
282 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
284 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
285 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
286 5565365c 2024-03-27 op test_done "$testroot" 1
290 5565365c 2024-03-27 op for i in `seq 1 24`; do
291 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
292 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
293 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
294 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
295 939d3016 2024-04-23 op set -- "$@" "$commit_id $author_time"
298 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
299 5565365c 2024-03-27 op > $testroot/stdout &
301 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
303 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
304 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
305 5565365c 2024-03-27 op test_done "$testroot" "1"
309 5565365c 2024-03-27 op wait %1 # wait for the http "server"
311 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
313 5565365c 2024-03-27 op for i in `seq 1 24`; do
314 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
315 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
316 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
318 87890bc2 2024-03-28 op echo "$comma"
323 93623901 2024-03-28 op "type":"commit",
324 87890bc2 2024-03-28 op "short":false,
325 c1003102 2024-04-15 op "repo":"test-repo",
326 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
327 87890bc2 2024-03-28 op "id":"$commit_id",
329 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
330 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
331 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
332 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
334 ac0a4dfc 2024-03-28 op "committer":{
335 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
336 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
337 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
338 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
340 939d3016 2024-04-23 op "date":$commit_time,
341 ac0a4dfc 2024-03-28 op "short_message":"make changes",
342 87890bc2 2024-03-28 op "message":"make changes\n",
345 763b7f49 2024-03-28 op "action":"modified",
346 763b7f49 2024-03-28 op "file":"alpha",
357 5565365c 2024-03-27 op done >> $testroot/stdout.expected
358 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
359 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
364 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
366 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
367 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
368 5565365c 2024-03-27 op test_done "$testroot" "$ret"
372 5565365c 2024-03-27 op test_done "$testroot" "$ret"
375 5565365c 2024-03-27 op test_many_commits_summarized() {
376 5565365c 2024-03-27 op local testroot=`test_init many_commits_summarized 1`
378 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
380 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
381 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
382 5565365c 2024-03-27 op test_done "$testroot" 1
386 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
388 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
389 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
390 5565365c 2024-03-27 op test_done "$testroot" 1
394 5565365c 2024-03-27 op for i in `seq 1 51`; do
395 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
396 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
397 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
398 5565365c 2024-03-27 op local short_commit_id=`trim_obj_id 33 $commit_id`
399 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
400 939d3016 2024-04-23 op set -- "$@" "$short_commit_id $author_time"
403 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
404 5565365c 2024-03-27 op > $testroot/stdout &
406 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
408 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
409 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
410 5565365c 2024-03-27 op test_done "$testroot" "1"
414 5565365c 2024-03-27 op wait %1 # wait for the http "server"
416 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
418 5565365c 2024-03-27 op for i in `seq 1 51`; do
419 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
420 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
421 939d3016 2024-04-23 op commit_time=$(echo "$s" | cut -d' ' -f2)
423 87890bc2 2024-03-28 op echo "$comma"
428 93623901 2024-03-28 op "type":"commit",
429 87890bc2 2024-03-28 op "short":true,
430 c1003102 2024-04-15 op "repo":"test-repo",
431 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
432 87890bc2 2024-03-28 op "id":"$commit_id",
433 ac0a4dfc 2024-03-28 op "committer":{
434 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_8"
436 939d3016 2024-04-23 op "date":$commit_time,
437 ac0a4dfc 2024-03-28 op "short_message":"make changes"
440 5565365c 2024-03-27 op done >> $testroot/stdout.expected
441 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
442 914bfd3d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
447 914bfd3d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
449 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
450 914bfd3d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
451 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
455 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
458 914bfd3d 2024-03-28 op test_branch_created() {
459 914bfd3d 2024-03-28 op local testroot=`test_init branch_created 1`
461 914bfd3d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
463 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
464 914bfd3d 2024-03-28 op echo "got clone failed unexpectedly" >&2
465 914bfd3d 2024-03-28 op test_done "$testroot" 1
469 914bfd3d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
471 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
472 914bfd3d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
473 914bfd3d 2024-03-28 op test_done "$testroot" 1
477 914bfd3d 2024-03-28 op (cd $testroot/wt && got branch newbranch > /dev/null)
479 914bfd3d 2024-03-28 op echo "change alpha on branch" > $testroot/wt/alpha
480 914bfd3d 2024-03-28 op (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
481 914bfd3d 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
482 914bfd3d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
484 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
485 914bfd3d 2024-03-28 op > $testroot/stdout &
487 914bfd3d 2024-03-28 op got send -b newbranch -q -r $testroot/repo-clone
489 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
490 914bfd3d 2024-03-28 op echo "got send failed unexpectedly" >&2
491 914bfd3d 2024-03-28 op test_done "$testroot" "1"
495 914bfd3d 2024-03-28 op wait %1 # wait for the http "server"
497 914bfd3d 2024-03-28 op # in the future it should contain something like this too
499 914bfd3d 2024-03-28 op # "type":"new-branch",
500 914bfd3d 2024-03-28 op # "user":"${GOTD_DEVUSER}",
501 914bfd3d 2024-03-28 op # "ref":"refs/heads/newbranch"
504 914bfd3d 2024-03-28 op touch "$testroot/stdout.expected"
505 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
507 914bfd3d 2024-03-28 op {"notifications":[
509 914bfd3d 2024-03-28 op "type":"commit",
510 914bfd3d 2024-03-28 op "short":false,
511 c1003102 2024-04-15 op "repo":"test-repo",
512 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
513 914bfd3d 2024-03-28 op "id":"$commit_id",
515 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
516 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
517 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
518 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
520 914bfd3d 2024-03-28 op "committer":{
521 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
522 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
523 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
524 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
526 939d3016 2024-04-23 op "date":$author_time,
527 914bfd3d 2024-03-28 op "short_message":"newbranch",
528 914bfd3d 2024-03-28 op "message":"newbranch\n",
531 763b7f49 2024-03-28 op "action":"modified",
532 763b7f49 2024-03-28 op "file":"alpha",
548 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
550 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
551 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
552 5565365c 2024-03-27 op test_done "$testroot" "$ret"
556 5565365c 2024-03-27 op test_done "$testroot" "$ret"
559 d6057084 2024-03-28 op test_branch_removed() {
560 d6057084 2024-03-28 op local testroot=`test_init branch_removed 1`
562 d6057084 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
564 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
565 d6057084 2024-03-28 op echo "got clone failed unexpectedly" >&2
566 d6057084 2024-03-28 op test_done "$testroot" 1
570 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
571 d6057084 2024-03-28 op > $testroot/stdout &
573 d6057084 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
575 d6057084 2024-03-28 op got send -d newbranch -q -r $testroot/repo-clone
577 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
578 d6057084 2024-03-28 op echo "got send failed unexpectedly" >&2
579 d6057084 2024-03-28 op test_done "$testroot" "1"
583 d6057084 2024-03-28 op wait %1 # wait for the http "server"
585 d6057084 2024-03-28 op touch "$testroot/stdout.expected"
586 d6057084 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
588 d6057084 2024-03-28 op {"notifications":[{
589 d6057084 2024-03-28 op "type":"branch-deleted",
590 c1003102 2024-04-15 op "repo":"test-repo",
591 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
592 d6057084 2024-03-28 op "ref":"refs/heads/newbranch",
593 d6057084 2024-03-28 op "id":"$commit_id"
600 553d8347 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
602 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
603 553d8347 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
604 553d8347 2024-03-28 op test_done "$testroot" "$ret"
608 553d8347 2024-03-28 op test_done "$testroot" "$ret"
611 553d8347 2024-03-28 op test_tag_created() {
612 553d8347 2024-03-28 op local testroot=`test_init tag_created 1`
614 553d8347 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
616 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
617 553d8347 2024-03-28 op echo "got clone failed unexpectedly" >&2
618 553d8347 2024-03-28 op test_done "$testroot" 1
622 553d8347 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
623 553d8347 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
624 553d8347 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
626 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
627 553d8347 2024-03-28 op >$testroot/stdout &
629 553d8347 2024-03-28 op got send -t 1.0 -q -r $testroot/repo-clone
631 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
632 553d8347 2024-03-28 op echo "got send failed unexpectedly" >&2
633 553d8347 2024-03-28 op test_done "$testroot" "1"
637 553d8347 2024-03-28 op wait %1 # wait for the http "server"
639 553d8347 2024-03-28 op touch "$testroot/stdout.expected"
640 553d8347 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
642 553d8347 2024-03-28 op {"notifications":[{
643 553d8347 2024-03-28 op "type":"tag",
644 c1003102 2024-04-15 op "repo":"test-repo",
645 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
646 553d8347 2024-03-28 op "tag":"refs/tags/1.0",
648 553d8347 2024-03-28 op "full":"$GOT_AUTHOR",
649 553d8347 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
650 553d8347 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
651 553d8347 2024-03-28 op "user":"$GOT_AUTHOR_11"
653 939d3016 2024-04-23 op "date":$tagger_time,
655 553d8347 2024-03-28 op "type":"commit",
656 553d8347 2024-03-28 op "id":"$commit_id"
658 553d8347 2024-03-28 op "message":"new tag\n\n"
665 d6057084 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
667 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
668 d6057084 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
669 d6057084 2024-03-28 op test_done "$testroot" "$ret"
673 d6057084 2024-03-28 op test_done "$testroot" "$ret"
676 cd182532 2024-03-28 op test_tag_changed() {
677 cd182532 2024-03-28 op local testroot=`test_init tag_changed 1`
679 cd182532 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
681 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
682 cd182532 2024-03-28 op echo "got clone failed unexpectedly" >&2
683 cd182532 2024-03-28 op test_done "$testroot" 1
687 cd182532 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
689 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
690 cd182532 2024-03-28 op echo "got checkout failed unexpectedly" >&2
691 cd182532 2024-03-28 op test_done "$testroot" 1
695 cd182532 2024-03-28 op echo "change alpha" > $testroot/wt/alpha
696 cd182532 2024-03-28 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
697 cd182532 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
699 cd182532 2024-03-28 op got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
700 cd182532 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
701 cd182532 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
703 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
704 cd182532 2024-03-28 op > $testroot/stdout &
706 cd182532 2024-03-28 op got send -f -t 1.0 -q -r $testroot/repo-clone
708 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
709 cd182532 2024-03-28 op echo "got send failed unexpectedly" >&2
710 cd182532 2024-03-28 op test_done "$testroot" "1"
714 cd182532 2024-03-28 op wait %1 # wait for the http "server"
716 cd182532 2024-03-28 op # XXX: at the moment this is exactly the same as the "new tag"
717 cd182532 2024-03-28 op # notification
719 cd182532 2024-03-28 op touch "$testroot/stdout.expected"
720 cd182532 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
722 cd182532 2024-03-28 op {"notifications":[{
723 cd182532 2024-03-28 op "type":"tag",
724 c1003102 2024-04-15 op "repo":"test-repo",
725 841969e1 2024-04-30 op "authenticated_user":"${GOTD_DEVUSER}",
726 cd182532 2024-03-28 op "tag":"refs/tags/1.0",
728 cd182532 2024-03-28 op "full":"$GOT_AUTHOR",
729 cd182532 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
730 cd182532 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
731 cd182532 2024-03-28 op "user":"$GOT_AUTHOR_11"
733 939d3016 2024-04-23 op "date":$tagger_time,
735 cd182532 2024-03-28 op "type":"commit",
736 cd182532 2024-03-28 op "id":"$commit_id"
738 cd182532 2024-03-28 op "message":"new tag\n\n"
745 cd182532 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
747 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
748 cd182532 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
749 cd182532 2024-03-28 op test_done "$testroot" "$ret"
753 cd182532 2024-03-28 op test_done "$testroot" "$ret"
756 5565365c 2024-03-27 op test_parseargs "$@"
757 5565365c 2024-03-27 op run_test test_file_changed
758 ea5e974d 2024-03-28 op run_test test_bad_utf8
759 5565365c 2024-03-27 op run_test test_many_commits_not_summarized
760 5565365c 2024-03-27 op run_test test_many_commits_summarized
761 914bfd3d 2024-03-28 op run_test test_branch_created
762 d6057084 2024-03-28 op run_test test_branch_removed
763 553d8347 2024-03-28 op run_test test_tag_created
764 cd182532 2024-03-28 op run_test test_tag_changed