✨ support of depth flag
This commit is contained in:
parent
94818756af
commit
d1b97bae6c
81
test_e2e.sh
81
test_e2e.sh
|
|
@ -688,7 +688,7 @@ git -C "$NESTED_SUBMODULE" add nested-submodule
|
||||||
git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file"
|
git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file"
|
||||||
|
|
||||||
# Add submodule
|
# Add submodule
|
||||||
git -C "$REPO" submodule add -q $SUBMODULE
|
git -C "$REPO" submodule add -q file://$SUBMODULE
|
||||||
git -C "$REPO" commit -aqm "add submodule"
|
git -C "$REPO" commit -aqm "add submodule"
|
||||||
GIT_SYNC \
|
GIT_SYNC \
|
||||||
--logtostderr \
|
--logtostderr \
|
||||||
|
|
@ -724,7 +724,7 @@ assert_file_exists "$ROOT"/link/file
|
||||||
assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule
|
assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule
|
||||||
assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "submodule"
|
assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "submodule"
|
||||||
# Add nested submodule to submodule repo
|
# Add nested submodule to submodule repo
|
||||||
git -C "$SUBMODULE" submodule add -q $NESTED_SUBMODULE
|
git -C "$SUBMODULE" submodule add -q file://$NESTED_SUBMODULE
|
||||||
git -C "$SUBMODULE" commit -aqm "add nested submodule"
|
git -C "$SUBMODULE" commit -aqm "add nested submodule"
|
||||||
git -C "$REPO" submodule update --recursive --remote > /dev/null 2>&1
|
git -C "$REPO" submodule update --recursive --remote > /dev/null 2>&1
|
||||||
git -C "$REPO" commit -qam "$TESTCASE 4"
|
git -C "$REPO" commit -qam "$TESTCASE 4"
|
||||||
|
|
@ -762,5 +762,82 @@ remove_sync_container
|
||||||
wait
|
wait
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Test submodules depth syncing
|
||||||
|
testcase "submodule-sync-depth"
|
||||||
|
|
||||||
|
# Init submodule repo
|
||||||
|
SUBMODULE_REPO_NAME="sub"
|
||||||
|
SUBMODULE="$DIR/$SUBMODULE_REPO_NAME"
|
||||||
|
mkdir "$SUBMODULE"
|
||||||
|
|
||||||
|
git -C "$SUBMODULE" init > /dev/null
|
||||||
|
|
||||||
|
# First sync
|
||||||
|
expected_depth="1"
|
||||||
|
echo "$TESTCASE 1" > "$SUBMODULE"/submodule
|
||||||
|
git -C "$SUBMODULE" add submodule
|
||||||
|
git -C "$SUBMODULE" commit -aqm "submodule $TESTCASE 1"
|
||||||
|
git -C "$REPO" submodule add -q file://$SUBMODULE
|
||||||
|
git -C "$REPO" config -f "$REPO"/.gitmodules submodule.$SUBMODULE_REPO_NAME.shallow true
|
||||||
|
git -C "$REPO" commit -qam "$TESTCASE 1"
|
||||||
|
GIT_SYNC \
|
||||||
|
--logtostderr \
|
||||||
|
--v=5 \
|
||||||
|
--wait=0.1 \
|
||||||
|
--repo="$REPO" \
|
||||||
|
--depth="$expected_depth" \
|
||||||
|
--root="$ROOT" \
|
||||||
|
--dest="link" > "$DIR"/log."$TESTCASE" 2>&1 &
|
||||||
|
sleep 3
|
||||||
|
assert_link_exists "$ROOT"/link
|
||||||
|
assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule
|
||||||
|
assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "$TESTCASE 1"
|
||||||
|
depth=$(GIT_DIR="$ROOT"/link/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $depth ]; then
|
||||||
|
fail "initial depth mismatch expected=$expected_depth actual=$depth"
|
||||||
|
fi
|
||||||
|
submodule_depth=$(GIT_DIR="$ROOT"/link/$SUBMODULE_REPO_NAME/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $submodule_depth ]; then
|
||||||
|
fail "initial submodule depth mismatch expected=$expected_depth actual=$submodule_depth"
|
||||||
|
fi
|
||||||
|
# Move forward
|
||||||
|
echo "$TESTCASE 2" > "$SUBMODULE"/submodule
|
||||||
|
git -C "$SUBMODULE" commit -aqm "submodule $TESTCASE 2"
|
||||||
|
git -C "$REPO" submodule update --recursive --remote > /dev/null 2>&1
|
||||||
|
git -C "$REPO" commit -qam "$TESTCASE 2"
|
||||||
|
sleep 3
|
||||||
|
assert_link_exists "$ROOT"/link
|
||||||
|
assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule
|
||||||
|
assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "$TESTCASE 2"
|
||||||
|
depth=$(GIT_DIR="$ROOT"/link/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $depth ]; then
|
||||||
|
fail "forward depth mismatch expected=$expected_depth actual=$depth"
|
||||||
|
fi
|
||||||
|
submodule_depth=$(GIT_DIR="$ROOT"/link/$SUBMODULE_REPO_NAME/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $submodule_depth ]; then
|
||||||
|
fail "forward submodule depth mismatch expected=$expected_depth actual=$submodule_depth"
|
||||||
|
fi
|
||||||
|
# Move backward
|
||||||
|
git -C "$SUBMODULE" reset -q --hard HEAD^
|
||||||
|
git -C "$REPO" submodule update --recursive --remote > /dev/null 2>&1
|
||||||
|
git -C "$REPO" commit -qam "$TESTCASE 3"
|
||||||
|
sleep 3
|
||||||
|
assert_link_exists "$ROOT"/link
|
||||||
|
assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule
|
||||||
|
assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "$TESTCASE 1"
|
||||||
|
depth=$(GIT_DIR="$ROOT"/link/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $depth ]; then
|
||||||
|
fail "initial depth mismatch expected=$expected_depth actual=$depth"
|
||||||
|
fi
|
||||||
|
submodule_depth=$(GIT_DIR="$ROOT"/link/$SUBMODULE_REPO_NAME/.git git log | grep commit | wc -l)
|
||||||
|
if [ $expected_depth != $submodule_depth ]; then
|
||||||
|
fail "initial submodule depth mismatch expected=$expected_depth actual=$submodule_depth"
|
||||||
|
fi
|
||||||
|
# Wrap up
|
||||||
|
rm -rf $SUBMODULE
|
||||||
|
remove_sync_container
|
||||||
|
wait
|
||||||
|
pass
|
||||||
|
|
||||||
echo "cleaning up $DIR"
|
echo "cleaning up $DIR"
|
||||||
rm -rf "$DIR"
|
rm -rf "$DIR"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue