@@ -59,17 +59,11 @@ check_tag() {
5959
6060 TAG=1ドル
6161
62- # If a tag is specified, ensure that tag is present and checked out.
63- if [[ $TAG != $( git describe --abbrev=10) ]]; then
64- red " tag $TAG not checked out"
65- exit 1
66- fi
67- 6862 # Verify that it is signed if it is a real tag. If the tag looks like the
6963 # output of "git describe" for an untagged commit, skip verification.
7064 # The pattern is: <tag_name>-<number_of_commits>-g<abbreviated_commit_hash>
7165 # Example: "v0.31.2-beta-122-g8c6b73c".
72- if [[ $TAG =~ -[0-9]+-g([0-9a-f]{10 })$ ]]; then
66+ if [[ $TAG =~ -[0-9]+-g([0-9a-f]{7,40 })$ ]]; then
7367 # This looks like a "git describe" output. Make sure the hash
7468 # described is a prefix of the current commit.
7569 DESCRIBED_HASH=${BASH_REMATCH[1]}
@@ -82,6 +76,25 @@ check_tag() {
8276 return
8377 fi
8478
79+ # Release tags must start with 'v' (for example v0.31.5-beta).
80+ if [[ $TAG != v* ]]; then
81+ red " tag $TAG must start with 'v'"
82+ exit 1
83+ fi
84+ 85+ # Ensure the tag exists in the repository.
86+ if ! git show-ref --verify --quiet " refs/tags/$TAG " ; then
87+ red " tag $TAG not found"
88+ exit 1
89+ fi
90+ 91+ # Ensure the current commit is tagged with the requested tag, even when
92+ # multiple tags point at HEAD.
93+ if ! git tag --points-at HEAD | grep -Fxq " $TAG " ; then
94+ red " tag $TAG not checked out on the current commit"
95+ exit 1
96+ fi
97+ 8598 if ! git verify-tag $TAG ; then
8699 red " tag $TAG not signed"
87100 exit 1
0 commit comments