aboutsummaryrefslogtreecommitdiffstats
path: root/abbrevURL
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-03-28 18:00:57 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-03-28 18:05:54 +0100
commit0aa99c66b5a8902eafdebe20cb44423c1dc5c310 (patch)
tree6b660044fa4a998b179bd28125a5adf4aa74b477 /abbrevURL
parentc537d6f934ee4ec5c8ee72f8e568e7151fa3135b (diff)
downloadvim-suse-changes-0aa99c66b5a8902eafdebe20cb44423c1dc5c310.tar.gz
fix(abbrevURL): abbreviate git IDs in the commit URLs.
Unfortunately, we have to switch to bash for it, because POSIX shell doesn’t have string indexing.
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@')"