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 0178cac9 2024-03-30 thomas touch "$testroot/stdout.expected"
61 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
63 0178cac9 2024-03-30 thomas {"notifications":[{
64 71b7e0f5 2024-03-30 thomas "type":"commit",
65 0178cac9 2024-03-30 thomas "short":false,
66 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
67 0178cac9 2024-03-30 thomas "id":"$commit_id",
68 9c485a11 2024-03-30 thomas "author":{
69 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
70 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
71 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
72 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
74 9c485a11 2024-03-30 thomas "committer":{
75 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
76 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
77 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
78 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
80 c50aaf5d 2024-04-25 thomas.ad "date":$author_time,
81 9c485a11 2024-03-30 thomas "short_message":"make changes",
82 0178cac9 2024-03-30 thomas "message":"make changes\n",
83 9e56e3e7 2024-03-30 thomas "diffstat":{
84 9e56e3e7 2024-03-30 thomas "files":[{
85 9e56e3e7 2024-03-30 thomas "action":"modified",
86 9e56e3e7 2024-03-30 thomas "file":"alpha",
87 9e56e3e7 2024-03-30 thomas "added":1,
88 9e56e3e7 2024-03-30 thomas "removed":1
91 9e56e3e7 2024-03-30 thomas "added":1,
92 9e56e3e7 2024-03-30 thomas "removed":1
101 fcfdd0a1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
103 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
104 fcfdd0a1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
105 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
109 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
112 fcfdd0a1 2024-03-30 thomas test_bad_utf8() {
113 fcfdd0a1 2024-03-30 thomas local testroot=`test_init bad_utf8 1`
115 fcfdd0a1 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
117 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
118 fcfdd0a1 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
119 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
123 fcfdd0a1 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
125 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
126 fcfdd0a1 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
127 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
130 5571f6ee 2024-03-30 thomas # invalid utf8 sequence
131 fcfdd0a1 2024-03-30 thomas commit_msg="make$(printf '\xED\xA0\x80')changes"
133 fcfdd0a1 2024-03-30 thomas echo "changed" > $testroot/wt/alpha
134 fcfdd0a1 2024-03-30 thomas (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
135 fcfdd0a1 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
136 fcfdd0a1 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
138 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
139 fcfdd0a1 2024-03-30 thomas > $testroot/stdout &
141 fcfdd0a1 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
143 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
144 fcfdd0a1 2024-03-30 thomas echo "got send failed unexpectedly" >&2
145 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "1"
149 fcfdd0a1 2024-03-30 thomas wait %1 # wait for the http "server"
151 fcfdd0a1 2024-03-30 thomas touch "$testroot/stdout.expected"
152 fcfdd0a1 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
154 fcfdd0a1 2024-03-30 thomas {"notifications":[{
155 71b7e0f5 2024-03-30 thomas "type":"commit",
156 fcfdd0a1 2024-03-30 thomas "short":false,
157 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
158 fcfdd0a1 2024-03-30 thomas "id":"$commit_id",
159 9c485a11 2024-03-30 thomas "author":{
160 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
161 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
162 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
163 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
165 9c485a11 2024-03-30 thomas "committer":{
166 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
167 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
168 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
169 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
171 c50aaf5d 2024-04-25 thomas.ad "date":$author_time,
172 9c485a11 2024-03-30 thomas "short_message":"make\uFFFD\uFFFDchanges",
173 fcfdd0a1 2024-03-30 thomas "message":"make\uFFFD\uFFFDchanges\n",
174 9e56e3e7 2024-03-30 thomas "diffstat":{
175 9e56e3e7 2024-03-30 thomas "files":[{
176 9e56e3e7 2024-03-30 thomas "action":"modified",
177 9e56e3e7 2024-03-30 thomas "file":"alpha",
178 9e56e3e7 2024-03-30 thomas "added":1,
179 9e56e3e7 2024-03-30 thomas "removed":1
181 9e56e3e7 2024-03-30 thomas "total":{
182 9e56e3e7 2024-03-30 thomas "added":1,
183 9e56e3e7 2024-03-30 thomas "removed":1
192 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
194 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
195 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
196 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
200 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
203 94a3f4e9 2024-03-30 thomas test_many_commits_not_summarized() {
204 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_not_summarized 1`
206 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
208 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
209 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
210 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
214 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
216 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
217 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
218 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
222 94a3f4e9 2024-03-30 thomas for i in `seq 1 24`; do
223 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
224 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
225 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
226 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
227 c50aaf5d 2024-04-25 thomas.ad set -- "$@" "$commit_id $author_time"
230 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
231 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
233 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
235 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
236 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
237 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
241 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
243 86901c63 2024-03-30 thomas printf '{"notifications":[' > $testroot/stdout.expected
245 94a3f4e9 2024-03-30 thomas for i in `seq 1 24`; do
246 94a3f4e9 2024-03-30 thomas s=`pop_idx $i "$@"`
247 94a3f4e9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
248 54b4b049 2024-04-09 thomas commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
250 0178cac9 2024-03-30 thomas echo "$comma"
251 0178cac9 2024-03-30 thomas comma=','
253 0178cac9 2024-03-30 thomas cat <<-EOF
255 71b7e0f5 2024-03-30 thomas "type":"commit",
256 0178cac9 2024-03-30 thomas "short":false,
257 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
258 0178cac9 2024-03-30 thomas "id":"$commit_id",
259 9c485a11 2024-03-30 thomas "author":{
260 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
261 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
262 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
263 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
265 9c485a11 2024-03-30 thomas "committer":{
266 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
267 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
268 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
269 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
271 c50aaf5d 2024-04-25 thomas.ad "date":$commit_time,
272 9c485a11 2024-03-30 thomas "short_message":"make changes",
273 0178cac9 2024-03-30 thomas "message":"make changes\n",
274 9e56e3e7 2024-03-30 thomas "diffstat":{
275 9e56e3e7 2024-03-30 thomas "files":[{
276 9e56e3e7 2024-03-30 thomas "action":"modified",
277 9e56e3e7 2024-03-30 thomas "file":"alpha",
278 9e56e3e7 2024-03-30 thomas "added":1,
279 9e56e3e7 2024-03-30 thomas "removed":1
281 9e56e3e7 2024-03-30 thomas "total":{
282 9e56e3e7 2024-03-30 thomas "added":1,
283 9e56e3e7 2024-03-30 thomas "removed":1
288 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
289 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
290 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
295 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
297 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
298 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
299 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
303 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
306 94a3f4e9 2024-03-30 thomas test_many_commits_summarized() {
307 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_summarized 1`
309 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
311 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
312 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
313 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
317 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
319 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
320 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
321 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
325 94a3f4e9 2024-03-30 thomas for i in `seq 1 51`; do
326 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
327 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
328 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
329 94a3f4e9 2024-03-30 thomas local short_commit_id=`trim_obj_id 33 $commit_id`
330 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
331 c50aaf5d 2024-04-25 thomas.ad set -- "$@" "$short_commit_id $author_time"
334 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
335 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
337 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
339 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
340 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
341 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
345 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
347 86901c63 2024-03-30 thomas printf '{"notifications":[' > $testroot/stdout.expected
349 94a3f4e9 2024-03-30 thomas for i in `seq 1 51`; do
350 94a3f4e9 2024-03-30 thomas s=`pop_idx $i "$@"`
351 94a3f4e9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
352 c50aaf5d 2024-04-25 thomas.ad commit_time=$(echo "$s" | cut -d' ' -f2)
354 0178cac9 2024-03-30 thomas echo "$comma"
355 0178cac9 2024-03-30 thomas comma=','
357 0178cac9 2024-03-30 thomas cat <<-EOF
359 71b7e0f5 2024-03-30 thomas "type":"commit",
360 0178cac9 2024-03-30 thomas "short":true,
361 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
362 0178cac9 2024-03-30 thomas "id":"$commit_id",
363 9c485a11 2024-03-30 thomas "committer":{
364 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_8"
366 c50aaf5d 2024-04-25 thomas.ad "date":$commit_time,
367 9c485a11 2024-03-30 thomas "short_message":"make changes"
370 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
371 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
372 444f59b9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
377 444f59b9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
379 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
380 444f59b9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
381 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
385 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
388 444f59b9 2024-03-30 thomas test_branch_created() {
389 444f59b9 2024-03-30 thomas local testroot=`test_init branch_created 1`
391 444f59b9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
393 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
394 444f59b9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
395 444f59b9 2024-03-30 thomas test_done "$testroot" 1
399 444f59b9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
401 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
402 444f59b9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
403 444f59b9 2024-03-30 thomas test_done "$testroot" 1
407 444f59b9 2024-03-30 thomas (cd $testroot/wt && got branch newbranch > /dev/null)
409 444f59b9 2024-03-30 thomas echo "change alpha on branch" > $testroot/wt/alpha
410 444f59b9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
411 444f59b9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
412 444f59b9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
414 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
415 444f59b9 2024-03-30 thomas > $testroot/stdout &
417 444f59b9 2024-03-30 thomas got send -b newbranch -q -r $testroot/repo-clone
419 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
420 444f59b9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
421 444f59b9 2024-03-30 thomas test_done "$testroot" "1"
425 444f59b9 2024-03-30 thomas wait %1 # wait for the http "server"
427 444f59b9 2024-03-30 thomas # in the future it should contain something like this too
429 444f59b9 2024-03-30 thomas # "type":"new-branch",
430 444f59b9 2024-03-30 thomas # "user":"${GOTD_DEVUSER}",
431 444f59b9 2024-03-30 thomas # "ref":"refs/heads/newbranch"
434 444f59b9 2024-03-30 thomas touch "$testroot/stdout.expected"
435 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
437 444f59b9 2024-03-30 thomas {"notifications":[
439 444f59b9 2024-03-30 thomas "type":"commit",
440 444f59b9 2024-03-30 thomas "short":false,
441 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
442 444f59b9 2024-03-30 thomas "id":"$commit_id",
443 444f59b9 2024-03-30 thomas "author":{
444 444f59b9 2024-03-30 thomas "full":"$GOT_AUTHOR",
445 444f59b9 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
446 444f59b9 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
447 444f59b9 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
449 444f59b9 2024-03-30 thomas "committer":{
450 444f59b9 2024-03-30 thomas "full":"$GOT_AUTHOR",
451 444f59b9 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
452 444f59b9 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
453 444f59b9 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
455 c50aaf5d 2024-04-25 thomas.ad "date":$author_time,
456 444f59b9 2024-03-30 thomas "short_message":"newbranch",
457 444f59b9 2024-03-30 thomas "message":"newbranch\n",
458 9e56e3e7 2024-03-30 thomas "diffstat":{
459 9e56e3e7 2024-03-30 thomas "files":[{
460 9e56e3e7 2024-03-30 thomas "action":"modified",
461 9e56e3e7 2024-03-30 thomas "file":"alpha",
462 9e56e3e7 2024-03-30 thomas "added":1,
463 9e56e3e7 2024-03-30 thomas "removed":1
465 9e56e3e7 2024-03-30 thomas "total":{
466 9e56e3e7 2024-03-30 thomas "added":1,
467 9e56e3e7 2024-03-30 thomas "removed":1
477 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
479 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
480 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
481 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
485 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
488 4808d170 2024-03-30 thomas test_branch_removed() {
489 4808d170 2024-03-30 thomas local testroot=`test_init branch_removed 1`
491 4808d170 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
493 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
494 4808d170 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
495 4808d170 2024-03-30 thomas test_done "$testroot" 1
499 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
500 4808d170 2024-03-30 thomas > $testroot/stdout &
502 4808d170 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
504 4808d170 2024-03-30 thomas got send -d newbranch -q -r $testroot/repo-clone
506 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
507 4808d170 2024-03-30 thomas echo "got send failed unexpectedly" >&2
508 4808d170 2024-03-30 thomas test_done "$testroot" "1"
512 4808d170 2024-03-30 thomas wait %1 # wait for the http "server"
514 4808d170 2024-03-30 thomas touch "$testroot/stdout.expected"
515 4808d170 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
517 4808d170 2024-03-30 thomas {"notifications":[{
518 4808d170 2024-03-30 thomas "type":"branch-deleted",
519 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
520 4808d170 2024-03-30 thomas "ref":"refs/heads/newbranch",
521 4808d170 2024-03-30 thomas "id":"$commit_id"
528 e0d15dee 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
530 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
531 e0d15dee 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
532 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
536 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
539 e0d15dee 2024-03-30 thomas test_tag_created() {
540 e0d15dee 2024-03-30 thomas local testroot=`test_init tag_created 1`
542 e0d15dee 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
544 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
545 e0d15dee 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
546 e0d15dee 2024-03-30 thomas test_done "$testroot" 1
550 e0d15dee 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
551 e0d15dee 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
552 e0d15dee 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
554 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
555 e0d15dee 2024-03-30 thomas >$testroot/stdout &
557 e0d15dee 2024-03-30 thomas got send -t 1.0 -q -r $testroot/repo-clone
559 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
560 e0d15dee 2024-03-30 thomas echo "got send failed unexpectedly" >&2
561 e0d15dee 2024-03-30 thomas test_done "$testroot" "1"
565 e0d15dee 2024-03-30 thomas wait %1 # wait for the http "server"
567 e0d15dee 2024-03-30 thomas touch "$testroot/stdout.expected"
568 e0d15dee 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
570 e0d15dee 2024-03-30 thomas {"notifications":[{
571 e0d15dee 2024-03-30 thomas "type":"tag",
572 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
573 e0d15dee 2024-03-30 thomas "tag":"refs/tags/1.0",
574 e0d15dee 2024-03-30 thomas "tagger":{
575 e0d15dee 2024-03-30 thomas "full":"$GOT_AUTHOR",
576 e0d15dee 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
577 e0d15dee 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
578 e0d15dee 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
580 c50aaf5d 2024-04-25 thomas.ad "date":$tagger_time,
581 e0d15dee 2024-03-30 thomas "object":{
582 e0d15dee 2024-03-30 thomas "type":"commit",
583 e0d15dee 2024-03-30 thomas "id":"$commit_id"
585 e0d15dee 2024-03-30 thomas "message":"new tag\n\n"
592 4808d170 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
594 4808d170 2024-03-30 thomas if [ $ret -ne 0 ]; then
595 4808d170 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
596 4808d170 2024-03-30 thomas test_done "$testroot" "$ret"
600 4808d170 2024-03-30 thomas test_done "$testroot" "$ret"
603 407d84f1 2024-03-30 thomas test_tag_changed() {
604 407d84f1 2024-03-30 thomas local testroot=`test_init tag_changed 1`
606 407d84f1 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
608 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
609 407d84f1 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
610 407d84f1 2024-03-30 thomas test_done "$testroot" 1
614 407d84f1 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
616 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
617 407d84f1 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
618 407d84f1 2024-03-30 thomas test_done "$testroot" 1
622 407d84f1 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
623 407d84f1 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
624 407d84f1 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
626 407d84f1 2024-03-30 thomas got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
627 407d84f1 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
628 407d84f1 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
630 f0b0cfba 2024-04-25 thomas.ad timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
631 407d84f1 2024-03-30 thomas > $testroot/stdout &
633 407d84f1 2024-03-30 thomas got send -f -t 1.0 -q -r $testroot/repo-clone
635 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
636 407d84f1 2024-03-30 thomas echo "got send failed unexpectedly" >&2
637 407d84f1 2024-03-30 thomas test_done "$testroot" "1"
641 407d84f1 2024-03-30 thomas wait %1 # wait for the http "server"
643 407d84f1 2024-03-30 thomas # XXX: at the moment this is exactly the same as the "new tag"
644 407d84f1 2024-03-30 thomas # notification
646 407d84f1 2024-03-30 thomas touch "$testroot/stdout.expected"
647 407d84f1 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
649 407d84f1 2024-03-30 thomas {"notifications":[{
650 407d84f1 2024-03-30 thomas "type":"tag",
651 23022bc0 2024-04-25 thomas.ad "repo":"test-repo",
652 407d84f1 2024-03-30 thomas "tag":"refs/tags/1.0",
653 407d84f1 2024-03-30 thomas "tagger":{
654 407d84f1 2024-03-30 thomas "full":"$GOT_AUTHOR",
655 407d84f1 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
656 407d84f1 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
657 407d84f1 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
659 c50aaf5d 2024-04-25 thomas.ad "date":$tagger_time,
660 407d84f1 2024-03-30 thomas "object":{
661 407d84f1 2024-03-30 thomas "type":"commit",
662 407d84f1 2024-03-30 thomas "id":"$commit_id"
664 407d84f1 2024-03-30 thomas "message":"new tag\n\n"
671 407d84f1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
673 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
674 407d84f1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
675 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
679 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
682 94a3f4e9 2024-03-30 thomas test_parseargs "$@"
683 94a3f4e9 2024-03-30 thomas run_test test_file_changed
684 fcfdd0a1 2024-03-30 thomas run_test test_bad_utf8
685 94a3f4e9 2024-03-30 thomas run_test test_many_commits_not_summarized
686 94a3f4e9 2024-03-30 thomas run_test test_many_commits_summarized
687 444f59b9 2024-03-30 thomas run_test test_branch_created
688 4808d170 2024-03-30 thomas run_test test_branch_removed
689 e0d15dee 2024-03-30 thomas run_test test_tag_created
690 407d84f1 2024-03-30 thomas run_test test_tag_changed