@@ -26,28 +26,27 @@ esac;
2626# will set branch to the version number. This will mean that below the branch is
2727# treated as a release no matter what the true name of the branch is.
2828# 2. Failing that, try to get the branch name using symbolic-ref
29- # 3. ... but that won't work for detached heads so first try TRAVIS_BRANCH in case we're on Travis
30- # 4. ... and if this isn't Travis try Appveyor
31- # 4. ... and if this isn't Appveyor try to use git describe to get something even if it's just a sha
32- # 5. ... but sometimes despite the --always, even that will fail so just output the commitish.
33- branch=" $( $GIT describe --tags --exact-match --match=' [0-9]*.[0-9]*.[0-9]*' $commitish 2> /dev/null || $GIT symbolic-ref -q --short HEAD || echo ${TRAVIS_BRANCH:- } ) " ;
34-
35- if [[ -z $branch ]]; then
36- branch=" ${APPVEYOR_REPO_BRANCH} "
37- fi ;
38-
29+ # 3. ... but that won't work for detached heads so first try GITHUB_REF
30+ # 4. ... else try to use git describe to get something even if it's just a sha
31+ # 5. ... but sometimes despite the --always, even that will fail so just output the commitish
32+ branch=" $( $GIT describe --tags --exact-match --match=' [0-9]*.[0-9]*.[0-9]*' $commitish 2> /dev/null || $GIT symbolic-ref -q --short HEAD || echo ${GITHUB_REF:- } ) "
3933if [[ -z $branch ]]; then
4034 branch=" $( $GIT describe --all --exact-match --always $commitish 2> /dev/null || echo $commitish ) " ;
41- fi ;
35+ fi
4236
4337desc=" $( $GIT describe --tags --long --match=' [0-9]*.[0-9]*.[0-9]*' $commitish 2> /dev/null || echo ' 0.0.0-0' ) " ;
44- current_version=" ${desc%% -* } " ;
45- branch_type=" ${branch%/* } " ;
46- branch_short_name=" ${branch#*/ } " ;
47-
48- if [ " $branch_type " = " $current_version " ]; then
49- branch_type=" release" ;
50- fi ;
38+ current_version=" ${desc%% -* } "
39+ github_pr_regex=" ^refs/pull/([0-9]+)/merge"
40+ if [[ $branch =~ $github_pr_regex ]]; then
41+ branch_type=" feature"
42+ branch_short_name=" pr${BASH_REMATCH[1]} "
43+ else
44+ branch_type=" ${branch%/* } "
45+ branch_short_name=" ${branch#*/ } "
46+ if [ " $branch_type " = " $current_version " ]; then
47+ branch_type=" release"
48+ fi
49+ fi
5150
5251major=" ${current_version%% .* } " ;
5352minor=" ${current_version% .* } " ;
0 commit comments