Blame


1 fdbea373 2023-07-10 thomas #!/bin/sh
2 fdbea373 2023-07-10 thomas #
3 fdbea373 2023-07-10 thomas # Copyright (c) 2023 Omar Polo <op@openbsd.org>
4 fdbea373 2023-07-10 thomas #
5 fdbea373 2023-07-10 thomas # Permission to use, copy, modify, and distribute this software for any
6 fdbea373 2023-07-10 thomas # purpose with or without fee is hereby granted, provided that the above
7 fdbea373 2023-07-10 thomas # copyright notice and this permission notice appear in all copies.
8 fdbea373 2023-07-10 thomas #
9 fdbea373 2023-07-10 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fdbea373 2023-07-10 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fdbea373 2023-07-10 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fdbea373 2023-07-10 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fdbea373 2023-07-10 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fdbea373 2023-07-10 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fdbea373 2023-07-10 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fdbea373 2023-07-10 thomas
17 fdbea373 2023-07-10 thomas . ./common.sh
18 fdbea373 2023-07-10 thomas
19 fdbea373 2023-07-10 thomas test_dump_bundle() {
20 fdbea373 2023-07-10 thomas local testroot=`test_init test_dump_bundle`
21 fdbea373 2023-07-10 thomas
22 fdbea373 2023-07-10 thomas # add a fake reference so that `got log' appears the same in
23 fdbea373 2023-07-10 thomas # the cloned repository
24 fdbea373 2023-07-10 thomas (cd "$testroot/repo" && got branch -n origin/master)
25 fdbea373 2023-07-10 thomas
26 fdbea373 2023-07-10 thomas (cd "$testroot/repo" && got log -p >$testroot/repo.log)
27 fdbea373 2023-07-10 thomas
28 fdbea373 2023-07-10 thomas (cd "$testroot/repo" && gotadmin dump -q master >$testroot/r.bundle)
29 fdbea373 2023-07-10 thomas if [ $? -ne 0 ]; then
30 fdbea373 2023-07-10 thomas echo "gotadmin dump failed unexpectedly" >&2
31 fdbea373 2023-07-10 thomas test_done "$testroot" 1
32 fdbea373 2023-07-10 thomas return 1
33 fdbea373 2023-07-10 thomas fi
34 fdbea373 2023-07-10 thomas
35 d1e03b8c 2023-10-08 thomas if ! git -C "$testroot" clone -b master -q r.bundle; then
36 fdbea373 2023-07-10 thomas echo "failed to git clone from the generated bundle" >&2
37 fdbea373 2023-07-10 thomas test_done "$testroot" 1
38 fdbea373 2023-07-10 thomas return 1
39 fdbea373 2023-07-10 thomas fi
40 fdbea373 2023-07-10 thomas
41 fdbea373 2023-07-10 thomas if ! (cd "$testroot/r" && got log -p >$testroot/r.log); then
42 fdbea373 2023-07-10 thomas echo "got log failed unexpectedly" >&2
43 fdbea373 2023-07-10 thomas test_done "$testroot" 1
44 fdbea373 2023-07-10 thomas return 1
45 fdbea373 2023-07-10 thomas fi
46 fdbea373 2023-07-10 thomas
47 fdbea373 2023-07-10 thomas if ! cmp -s "$testroot/repo.log" "$testroot/r.log"; then
48 fdbea373 2023-07-10 thomas echo "history differs after clone" >&2
49 fdbea373 2023-07-10 thomas diff -u "$testroot/repo.log" "$testroot/r.log"
50 fdbea373 2023-07-10 thomas test_done "$testroot" 1
51 fdbea373 2023-07-10 thomas return 1
52 fdbea373 2023-07-10 thomas fi
53 fdbea373 2023-07-10 thomas
54 d1e03b8c 2023-10-08 thomas git -C "$testroot/repo" checkout -q -b newbranch
55 fdbea373 2023-07-10 thomas
56 fdbea373 2023-07-10 thomas # commit some changes in the repo
57 fdbea373 2023-07-10 thomas for i in `seq 5`; do
58 fdbea373 2023-07-10 thomas echo "alpha edit #$i" > $testroot/repo/alpha
59 fdbea373 2023-07-10 thomas git_commit "$testroot/repo" -m "edit alpha"
60 fdbea373 2023-07-10 thomas done
61 fdbea373 2023-07-10 thomas
62 fdbea373 2023-07-10 thomas (cd "$testroot/repo" && \
63 fdbea373 2023-07-10 thomas gotadmin dump -q -x master newbranch >$testroot/r.bundle)
64 fdbea373 2023-07-10 thomas if [ $? -ne 0 ]; then
65 fdbea373 2023-07-10 thomas echo "gotadmin dump failed unexpectedly" >&2
66 fdbea373 2023-07-10 thomas test_done "$testroot" 1
67 fdbea373 2023-07-10 thomas return 1
68 fdbea373 2023-07-10 thomas fi
69 fdbea373 2023-07-10 thomas
70 d1e03b8c 2023-10-08 thomas git -C "$testroot/r" checkout -q -b newbranch && \
71 d1e03b8c 2023-10-08 thomas git -C "$testroot/r" pull -q "$testroot/r.bundle" newbranch
72 fdbea373 2023-07-10 thomas if [ $? -ne 0 ]; then
73 fdbea373 2023-07-10 thomas echo "git pull failed unexpectedly" >&2
74 fdbea373 2023-07-10 thomas test_done "$testroot" 1
75 fdbea373 2023-07-10 thomas return 1
76 fdbea373 2023-07-10 thomas fi
77 fdbea373 2023-07-10 thomas
78 fdbea373 2023-07-10 thomas (cd "$testroot/repo" && got log -p >$testroot/repo.log)
79 fdbea373 2023-07-10 thomas
80 fdbea373 2023-07-10 thomas if ! (cd "$testroot/r" && got log -p >$testroot/r.log); then
81 fdbea373 2023-07-10 thomas echo "got log failed unexpectedly" >&2
82 fdbea373 2023-07-10 thomas test_done "$testroot" 1
83 fdbea373 2023-07-10 thomas return 1
84 fdbea373 2023-07-10 thomas fi
85 fdbea373 2023-07-10 thomas
86 fdbea373 2023-07-10 thomas if ! cmp -s "$testroot/repo.log" "$testroot/r.log"; then
87 fdbea373 2023-07-10 thomas echo "history differs after pull" >&2
88 fdbea373 2023-07-10 thomas diff -u "$testroot/repo.log" "$testroot/r.log"
89 fdbea373 2023-07-10 thomas test_done "$testroot" 1
90 fdbea373 2023-07-10 thomas return 1
91 fdbea373 2023-07-10 thomas fi
92 fdbea373 2023-07-10 thomas
93 fdbea373 2023-07-10 thomas test_done "$testroot" 0
94 fdbea373 2023-07-10 thomas }
95 fdbea373 2023-07-10 thomas
96 fdbea373 2023-07-10 thomas test_parseargs "$@"
97 fdbea373 2023-07-10 thomas run_test test_dump_bundle