commit 5760205b5f9b7d77dda76f98561d2a39e4eac7a9 from: Omar Polo date: Sat Jan 28 12:07:37 2023 UTC extend test_delete_branch - try to delete using git - try to delete multiple branches in one go - verify the ref-list reported by the server before and after the deletion suggested / ok stsp commit - 9a8e357c727600cb61ac6ec4c83259fa6d9a3081 commit + 5760205b5f9b7d77dda76f98561d2a39e4eac7a9 blob - b48e2b54f360c89a3ce5d4c9e38d4dd5a7a3532f blob + d75e82812ee4b8e5c04144e1f6f981703b541699 --- regress/gotd/repo_write.sh +++ regress/gotd/repo_write.sh @@ -295,7 +295,7 @@ test_send_new_empty_branch() { test_delete_branch() { local testroot=`test_init delete_branch 1` - got clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone + got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then echo "got clone failed unexpectedly" >&2 @@ -327,6 +327,13 @@ test_delete_branch() { test_done "$testroot" 1 return 1 fi + + local foo_id=`git_show_branch_head "$testroot/repo-clone" foo` + local main_id=`git_show_branch_head "$testroot/repo-clone" main` + local nb_id=`git_show_branch_head "$testroot/repo-clone" newbranch` + local nb2_id=`git_show_branch_head "$testroot/repo-clone" newbranch2` + local tag_id=`got ref -r "$testroot/repo-clone" -l refs/tags/1.0 | \ + awk '{print $2}'` if ! got send -q -r $testroot/repo-clone -b foo; then echo "got send failed unexpectedly" >&2 @@ -334,17 +341,59 @@ test_delete_branch() { return 1 fi - got send -r $testroot/repo-clone -d foo >$testroot/stdout + got fetch -q -r $testroot/repo-clone -l >$testroot/refs + cat <$testroot/refs.expected +HEAD: refs/heads/main +HEAD: $main_id +refs/heads/foo: $foo_id +refs/heads/main: $main_id +refs/heads/newbranch: $nb_id +refs/heads/newbranch2: $nb2_id +refs/tags/1.0: $tag_id +EOF + if ! cmp -s $testroot/refs.expected $testroot/refs; then + diff -u $testroot/refs.expected $testroot/refs + test_done "$testroot" 1 + return 1 + fi + + (cd $testroot/repo-clone && git push -d origin foo) >/dev/null 2>&1 ret=$? if [ $ret -ne 0 ]; then - echo "got send -d failed unexpectedly" >&2 + echo "git push -d failed unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + + got fetch -q -r $testroot/repo-clone -l >$testroot/refs + cat <$testroot/refs.expected +HEAD: refs/heads/main +HEAD: $main_id +refs/heads/main: $main_id +refs/heads/newbranch: $nb_id +refs/heads/newbranch2: $nb2_id +refs/tags/1.0: $tag_id +EOF + if ! cmp -s $testroot/refs.expected $testroot/refs; then + diff -u $testroot/refs.expected $testroot/refs test_done "$testroot" 1 return 1 fi + # try to delete multiple branches in one go + got send -r $testroot/repo-clone -d newbranch -d newbranch2 \ + >$testroot/stdout + ret=$? + if [ $ret -ne 0 ]; then + echo "got send with multiple -d failed unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + cat <$testroot/stdout.expected Connecting to "origin" ${GOTD_TEST_REPO_URL} -Server has deleted refs/heads/foo +Server has deleted refs/heads/newbranch2 +Server has deleted refs/heads/newbranch EOF if ! cmp -s $testroot/stdout.expected $testroot/stdout; then diff -u $testroot/stdout.expected $testroot/stdout @@ -352,6 +401,19 @@ EOF return 1 fi + got fetch -q -r $testroot/repo-clone -l >$testroot/refs + cat <$testroot/refs.expected +HEAD: refs/heads/main +HEAD: $main_id +refs/heads/main: $main_id +refs/tags/1.0: $tag_id +EOF + if ! cmp -s $testroot/refs.expected $testroot/refs; then + diff -u $testroot/refs.expected $testroot/refs + test_done "$testroot" 1 + return 1 + fi + # now try again but while also updating another branch # other than deleting `foo'. @@ -359,6 +421,7 @@ EOF echo 'more alpha' > alpha && \ got commit -m 'edit alpha on main' && \ got send -q -b foo) >/dev/null + main_id=`git_show_branch_head "$testroot/repo-clone" main` got send -r $testroot/repo-clone -d foo -b main | \ grep '^Server has' >$testroot/stdout @@ -379,6 +442,19 @@ EOF return 1 fi + got fetch -q -r $testroot/repo-clone -l >$testroot/refs + cat <$testroot/refs.expected +HEAD: refs/heads/main +HEAD: $main_id +refs/heads/main: $main_id +refs/tags/1.0: $tag_id +EOF + if ! cmp -s $testroot/refs.expected $testroot/refs; then + diff -u $testroot/refs.expected $testroot/refs + test_done "$testroot" 1 + return 1 + fi + test_done "$testroot" 0 }