@@ -5,7 +5,9 @@ cr_major_pattern=":warning:|$(printf "\xe2\x9a\xa0")"
5
5
cr_minor_pattern=" :sparkles:|$( printf " \xe2\x9c\xa8" ) "
6
6
cr_patch_pattern=" :bug:|$( printf " \xf0\x9f\x90\x9b" ) "
7
7
cr_docs_pattern=" :book:|$( printf " \xf0\x9f\x93\x96" ) "
8
+ cr_no_release_note_pattern=" :ghost:|$( printf " \xf0\x9f\x91\xbb" ) "
8
9
cr_other_pattern=" :running:|$( printf " \xf0\x9f\x8f\x83" ) "
10
+ cr_all_pattern=" ${cr_major_pattern} |${cr_minor_pattern} |${cr_patch_pattern} |${cr_docs_pattern} |${cr_other_pattern} "
9
11
10
12
# cr::symbol-type-raw turns :xyz: and the corresponding emoji
11
13
# into one of "major", "minor", "patch", "docs", "other", or
@@ -24,6 +26,9 @@ cr::symbol-type-raw() {
24
26
@ (${cr_docs_pattern} )? (' !' ))
25
27
echo " docs"
26
28
;;
29
+ @ (${cr_no_release_note_pattern} )? (' !' ))
30
+ echo " no_release_note"
31
+ ;;
27
32
@ (${cr_other_pattern} )? (' !' ))
28
33
echo " other"
29
34
;;
@@ -66,6 +71,52 @@ git::ensure-release-branch() {
66
71
fi
67
72
}
68
73
74
+ # git::export-version-from-branch outputs the current version
75
+ # for the given branch (as the argument) as exported variables
76
+ # (${maj,min,patch} _ver, last_tag).
77
+ git::export-version-from-branch() {
78
+ local target_branch=${1?must specify a branch}
79
+ local current_branch=$(git branch --show-current -q)
80
+
81
+ local expected_maj_ver
82
+ local expected_min_ver
83
+ if [[ ${target_branch} =~ release- 0 .([[: digit: ]]+ ) ]]; then
84
+ expected_maj_ver=0
85
+ expected_min_ver=${BASH_REMATCH[1]}
86
+ elif [[ ${target_branch} =~ release- ([[: digit: ]]+ ) ]]; then
87
+ expected_maj_ver=${BASH_REMATCH[1]}
88
+ else
89
+ echo "branch ${target_branch} does not appear to be for a release -- it should be release- X or release- 0 .Y" >& 2
90
+ exit 1
91
+ fi
92
+
93
+ local tag_pattern='v([[:digit:]]+).([[:digit:]]+).([[:digit:]]+)'
94
+
95
+ git checkout -q ${target_branch}
96
+
97
+ # make sure we've got a tag that matches *some* release
98
+ last_tag=$(git describe --tags --abbrev=0 ) # try to fetch just the "current" tag name
99
+ if [[ ! ${last_tag} =~ ${tag_pattern} ]]; then
100
+ # it's probably for a previous version
101
+ echo "tag ${last_tag} does not appear to be for a release -- it should be vX.Y.Z" >& 2
102
+ git checkout -q ${current_branch}
103
+ exit 1
104
+ fi
105
+
106
+ export min_ver=${BASH_REMATCH[2]}
107
+ export patch_ver=${BASH_REMATCH[3]}
108
+ export maj_ver=${BASH_REMATCH[1]}
109
+ export last_tag=${last_tag}
110
+
111
+ if ${2:- 1} && ([[ ${maj_ver} != ${expected_maj_ver} ]] || [[ ${maj_ver} == 0 && ${min_ver} != ${expected_min_ver} ]]); then
112
+ echo "tag ${last_tag} does not appear to be for a the right release (${target_branch} )" >& 2
113
+ git checkout ${current_branch}
114
+ exit 1
115
+ fi
116
+
117
+ git checkout -q ${current_branch}
118
+ }
119
+
69
120
# git::export-current-version outputs the current version
70
121
# as exported variables (${maj,min,patch} _ver, last_tag) after
71
122
# checking that we're on the right release branch.
@@ -75,25 +126,26 @@ git::export-current-version() {
75
126
76
127
# deal with the release-0 .1 branch, or similar
77
128
local release_ver=${BASH_REMATCH[1]}
78
- maj_ver=${release_ver}
79
- local tag_pattern='v${maj_ver} .([[: digit: ]]+ ).([[: digit]]+ )'
80
- if [[ ${maj_ver} =~ 0 \.([[: digit: ]]+ ) ]]; then
81
- maj_ver=0
82
- min_ver=${BASH_REMATCH[1]}
83
- local tag_pattern="v0 .(${min_ver} ).([[: digit: ]]+ )"
129
+ local expected_maj_ver=${release_ver}
130
+ if [[ ${expected_maj_ver} =~ 0 \.([[: digit: ]]+ ) ]]; then
131
+ expected_maj_ver=0
132
+ local expected_min_ver=${BASH_REMATCH[1]}
84
133
fi
85
134
86
- # make sure we've got a tag that matches our release branch
87
- last_tag=$(git describe --tags --abbrev=0 ) # try to fetch just the "current" tag name
88
- if [[ ! ${last_tag} =~ ${tag_pattern} ]]; then
89
- echo "tag ${last_tag} does not appear to be a release for this release (${release_ver} )-- it should be v${maj_ver} .Y.Z" >& 2
90
- exit 1
135
+ git::export-version-from-branch "release-${release_ver} " false
136
+
137
+ local last_tag_branch=""
138
+ if [[ ${maj_ver} == "0 " && ${min_ver} - eq $((expected_min_ver- 1 )) ]]; then
139
+ echo " most recent tag is a release behind (${last_tag} ), checking previous release branch to be safe" >&2
140
+ last_tag_branch=" release-0.${min_ver} "
141
+ elif [[ ${maj_ver} -eq $(( expected_maj_ver- 1 )) ]]; then
142
+ echo " most recent tag is a release behind (${last_tag} ), checking previous release branch to be safe" >&2
143
+ last_tag_branch=" release-${maj_ver} "
91
144
fi
92
145
93
- export min_ver=${BASH_REMATCH[1]}
94
- export patch_ver=${BASH_REMATCH[2]}
95
- export maj_ver=${maj_ver}
96
- export last_tag=${last_tag}
146
+ if [[ -n " ${last_tag_branch} " ]]; then
147
+ git::export-version-from-branch ${last_tag_branch} true
148
+ fi
97
149
}
98
150
99
151
# git::next-version figures out the next version to tag
0 commit comments