commit 1ac1d978352cb39038cfb80296e30c739a72ac05 from: Mark Jamsek via: Thomas Adam date: Fri Jan 3 10:46:48 2025 UTC regress/tog: ref view coverage of tag references Test for the error case when selecting tags that point to non-commit objects. And test the valid case of selecting nested tags that resolve to commit objects. ok stsp@ commit - 13c67f87dfe5bbdaffe4614de19fd11dcbbafc17 commit + 1ac1d978352cb39038cfb80296e30c739a72ac05 blob - b6c1fc12ce3fdf5a04a5b37782be5523ea18f036 blob + 9ab0f1ee21ad588017f9903b260fe6c4c1dd934c --- regress/tog/ref.sh +++ regress/tog/ref.sh @@ -135,8 +135,106 @@ test_ref_id_date_keymaps() test_done "$testroot" "$ret" } +test_ref_nested_tag_to_commit() +{ + test_init ref_nested_tag_to_commit 142 5 + + local author_time=$(git_show_author_time $testroot/repo) + local date=$(date -u -r $author_time +"%a %b %e %X %Y UTC") + local ymd=$(date -u -r $author_time +"%F") + local id=$(git_show_head $testroot/repo) + + cd $testroot/repo + + git tag -a tagref -m "tag to commit" > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "git tag failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi + + git tag -a nestedtag -m "nested tag" tagref > /dev/null 2>&1 + ret=$? + if [ $ret -ne 0 ]; then + echo "git tag failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi + + cat <<-EOF >$TOG_TEST_SCRIPT + 2j # select nested tag ref + KEY_ENTER # open log view + 35+ # grow log view vsplit + SCREENDUMP + EOF + + cat <$testroot/view.expected +references [3/4] |commit $id [1/1] master, tags/tagref +HEAD -> refs/heads/master |$ymd flan_hacker [master, tags/tagref] adding the test tree +refs/heads/master | +refs/tags/nestedtag | +refs/tags/tagref | +EOF + + cd $testroot/repo && tog ref + cmp -s $testroot/view.expected $testroot/view + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/view.expected $testroot/view + test_done "$testroot" "$ret" + return 1 + fi + + test_done "$testroot" "$ret" +} + +test_ref_non_commit_tag() +{ + test_init ref_non_commit_tag 32 5 + + local blobid_alpha=$(get_blob_id $testroot/repo "" alpha) + + cd $testroot/repo + + git tag blobtag $blobid_alpha > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "git tag failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi + + cat <<-EOF >$TOG_TEST_SCRIPT + 2j # select tag to blob entry + KEY_ENTER + SCREENDUMP + EOF + + cat <<-EOF >$testroot/view.expected + references [3/3] + HEAD -> refs/heads/master + refs/heads/master + refs/tags/blobtag + :commit reference required + EOF + + cd $testroot/repo && tog ref + cmp -s $testroot/view.expected $testroot/view + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/view.expected $testroot/view + test_done "$testroot" "$ret" + return 1 + fi + + test_done "$testroot" "$ret" +} + test_parseargs "$@" run_test test_ref_basic run_test test_ref_id_keymap run_test test_ref_date_keymap run_test test_ref_id_date_keymaps +run_test test_ref_nested_tag_to_commit +run_test test_ref_non_commit_tag