3 94a3f4e9 2024-03-30 thomas # Copyright (c) 2024 Omar Polo <op@openbsd.org>
5 94a3f4e9 2024-03-30 thomas # Permission to use, copy, modify, and distribute this software for any
6 94a3f4e9 2024-03-30 thomas # purpose with or without fee is hereby granted, provided that the above
7 94a3f4e9 2024-03-30 thomas # copyright notice and this permission notice appear in all copies.
9 94a3f4e9 2024-03-30 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 94a3f4e9 2024-03-30 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 94a3f4e9 2024-03-30 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 94a3f4e9 2024-03-30 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 94a3f4e9 2024-03-30 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 94a3f4e9 2024-03-30 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 94a3f4e9 2024-03-30 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 94a3f4e9 2024-03-30 thomas . ../cmdline/common.sh
18 94a3f4e9 2024-03-30 thomas . ./common.sh
20 f0b0cfba 2024-04-25 thomas.ad # flan:password encoded in base64
21 f0b0cfba 2024-04-25 thomas.ad AUTH="ZmxhbjpwYXNzd29yZA=="
23 94a3f4e9 2024-03-30 thomas test_file_changed() {
24 94a3f4e9 2024-03-30 thomas local testroot=`test_init file_changed 1`
26 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
28 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
29 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
30 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
34 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
36 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
37 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
38 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
42 94a3f4e9 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
43 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
44 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
45 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
47 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
48 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
50 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
52 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
53 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
54 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
58 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
60 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
62 0178cac9 2024-03-30 thomas touch "$testroot/stdout.expected"
63 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
65 0178cac9 2024-03-30 thomas {"notifications":[{
66 71b7e0f5 2024-03-30 thomas "type":"commit",
67 0178cac9 2024-03-30 thomas "short":false,
68 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
69 0178cac9 2024-03-30 thomas "id":"$commit_id",
70 9c485a11 2024-03-30 thomas "author":{
71 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
72 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
73 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
74 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
76 9c485a11 2024-03-30 thomas "committer":{
77 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
78 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
79 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
80 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
82 0178cac9 2024-03-30 thomas "date":"$d",
83 9c485a11 2024-03-30 thomas "short_message":"make changes",
84 0178cac9 2024-03-30 thomas "message":"make changes\n",
85 9e56e3e7 2024-03-30 thomas "diffstat":{
86 9e56e3e7 2024-03-30 thomas "files":[{
87 9e56e3e7 2024-03-30 thomas "action":"modified",
88 9e56e3e7 2024-03-30 thomas "file":"alpha",
89 9e56e3e7 2024-03-30 thomas "added":1,
90 9e56e3e7 2024-03-30 thomas "removed":1
93 9e56e3e7 2024-03-30 thomas "added":1,
94 9e56e3e7 2024-03-30 thomas "removed":1
103 fcfdd0a1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
105 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
106 fcfdd0a1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
107 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
111 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
114 fcfdd0a1 2024-03-30 thomas test_bad_utf8() {
115 fcfdd0a1 2024-03-30 thomas local testroot=`test_init bad_utf8 1`
117 fcfdd0a1 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
119 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
120 fcfdd0a1 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
121 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
125 fcfdd0a1 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
127 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
128 fcfdd0a1 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
129 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
132 5571f6ee 2024-03-30 thomas # invalid utf8 sequence
133 fcfdd0a1 2024-03-30 thomas commit_msg="make$(printf '\xED\xA0\x80')changes"
135 fcfdd0a1 2024-03-30 thomas echo "changed" > $testroot/wt/alpha
136 fcfdd0a1 2024-03-30 thomas (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
137 fcfdd0a1 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
138 fcfdd0a1 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
140 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
141 fcfdd0a1 2024-03-30 thomas > $testroot/stdout &
143 fcfdd0a1 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
145 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
146 fcfdd0a1 2024-03-30 thomas echo "got send failed unexpectedly" >&2
147 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "1"
151 fcfdd0a1 2024-03-30 thomas wait %1 # wait for the http "server"
153 fcfdd0a1 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
155 fcfdd0a1 2024-03-30 thomas touch "$testroot/stdout.expected"
156 fcfdd0a1 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
158 fcfdd0a1 2024-03-30 thomas {"notifications":[{
159 71b7e0f5 2024-03-30 thomas "type":"commit",
160 fcfdd0a1 2024-03-30 thomas "short":false,
161 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
162 fcfdd0a1 2024-03-30 thomas "id":"$commit_id",
163 9c485a11 2024-03-30 thomas "author":{
164 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
165 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
166 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
167 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
169 9c485a11 2024-03-30 thomas "committer":{
170 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
171 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
172 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
173 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
175 fcfdd0a1 2024-03-30 thomas "date":"$d",
176 9c485a11 2024-03-30 thomas "short_message":"make\uFFFD\uFFFDchanges",
177 fcfdd0a1 2024-03-30 thomas "message":"make\uFFFD\uFFFDchanges\n",
178 9e56e3e7 2024-03-30 thomas "diffstat":{
179 9e56e3e7 2024-03-30 thomas "files":[{
180 9e56e3e7 2024-03-30 thomas "action":"modified",
181 9e56e3e7 2024-03-30 thomas "file":"alpha",
182 9e56e3e7 2024-03-30 thomas "added":1,
183 9e56e3e7 2024-03-30 thomas "removed":1
185 9e56e3e7 2024-03-30 thomas "total":{
186 9e56e3e7 2024-03-30 thomas "added":1,
187 9e56e3e7 2024-03-30 thomas "removed":1
196 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
198 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
199 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
200 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
204 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
207 94a3f4e9 2024-03-30 thomas test_many_commits_not_summarized() {
208 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_not_summarized 1`
210 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
212 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
213 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
214 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
218 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
220 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
221 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
222 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
226 94a3f4e9 2024-03-30 thomas for i in `seq 1 24`; do
227 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
228 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
229 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
230 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
231 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
232 94a3f4e9 2024-03-30 thomas set -- "$@" "$commit_id $d"
235 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
236 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
238 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
240 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
241 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
242 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
246 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
248 86901c63 2024-03-30 thomas printf '{"notifications":[' > $testroot/stdout.expected
250 94a3f4e9 2024-03-30 thomas for i in `seq 1 24`; do
251 94a3f4e9 2024-03-30 thomas s=`pop_idx $i "$@"`
252 94a3f4e9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
253 54b4b049 2024-04-09 thomas commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
255 0178cac9 2024-03-30 thomas echo "$comma"
256 0178cac9 2024-03-30 thomas comma=','
258 0178cac9 2024-03-30 thomas cat <<-EOF
260 71b7e0f5 2024-03-30 thomas "type":"commit",
261 0178cac9 2024-03-30 thomas "short":false,
262 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
263 0178cac9 2024-03-30 thomas "id":"$commit_id",
264 9c485a11 2024-03-30 thomas "author":{
265 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
266 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
267 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
268 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
270 9c485a11 2024-03-30 thomas "committer":{
271 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
272 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
273 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
274 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
276 0178cac9 2024-03-30 thomas "date":"$commit_time",
277 9c485a11 2024-03-30 thomas "short_message":"make changes",
278 0178cac9 2024-03-30 thomas "message":"make changes\n",
279 9e56e3e7 2024-03-30 thomas "diffstat":{
280 9e56e3e7 2024-03-30 thomas "files":[{
281 9e56e3e7 2024-03-30 thomas "action":"modified",
282 9e56e3e7 2024-03-30 thomas "file":"alpha",
283 9e56e3e7 2024-03-30 thomas "added":1,
284 9e56e3e7 2024-03-30 thomas "removed":1
286 9e56e3e7 2024-03-30 thomas "total":{
287 9e56e3e7 2024-03-30 thomas "added":1,
288 9e56e3e7 2024-03-30 thomas "removed":1
293 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
294 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
295 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
300 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
302 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
303 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
304 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
308 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
311 94a3f4e9 2024-03-30 thomas test_many_commits_summarized() {
312 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_summarized 1`
314 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
316 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
317 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
318 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
322 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
324 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
325 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
326 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
330 94a3f4e9 2024-03-30 thomas for i in `seq 1 51`; do
331 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
332 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
333 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
334 94a3f4e9 2024-03-30 thomas local short_commit_id=`trim_obj_id 33 $commit_id`
335 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
336 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%G-%m-%d"`
337 94a3f4e9 2024-03-30 thomas set -- "$@" "$short_commit_id $d"
340 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
341 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
343 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
345 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
346 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
347 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
351 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
353 86901c63 2024-03-30 thomas printf '{"notifications":[' > $testroot/stdout.expected
355 94a3f4e9 2024-03-30 thomas for i in `seq 1 51`; do
356 94a3f4e9 2024-03-30 thomas s=`pop_idx $i "$@"`
357 94a3f4e9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
358 54b4b049 2024-04-09 thomas commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
360 0178cac9 2024-03-30 thomas echo "$comma"
361 0178cac9 2024-03-30 thomas comma=','
363 0178cac9 2024-03-30 thomas cat <<-EOF
365 71b7e0f5 2024-03-30 thomas "type":"commit",
366 0178cac9 2024-03-30 thomas "short":true,
367 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
368 0178cac9 2024-03-30 thomas "id":"$commit_id",
369 9c485a11 2024-03-30 thomas "committer":{
370 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_8"
372 0178cac9 2024-03-30 thomas "date":"$commit_time",
373 9c485a11 2024-03-30 thomas "short_message":"make changes"
376 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
377 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
378 444f59b9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
383 444f59b9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
385 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
386 444f59b9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
387 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
391 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
394 444f59b9 2024-03-30 thomas test_branch_created() {
395 444f59b9 2024-03-30 thomas local testroot=`test_init branch_created 1`
397 444f59b9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
399 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
400 444f59b9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
401 444f59b9 2024-03-30 thomas test_done "$testroot" 1
405 444f59b9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
407 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
408 444f59b9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
409 444f59b9 2024-03-30 thomas test_done "$testroot" 1
413 444f59b9 2024-03-30 thomas (cd $testroot/wt && got branch newbranch > /dev/null)
415 444f59b9 2024-03-30 thomas echo "change alpha on branch" > $testroot/wt/alpha
416 444f59b9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
417 444f59b9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
418 444f59b9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
420 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
421 444f59b9 2024-03-30 thomas > $testroot/stdout &
423 444f59b9 2024-03-30 thomas got send -b newbranch -q -r $testroot/repo-clone
425 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
426 444f59b9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
427 444f59b9 2024-03-30 thomas test_done "$testroot" "1"
431 444f59b9 2024-03-30 thomas wait %1 # wait for the http "server"
433 444f59b9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
435 444f59b9 2024-03-30 thomas # in the future it should contain something like this too
437 444f59b9 2024-03-30 thomas # "type":"new-branch",
438 444f59b9 2024-03-30 thomas # "user":"${GOTD_DEVUSER}",
439 444f59b9 2024-03-30 thomas # "ref":"refs/heads/newbranch"
442 444f59b9 2024-03-30 thomas touch "$testroot/stdout.expected"
443 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
445 444f59b9 2024-03-30 thomas {"notifications":[
447 444f59b9 2024-03-30 thomas "type":"commit",
448 444f59b9 2024-03-30 thomas "short":false,
449 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
450 444f59b9 2024-03-30 thomas "id":"$commit_id",
451 444f59b9 2024-03-30 thomas "author":{
452 444f59b9 2024-03-30 thomas "full":"$GOT_AUTHOR",
453 444f59b9 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
454 444f59b9 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
455 444f59b9 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
457 444f59b9 2024-03-30 thomas "committer":{
458 444f59b9 2024-03-30 thomas "full":"$GOT_AUTHOR",
459 444f59b9 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
460 444f59b9 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
461 444f59b9 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
463 444f59b9 2024-03-30 thomas "date":"$d",
464 444f59b9 2024-03-30 thomas "short_message":"newbranch",
465 444f59b9 2024-03-30 thomas "message":"newbranch\n",
466 9e56e3e7 2024-03-30 thomas "diffstat":{
467 9e56e3e7 2024-03-30 thomas "files":[{
468 9e56e3e7 2024-03-30 thomas "action":"modified",
469 9e56e3e7 2024-03-30 thomas "file":"alpha",
470 9e56e3e7 2024-03-30 thomas "added":1,
471 9e56e3e7 2024-03-30 thomas "removed":1
473 9e56e3e7 2024-03-30 thomas "total":{
474 9e56e3e7 2024-03-30 thomas "added":1,
475 9e56e3e7 2024-03-30 thomas "removed":1
485 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
487 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
488 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
489 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
493 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
496 4808d170 2024-03-30 thomas test_branch_removed() {
497 4808d170 2024-03-30 thomas local testroot=`test_init branch_removed 1`
499 4808d170 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
501 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
502 4808d170 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
503 4808d170 2024-03-30 thomas test_done "$testroot" 1
507 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
508 4808d170 2024-03-30 thomas > $testroot/stdout &
510 4808d170 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
512 4808d170 2024-03-30 thomas got send -d newbranch -q -r $testroot/repo-clone
514 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
515 4808d170 2024-03-30 thomas echo "got send failed unexpectedly" >&2
516 4808d170 2024-03-30 thomas test_done "$testroot" "1"
520 4808d170 2024-03-30 thomas wait %1 # wait for the http "server"
522 4808d170 2024-03-30 thomas touch "$testroot/stdout.expected"
523 4808d170 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
525 4808d170 2024-03-30 thomas {"notifications":[{
526 4808d170 2024-03-30 thomas "type":"branch-deleted",
527 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
528 4808d170 2024-03-30 thomas "ref":"refs/heads/newbranch",
529 4808d170 2024-03-30 thomas "id":"$commit_id"
536 e0d15dee 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
538 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
539 e0d15dee 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
540 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
544 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
547 e0d15dee 2024-03-30 thomas test_tag_created() {
548 e0d15dee 2024-03-30 thomas local testroot=`test_init tag_created 1`
550 e0d15dee 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
552 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
553 e0d15dee 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
554 e0d15dee 2024-03-30 thomas test_done "$testroot" 1
558 e0d15dee 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
559 e0d15dee 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
560 e0d15dee 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
562 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
563 e0d15dee 2024-03-30 thomas >$testroot/stdout &
565 e0d15dee 2024-03-30 thomas got send -t 1.0 -q -r $testroot/repo-clone
567 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
568 e0d15dee 2024-03-30 thomas echo "got send failed unexpectedly" >&2
569 e0d15dee 2024-03-30 thomas test_done "$testroot" "1"
573 e0d15dee 2024-03-30 thomas wait %1 # wait for the http "server"
575 e0d15dee 2024-03-30 thomas d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
577 e0d15dee 2024-03-30 thomas touch "$testroot/stdout.expected"
578 e0d15dee 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
580 e0d15dee 2024-03-30 thomas {"notifications":[{
581 e0d15dee 2024-03-30 thomas "type":"tag",
582 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
583 e0d15dee 2024-03-30 thomas "tag":"refs/tags/1.0",
584 e0d15dee 2024-03-30 thomas "tagger":{
585 e0d15dee 2024-03-30 thomas "full":"$GOT_AUTHOR",
586 e0d15dee 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
587 e0d15dee 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
588 e0d15dee 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
590 e0d15dee 2024-03-30 thomas "date":"$d",
591 e0d15dee 2024-03-30 thomas "object":{
592 e0d15dee 2024-03-30 thomas "type":"commit",
593 e0d15dee 2024-03-30 thomas "id":"$commit_id"
595 e0d15dee 2024-03-30 thomas "message":"new tag\n\n"
602 4808d170 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
604 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
605 4808d170 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
606 4808d170 2024-03-30 thomas test_done "$testroot" "$ret"
610 4808d170 2024-03-30 thomas test_done "$testroot" "$ret"
613 407d84f1 2024-03-30 thomas test_tag_changed() {
614 407d84f1 2024-03-30 thomas local testroot=`test_init tag_changed 1`
616 407d84f1 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
618 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
619 407d84f1 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
620 407d84f1 2024-03-30 thomas test_done "$testroot" 1
624 407d84f1 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
626 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
627 407d84f1 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
628 407d84f1 2024-03-30 thomas test_done "$testroot" 1
632 407d84f1 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
633 407d84f1 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
634 407d84f1 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
636 407d84f1 2024-03-30 thomas got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
637 407d84f1 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
638 407d84f1 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
640 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
641 407d84f1 2024-03-30 thomas > $testroot/stdout &
643 407d84f1 2024-03-30 thomas got send -f -t 1.0 -q -r $testroot/repo-clone
645 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
646 407d84f1 2024-03-30 thomas echo "got send failed unexpectedly" >&2
647 407d84f1 2024-03-30 thomas test_done "$testroot" "1"
651 407d84f1 2024-03-30 thomas wait %1 # wait for the http "server"
653 407d84f1 2024-03-30 thomas d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
655 407d84f1 2024-03-30 thomas # XXX: at the moment this is exactly the same as the "new tag"
656 407d84f1 2024-03-30 thomas # notification
658 407d84f1 2024-03-30 thomas touch "$testroot/stdout.expected"
659 407d84f1 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
661 407d84f1 2024-03-30 thomas {"notifications":[{
662 407d84f1 2024-03-30 thomas "type":"tag",
663 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
664 407d84f1 2024-03-30 thomas "tag":"refs/tags/1.0",
665 407d84f1 2024-03-30 thomas "tagger":{
666 407d84f1 2024-03-30 thomas "full":"$GOT_AUTHOR",
667 407d84f1 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
668 407d84f1 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
669 407d84f1 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
671 407d84f1 2024-03-30 thomas "date":"$d",
672 407d84f1 2024-03-30 thomas "object":{
673 407d84f1 2024-03-30 thomas "type":"commit",
674 407d84f1 2024-03-30 thomas "id":"$commit_id"
676 407d84f1 2024-03-30 thomas "message":"new tag\n\n"
683 407d84f1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
685 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
686 407d84f1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
687 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
691 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
694 94a3f4e9 2024-03-30 thomas test_parseargs "$@"
695 94a3f4e9 2024-03-30 thomas run_test test_file_changed
696 fcfdd0a1 2024-03-30 thomas run_test test_bad_utf8
697 94a3f4e9 2024-03-30 thomas run_test test_many_commits_not_summarized
698 94a3f4e9 2024-03-30 thomas run_test test_many_commits_summarized
699 444f59b9 2024-03-30 thomas run_test test_branch_created
700 4808d170 2024-03-30 thomas run_test test_branch_removed
701 e0d15dee 2024-03-30 thomas run_test test_tag_created
702 407d84f1 2024-03-30 thomas run_test test_tag_changed