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
|
#!/usr/bin/env bash
set -e
source test/setup
use Test::More
clone-foo-and-bar
(
cd "$OWNER/foo"
git subrepo --quiet clone "$UPSTREAM/bar"
)
test-exists \
"$OWNER/foo/bar/bard/"
# Test that reclone is not done if not needed.
export XYZ=1
is "$(
cd "$OWNER/foo"
git subrepo --force clone "$UPSTREAM/bar"
)" \
"Subrepo 'bar' is up to date." \
"No reclone if same commit"
# Test that reclone of a different ref works.
(
cd "$OWNER/foo"
git subrepo --quiet clone --force "$UPSTREAM/bar" --branch=refs/tags/A
)
is "$(git -C "$OWNER"/foo subrepo config bar branch)" \
"Subrepo 'bar' option 'branch' has value 'refs/tags/A'."
test-exists \
"!$OWNER/foo/bar/bard/"
# Test that reclone back to (implicit) master works.
(
cd "$OWNER/foo"
git subrepo --quiet clone -f "$UPSTREAM/bar"
)
is "$(git -C "$OWNER"/foo subrepo config bar branch)" \
"Subrepo 'bar' option 'branch' has value 'master'."
test-exists \
"$OWNER/foo/bar/bard/"
done_testing
teardown
|