]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
bundle.sh: accept more forms of a branch name
authorJason Ish <jason.ish@oisf.net>
Tue, 7 May 2024 22:28:07 +0000 (16:28 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 7 May 2024 22:28:07 +0000 (16:28 -0600)
For GitHub, add the following branch name formats:
- https://github.com/OISF/libhtp/pull/123
- OISF/libhtp#123

scripts/bundle.sh

index aabd728d3d887287a176c57465318c137999c7bc..06ea1ba9285d4539048037ce22f498112013a5c9 100755 (executable)
@@ -33,13 +33,27 @@ 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
+       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"