aboutsummaryrefslogtreecommitdiffstats
path: root/abbrevURL
diff options
context:
space:
mode:
Diffstat (limited to 'abbrevURL')
-rwxr-xr-xabbrevURL8
1 files changed, 3 insertions, 5 deletions
diff --git a/abbrevURL b/abbrevURL
index a405876..b6b102d 100755
--- a/abbrevURL
+++ b/abbrevURL
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Abbreviate according to
# https://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations
set -eu
@@ -25,15 +25,13 @@ fi
STR="$(echo "$STR" | sed -E -e 's@https?://github.com/(.*)/issues/([0-9]+)@gh#\1#\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://github.com/(.*)/pull/([0-9]+)@gh#\1!\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://github.com/(.*)/discussions/([0-9]+)@gh#\1\$\2@')"
-# TODO STR=STR:gsub("https?://github.com/(.*)/commit/(%w+)", function (r, i)
-# return "gh#" .. r .. "@" .. i:sub(1, 12)
-# end)
-STR="$(echo "$STR" | sed -E -e 's!https?://github.com/(.*)/commit/([a-zA-Z0-9]+)!gh#\1@\2!')"
+STR="$(ID=${STR#*/commit/}; echo "$STR" | sed -E -e 's!https?://github.com/(.*)/commit/([a-zA-Z0-9]+)!gh#\1@'"${ID:0:11}"'!')"
STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.com/(.*)/issues/([0-9]+)@gl#\1#\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.com/(.*)/pull/([0-9]+)@gl#\1!\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.com/(.*)/-/issues/([0-9]+)@gl#\1#\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.com/(.*)/-/pull/([0-9]+)@gl#\1!\2@')"
STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.com/(.*)/-/merge-requests/([0-9]+)@gl#\1!\2@')"
+STR="$(ID=${STR#*/commit/}; echo "$STR" | sed -E -e 's!https?://gitlab.com/(.*)/-/commit/([a-zA-Z0-9]+)!gl#\1@'"${ID:0:11}"'!')"
STR="$(echo "$STR" | sed -E -e 's@https?://sourceforge.net/support/tracker.php\?aid=([0-9]+)@sh#\1@')"
STR="$(echo "$STR" | sed -E -e 's@https?://sf.net/support/tracker.php\?aid=([0-9]+)@sh#\1@')"
STR="$(echo "$STR" | sed -E -e 's@https?://sourceforge.net/p/(.*)/patches/([0-9]+)/@shp#\1#\2@')"