1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
#!/usr/bin/env bash
set -e
source test/setup
use Test::More
clone-foo-and-bar
(
mkdir -p "$OWNER/empty"
git init "$OWNER/empty"
)
# Test that the repos look ok:
{
test-exists \
"$OWNER/foo/.git/" \
"$OWNER/foo/Foo" \
"!$OWNER/foo/bar/" \
"$OWNER/bar/.git/" \
"$OWNER/bar/Bar" \
"$OWNER/empty/.git/"
}
# Do the subrepo clone and test the output:
{
clone_output=$(
cd "$OWNER/foo"
git subrepo clone "$UPSTREAM/bar"
)
# Check output is correct:
is "$clone_output" \
"Subrepo '$UPSTREAM/bar' (master) cloned into 'bar'." \
'subrepo clone command output is correct'
is "$(
cd "$OWNER/foo"
git remote -v | grep subrepo/bar
)" \
"" \
'No remotes created'
clone_output_empty=$(
cd "$OWNER/empty"
catch git subrepo clone "$UPSTREAM/bar"
)
# Check output is correct:
is "$clone_output_empty" \
"git-subrepo: You can't clone into an empty repository" \
'subrepo empty clone command output is correct'
}
# Check that subrepo files look ok:
gitrepo=$OWNER/foo/bar/.gitrepo
{
test-exists \
"$OWNER/foo/bar/" \
"$OWNER/foo/bar/Bar" \
"$gitrepo" \
"!$OWNER/empty/bar/"
}
# Test foo/bar/.gitrepo file contents:
{
foo_clone_commit=$(cd "$OWNER/foo"; git rev-parse HEAD^)
bar_head_commit=$(cd "$OWNER/bar"; git rev-parse HEAD)
test-gitrepo-comment-block
test-gitrepo-field "remote" "$UPSTREAM/bar"
test-gitrepo-field "branch" "master"
test-gitrepo-field "commit" "$bar_head_commit"
test-gitrepo-field "parent" "$foo_clone_commit"
test-gitrepo-field "cmdver" "$(git subrepo --version)"
}
# Make sure status is clean:
{
git_status=$(
cd "$OWNER/foo"
git status -s
)
is "$git_status" \
"" \
'status is clean'
git_status_empty=$(
cd "$OWNER/empty"
git status -s
)
is "$git_status_empty" \
"" \
'status is clean'
}
done_testing
teardown
|