From d1b97bae6c756f4460adb073dd6e53c8233fa5b8 Mon Sep 17 00:00:00 2001 From: Michal Lula Date: Fri, 11 Oct 2019 17:44:06 +0200 Subject: [PATCH] :sparkles: support of depth flag --- test_e2e.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/test_e2e.sh b/test_e2e.sh index d0f5d59..a79f5c7 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -688,7 +688,7 @@ git -C "$NESTED_SUBMODULE" add nested-submodule git -C "$NESTED_SUBMODULE" commit -aqm "init nested-submodule file" # 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_SYNC \ --logtostderr \ @@ -724,7 +724,7 @@ assert_file_exists "$ROOT"/link/file assert_file_exists "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule assert_file_eq "$ROOT"/link/$SUBMODULE_REPO_NAME/submodule "submodule" # 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 "$REPO" submodule update --recursive --remote > /dev/null 2>&1 git -C "$REPO" commit -qam "$TESTCASE 4" @@ -762,5 +762,82 @@ remove_sync_container wait 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" rm -rf "$DIR"