From: Jason Ish Date: Tue, 7 May 2024 22:28:07 +0000 (-0600) Subject: bundle.sh: accept more forms of a branch name X-Git-Tag: suricata-8.0.0-beta1~1338 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cec1c9d8535429589e9b6a9ed0219a90737f3d35;p=thirdparty%2Fsuricata.git 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 --- diff --git a/scripts/bundle.sh b/scripts/bundle.sh index aabd728d3d..06ea1ba928 100755 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -33,13 +33,27 @@ what="$1" # Transforms a branch name in the form of "pr/" or # "mr/" 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 + echo "refs/pull/${pr}/head" + return fi - + mr=$(echo "${1}" | sed -n 's/^mr\/\([[:digit:]]\+\)$/\1/p') if [ "${mr}" ]; then echo "refs/merge-requests/${mr}/head"