From cec1c9d8535429589e9b6a9ed0219a90737f3d35 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 7 May 2024 16:28:07 -0600 Subject: [PATCH] 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 --- scripts/bundle.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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"