bundle.sh: accept more forms of a branch name

For GitHub, add the following branch name formats:
- https://github.com/OISF/libhtp/pull/123
- OISF/libhtp#123
pull/11046/head
Jason Ish 10 months ago
parent abb74245cc
commit cec1c9d853

@ -33,8 +33,22 @@ what="$1"
# Transforms a branch name in the form of "pr/<NUMBER>" or
# "mr/<NUMBER>" into a proper ref for GitHub or GitLab.
# Transform a branch name to a ref.
#
# For GitHub the following formats are allowed:
# - pr/123
# - pull/123
# - https://github.com/OISF/libhtp/pull/123
# - OISF/libhtp#123
#
# For GibLab only the format "mr/123" is supported.
transform_branch() {
pr=$(echo "${1}" | sed -n 's/^pr\/\([[:digit:]]\+\)$/\1/p')
pr=$(echo "${1}" | sed -n \
-e 's/^https:\/\/github.com\/OISF\/.*\/pull\/\([0-9]*\)$/\1/p' \
-e 's/^OISF\/.*#\([0-9]*\)$/\1/p' \
-e 's/^pull\/\([0-9]*\)$/\1/p' \
-e 's/^pr\/\([0-9]*\)$/\1/p')
if [ "${pr}" ]; then
echo "refs/pull/${pr}/head"
return

Loading…
Cancel
Save