implement support for keywords as got <commit> arguments
[got-portable.git] / regress / cmdline / init.sh
blob22184fffc887851e4b8c369a306088ffc4bf4686
1 #!/bin/sh
3 # Copyright (c) 2022 Mark Jamsek <mark@jamsek.dev>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_init_basic() {
20 local testname=init_basic
21 local testroot=`mktemp -d \
22 "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
23 local headref=main
25 gotadmin init $testroot/repo
27 local git_head=`(cd $testroot/repo && git symbolic-ref HEAD)`
28 echo $git_head > $testroot/content
29 echo refs/heads/$headref > $testroot/content.expected
30 cmp -s $testroot/content.expected $testroot/content
31 ret=$?
32 if [ $ret -ne 0 ]; then
33 echo "fail"
34 diff -u $testroot/content.expected $testroot/content
36 test_done "$testroot" "$ret"
39 test_init_specified_head() {
40 local testname=init_specified_head
41 local testroot=`mktemp -d \
42 "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
43 local headref=trunk
45 gotadmin init -b $headref $testroot/repo
47 local git_head=`(cd $testroot/repo && git symbolic-ref HEAD)`
48 echo refs/heads/$headref > $testroot/content.expected
49 echo $git_head > $testroot/content
50 cmp -s $testroot/content.expected $testroot/content
51 ret=$?
52 if [ $ret -ne 0 ]; then
53 echo "fail"
54 diff -u $testroot/content.expected $testroot/content
56 test_done "$testroot" "$ret"
59 test_parseargs "$@"
60 run_test test_init_basic
61 run_test test_init_specified_head