@@ -36,14 +36,34 @@ resolve_sha_to_tag() {
3636
3737 # Only process if it looks like a SHA (40 character hex string)
3838 if [[ ${# sha} -eq 40 && " $sha " =~ ^[a-f0-9]+$ ]]; then
39- # Try to find a tag that points to this commit SHA
39+ # Try to find a tag that points to this commit SHA (handles both lightweight and annotated tags)
4040 local tag_name
4141 # First try to find a semantic version tag (prefer v1.2.3 over v1)
42- tag_name=$( gh api repos/" $action_name " /git/refs/tags --paginate 2> /dev/null | jq -r --arg sha " $sha " ' .[] | select(.object.sha == $sha) | .ref | sub("refs/tags/"; "")' 2> /dev/null | grep -E ' ^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
42+ tag_name=$(
43+ {
44+ # Get lightweight tags
45+ gh api repos/" $action_name " /git/refs/tags --paginate 2> /dev/null | \
46+ jq -r --arg sha " $sha " ' .[] | select(.object.sha == $sha) | .ref | sub("refs/tags/"; "")' 2> /dev/null
47+
48+ # Get annotated tags (dereference to commit SHA)
49+ gh api repos/" $action_name " /tags --paginate 2> /dev/null | \
50+ jq -r --arg sha " $sha " ' .[] | select(.commit.sha == $sha) | .name' 2> /dev/null
51+ } | grep -E ' ^v[0-9]+\.[0-9]+\.[0-9]+' | head -1
52+ )
4353
4454 # If no semantic version found, fall back to any tag
4555 if [ -z " $tag_name " ]; then
46- tag_name=$( gh api repos/" $action_name " /git/refs/tags --paginate 2> /dev/null | jq -r --arg sha " $sha " ' .[] | select(.object.sha == $sha) | .ref | sub("refs/tags/"; "")' 2> /dev/null | head -1)
56+ tag_name=$(
57+ {
58+ # Get lightweight tags
59+ gh api repos/" $action_name " /git/refs/tags --paginate 2> /dev/null | \
60+ jq -r --arg sha " $sha " ' .[] | select(.object.sha == $sha) | .ref | sub("refs/tags/"; "")' 2> /dev/null
61+
62+ # Get annotated tags (dereference to commit SHA)
63+ gh api repos/" $action_name " /tags --paginate 2> /dev/null | \
64+ jq -r --arg sha " $sha " ' .[] | select(.commit.sha == $sha) | .name' 2> /dev/null
65+ } | head -1
66+ )
4767 fi
4868
4969 if [ -n " $tag_name " ] && [ " $tag_name " != " null" ]; then
@@ -93,4 +113,7 @@ if [ "$resolve_shas" == "true" ]; then
93113 results=$( echo -e " $temp_results " | sed ' /^$/d' )
94114fi
95115
116+ # Sort results alphabetically
117+ results=$( echo -e " $results " | sort)
118+
96119echo -e " $results "
0 commit comments