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 94a3f4e9 2024-03-30 thomas test_file_changed() {
21 94a3f4e9 2024-03-30 thomas local testroot=`test_init file_changed 1`
23 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
25 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
26 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
27 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
31 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
33 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
34 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
35 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
39 94a3f4e9 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
40 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
41 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
42 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
44 94a3f4e9 2024-03-30 thomas timeout 5 ./http-server -p $GOTD_TEST_HTTP_PORT \
45 94a3f4e9 2024-03-30 thomas > $testroot/stdout &
47 94a3f4e9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
49 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
50 94a3f4e9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
51 94a3f4e9 2024-03-30 thomas test_done "$testroot" "1"
55 94a3f4e9 2024-03-30 thomas wait %1 # wait for the http "server"
57 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
59 0178cac9 2024-03-30 thomas touch "$testroot/stdout.expected"
60 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
62 0178cac9 2024-03-30 thomas {"notifications":[{
63 71b7e0f5 2024-03-30 thomas "type":"commit",
64 0178cac9 2024-03-30 thomas "short":false,
65 0178cac9 2024-03-30 thomas "id":"$commit_id",
66 9c485a11 2024-03-30 thomas "author":{
67 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
68 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
69 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
70 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
72 9c485a11 2024-03-30 thomas "committer":{
73 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
74 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
75 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
76 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
78 0178cac9 2024-03-30 thomas "date":"$d",
79 9c485a11 2024-03-30 thomas "short_message":"make changes",
80 0178cac9 2024-03-30 thomas "message":"make changes\n",
81 9e56e3e7 2024-03-30 thomas "diffstat":{
82 9e56e3e7 2024-03-30 thomas "files":[{
83 9e56e3e7 2024-03-30 thomas "action":"modified",
84 9e56e3e7 2024-03-30 thomas "file":"alpha",
85 9e56e3e7 2024-03-30 thomas "added":1,
86 9e56e3e7 2024-03-30 thomas "removed":1
89 9e56e3e7 2024-03-30 thomas "added":1,
90 9e56e3e7 2024-03-30 thomas "removed":1
99 fcfdd0a1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
101 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
102 fcfdd0a1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
103 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
107 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "$ret"
110 fcfdd0a1 2024-03-30 thomas test_bad_utf8() {
111 fcfdd0a1 2024-03-30 thomas local testroot=`test_init bad_utf8 1`
113 fcfdd0a1 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
115 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
116 fcfdd0a1 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
117 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
121 fcfdd0a1 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
123 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
124 fcfdd0a1 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
125 fcfdd0a1 2024-03-30 thomas test_done "$testroot" 1
128 5571f6ee 2024-03-30 thomas # invalid utf8 sequence
129 fcfdd0a1 2024-03-30 thomas commit_msg="make$(printf '\xED\xA0\x80')changes"
131 fcfdd0a1 2024-03-30 thomas echo "changed" > $testroot/wt/alpha
132 fcfdd0a1 2024-03-30 thomas (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
133 fcfdd0a1 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
134 fcfdd0a1 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
136 fcfdd0a1 2024-03-30 thomas timeout 5 ./http-server -p $GOTD_TEST_HTTP_PORT \
137 fcfdd0a1 2024-03-30 thomas > $testroot/stdout &
139 fcfdd0a1 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
141 fcfdd0a1 2024-03-30 thomas if [ $ret -ne 0 ]; then
142 fcfdd0a1 2024-03-30 thomas echo "got send failed unexpectedly" >&2
143 fcfdd0a1 2024-03-30 thomas test_done "$testroot" "1"
147 fcfdd0a1 2024-03-30 thomas wait %1 # wait for the http "server"
149 fcfdd0a1 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
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 fcfdd0a1 2024-03-30 thomas "id":"$commit_id",
158 9c485a11 2024-03-30 thomas "author":{
159 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
160 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
161 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
162 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
164 9c485a11 2024-03-30 thomas "committer":{
165 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
166 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
167 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
168 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
170 fcfdd0a1 2024-03-30 thomas "date":"$d",
171 9c485a11 2024-03-30 thomas "short_message":"make\uFFFD\uFFFDchanges",
172 fcfdd0a1 2024-03-30 thomas "message":"make\uFFFD\uFFFDchanges\n",
173 9e56e3e7 2024-03-30 thomas "diffstat":{
174 9e56e3e7 2024-03-30 thomas "files":[{
175 9e56e3e7 2024-03-30 thomas "action":"modified",
176 9e56e3e7 2024-03-30 thomas "file":"alpha",
177 9e56e3e7 2024-03-30 thomas "added":1,
178 9e56e3e7 2024-03-30 thomas "removed":1
180 9e56e3e7 2024-03-30 thomas "total":{
181 9e56e3e7 2024-03-30 thomas "added":1,
182 9e56e3e7 2024-03-30 thomas "removed":1
191 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
193 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
194 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
195 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
199 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
202 94a3f4e9 2024-03-30 thomas test_many_commits_not_summarized() {
203 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_not_summarized 1`
205 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
207 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
208 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
209 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
213 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
215 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
216 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
217 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
221 94a3f4e9 2024-03-30 thomas for i in `seq 1 24`; do
222 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
223 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
224 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
225 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
226 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
227 94a3f4e9 2024-03-30 thomas set -- "$@" "$commit_id $d"
230 94a3f4e9 2024-03-30 thomas timeout 5 ./http-server -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 94a3f4e9 2024-03-30 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 0178cac9 2024-03-30 thomas "id":"$commit_id",
258 9c485a11 2024-03-30 thomas "author":{
259 9c485a11 2024-03-30 thomas "full":"$GOT_AUTHOR",
260 9c485a11 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
261 9c485a11 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
262 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
264 9c485a11 2024-03-30 thomas "committer":{
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 0178cac9 2024-03-30 thomas "date":"$commit_time",
271 9c485a11 2024-03-30 thomas "short_message":"make changes",
272 0178cac9 2024-03-30 thomas "message":"make changes\n",
273 9e56e3e7 2024-03-30 thomas "diffstat":{
274 9e56e3e7 2024-03-30 thomas "files":[{
275 9e56e3e7 2024-03-30 thomas "action":"modified",
276 9e56e3e7 2024-03-30 thomas "file":"alpha",
277 9e56e3e7 2024-03-30 thomas "added":1,
278 9e56e3e7 2024-03-30 thomas "removed":1
280 9e56e3e7 2024-03-30 thomas "total":{
281 9e56e3e7 2024-03-30 thomas "added":1,
282 9e56e3e7 2024-03-30 thomas "removed":1
287 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
288 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
289 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
294 94a3f4e9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
296 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
297 94a3f4e9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
298 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
302 94a3f4e9 2024-03-30 thomas test_done "$testroot" "$ret"
305 94a3f4e9 2024-03-30 thomas test_many_commits_summarized() {
306 94a3f4e9 2024-03-30 thomas local testroot=`test_init many_commits_summarized 1`
308 94a3f4e9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
310 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
311 94a3f4e9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
312 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
316 94a3f4e9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
318 94a3f4e9 2024-03-30 thomas if [ $ret -ne 0 ]; then
319 94a3f4e9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
320 94a3f4e9 2024-03-30 thomas test_done "$testroot" 1
324 94a3f4e9 2024-03-30 thomas for i in `seq 1 51`; do
325 94a3f4e9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
326 94a3f4e9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
327 94a3f4e9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
328 94a3f4e9 2024-03-30 thomas local short_commit_id=`trim_obj_id 33 $commit_id`
329 94a3f4e9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
330 94a3f4e9 2024-03-30 thomas d=`date -u -r $author_time +"%G-%m-%d"`
331 94a3f4e9 2024-03-30 thomas set -- "$@" "$short_commit_id $d"
334 94a3f4e9 2024-03-30 thomas timeout 5 ./http-server -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 94a3f4e9 2024-03-30 thomas commit_time=$(echo $s | sed -e "s/^$commit_id //g")
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 0178cac9 2024-03-30 thomas "id":"$commit_id",
362 9c485a11 2024-03-30 thomas "committer":{
363 9c485a11 2024-03-30 thomas "user":"$GOT_AUTHOR_8"
365 0178cac9 2024-03-30 thomas "date":"$commit_time",
366 9c485a11 2024-03-30 thomas "short_message":"make changes"
369 94a3f4e9 2024-03-30 thomas done >> $testroot/stdout.expected
370 94a3f4e9 2024-03-30 thomas echo "]}" >> $testroot/stdout.expected
371 444f59b9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
376 444f59b9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
378 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
379 444f59b9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
380 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
384 444f59b9 2024-03-30 thomas test_done "$testroot" "$ret"
387 444f59b9 2024-03-30 thomas test_branch_created() {
388 444f59b9 2024-03-30 thomas local testroot=`test_init branch_created 1`
390 444f59b9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
392 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
393 444f59b9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
394 444f59b9 2024-03-30 thomas test_done "$testroot" 1
398 444f59b9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
400 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
401 444f59b9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
402 444f59b9 2024-03-30 thomas test_done "$testroot" 1
406 444f59b9 2024-03-30 thomas (cd $testroot/wt && got branch newbranch > /dev/null)
408 444f59b9 2024-03-30 thomas echo "change alpha on branch" > $testroot/wt/alpha
409 444f59b9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
410 444f59b9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
411 444f59b9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
413 444f59b9 2024-03-30 thomas timeout 5 ./http-server -p "$GOTD_TEST_HTTP_PORT" \
414 444f59b9 2024-03-30 thomas > $testroot/stdout &
416 444f59b9 2024-03-30 thomas got send -b newbranch -q -r $testroot/repo-clone
418 444f59b9 2024-03-30 thomas if [ $ret -ne 0 ]; then
419 444f59b9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
420 444f59b9 2024-03-30 thomas test_done "$testroot" "1"
424 444f59b9 2024-03-30 thomas wait %1 # wait for the http "server"
426 444f59b9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
428 444f59b9 2024-03-30 thomas # in the future it should contain something like this too
430 444f59b9 2024-03-30 thomas # "type":"new-branch",
431 444f59b9 2024-03-30 thomas # "user":"${GOTD_DEVUSER}",
432 444f59b9 2024-03-30 thomas # "ref":"refs/heads/newbranch"
435 444f59b9 2024-03-30 thomas touch "$testroot/stdout.expected"
436 0178cac9 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
438 444f59b9 2024-03-30 thomas {"notifications":[
440 444f59b9 2024-03-30 thomas "type":"commit",
441 444f59b9 2024-03-30 thomas "short":false,
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 444f59b9 2024-03-30 thomas "date":"$d",
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 4808d170 2024-03-30 thomas timeout 5 ./http-server -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 4808d170 2024-03-30 thomas "ref":"refs/heads/newbranch",
520 4808d170 2024-03-30 thomas "id":"$commit_id"
527 e0d15dee 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
529 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
530 e0d15dee 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
531 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
535 e0d15dee 2024-03-30 thomas test_done "$testroot" "$ret"
538 e0d15dee 2024-03-30 thomas test_tag_created() {
539 e0d15dee 2024-03-30 thomas local testroot=`test_init tag_created 1`
541 e0d15dee 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
543 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
544 e0d15dee 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
545 e0d15dee 2024-03-30 thomas test_done "$testroot" 1
549 e0d15dee 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
550 e0d15dee 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
551 e0d15dee 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
553 e0d15dee 2024-03-30 thomas timeout 5 ./http-server -p "$GOTD_TEST_HTTP_PORT" \
554 e0d15dee 2024-03-30 thomas >$testroot/stdout &
556 e0d15dee 2024-03-30 thomas got send -t 1.0 -q -r $testroot/repo-clone
558 e0d15dee 2024-03-30 thomas if [ $ret -ne 0 ]; then
559 e0d15dee 2024-03-30 thomas echo "got send failed unexpectedly" >&2
560 e0d15dee 2024-03-30 thomas test_done "$testroot" "1"
564 e0d15dee 2024-03-30 thomas wait %1 # wait for the http "server"
566 e0d15dee 2024-03-30 thomas d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
568 e0d15dee 2024-03-30 thomas touch "$testroot/stdout.expected"
569 e0d15dee 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
571 e0d15dee 2024-03-30 thomas {"notifications":[{
572 e0d15dee 2024-03-30 thomas "type":"tag",
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 e0d15dee 2024-03-30 thomas "date":"$d",
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 407d84f1 2024-03-30 thomas timeout 5 ./http-server -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 d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
645 407d84f1 2024-03-30 thomas # XXX: at the moment this is exactly the same as the "new tag"
646 407d84f1 2024-03-30 thomas # notification
648 407d84f1 2024-03-30 thomas touch "$testroot/stdout.expected"
649 407d84f1 2024-03-30 thomas ed -s "$testroot/stdout.expected" <<-EOF
651 407d84f1 2024-03-30 thomas {"notifications":[{
652 407d84f1 2024-03-30 thomas "type":"tag",
653 407d84f1 2024-03-30 thomas "tag":"refs/tags/1.0",
654 407d84f1 2024-03-30 thomas "tagger":{
655 407d84f1 2024-03-30 thomas "full":"$GOT_AUTHOR",
656 407d84f1 2024-03-30 thomas "name":"$GIT_AUTHOR_NAME",
657 407d84f1 2024-03-30 thomas "mail":"$GIT_AUTHOR_EMAIL",
658 407d84f1 2024-03-30 thomas "user":"$GOT_AUTHOR_11"
660 407d84f1 2024-03-30 thomas "date":"$d",
661 407d84f1 2024-03-30 thomas "object":{
662 407d84f1 2024-03-30 thomas "type":"commit",
663 407d84f1 2024-03-30 thomas "id":"$commit_id"
665 407d84f1 2024-03-30 thomas "message":"new tag\n\n"
672 407d84f1 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout
674 407d84f1 2024-03-30 thomas if [ $ret -ne 0 ]; then
675 407d84f1 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout
676 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
680 407d84f1 2024-03-30 thomas test_done "$testroot" "$ret"
683 94a3f4e9 2024-03-30 thomas test_parseargs "$@"
684 94a3f4e9 2024-03-30 thomas run_test test_file_changed
685 fcfdd0a1 2024-03-30 thomas run_test test_bad_utf8
686 94a3f4e9 2024-03-30 thomas run_test test_many_commits_not_summarized
687 94a3f4e9 2024-03-30 thomas run_test test_many_commits_summarized
688 444f59b9 2024-03-30 thomas run_test test_branch_created
689 4808d170 2024-03-30 thomas run_test test_branch_removed
690 e0d15dee 2024-03-30 thomas run_test test_tag_created
691 407d84f1 2024-03-30 thomas run_test test_tag_changed