aboutsummaryrefslogtreecommitdiffstats
path: root/abbrevURL.sh
diff options
context:
space:
mode:
Diffstat (limited to 'abbrevURL.sh')
-rwxr-xr-xabbrevURL.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/abbrevURL.sh b/abbrevURL.sh
new file mode 100755
index 0000000..516f202
--- /dev/null
+++ b/abbrevURL.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Abbreviate according to
+# https://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations
+set -eu
+
+if [ $# -le 1 ] ; then
+STR="$(cat)"
+else
+STR="$1"
+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@')"
+STR="$(ID=${STR#*/commit/}; echo "$STR" | sed -E -e 's!https?://github.com/(.*)/commit/([a-zA-Z0-9]+)!gh#\1@'"${ID%"${ID#????????????}"}"'!')"
+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%"${ID#????????????}"}"'!')"
+STR="$(echo "$STR" | sed -E -e 's@https?://todo.sr.ht/~(.*)/([0-9]+)@srht#\1#\2@')"
+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@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://sourceforge.net/p/(.*)/bugs/([0-9]+)/@shb#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://sourceforge.net/p/(.*)/tickets/([0-9]+)/@sht#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://sf.net/support/p/(.*)/patches/([0-9]+)/@shp#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://sf.net/support/p/(.*)/bugs/([0-9]+)/@shb#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://sf.net/support/p/(.*)/tickets/([0-9]+)/@sht#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bitbucket.org/(.*)/issues/([0-9]+)/@bt#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://build.suse.de/request/show/([0-9]+)@ssr#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://build.opensuse.org/request/show/([0-9]+)@sr#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.opensuse.org/show_bug.cgi\?id=([0-9]+)@boo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.opensuse.org/([0-9]+)@boo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.suse.com/show_bug.cgi\?id=([0-9]+)@bsc#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.suse.com/([0-9]+)@bsc#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.redhat.com/show_bug.cgi\?id=([0-9]+)@rh#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.redhat.com/([0-9]+)@rh#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.mozilla.org/show_bug.cgi\?id=([0-9]+)@bmo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugzilla.mozilla.org/([0-9]+)@bmo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.documentfoundation.org/show_bug.cgi\?id=([0-9]+)@tdf#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.documentfoundation.org/([0-9]+)@tdf#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://jira.suse.com/browse/([a-zA-Z]+)@jsc#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.python.org/issue([0-9]+)@bpo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.launchpad.net/.+/\+bug/([0-9]+)@lp#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://www.python.org/dev/peps/pep-([0-9]+)/?@pep#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://svn.boost.org/trac/boost/([0-9]+)@boost#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://rt.cpan.org/Public/([0-9]+)@RT#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.debian.org/([0-9]+)@deb#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.freedesktop.org/([0-9]+)@fdo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.freedesktop.org/([a-zA-Z]+)/issues/([0-9]+)@glfo#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://gcc.gnu.org/bugzilla/([0-9]+)@gcc#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://gitlab.gnome.org/([a-zA-Z]+)/issues/([0-9]+)@glgo#\1#\2@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://bugs.kde.org/([0-9]+)@kde#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://api.github.com/repos/openSUSE/open-build-service/issues/([0-9]+)@obs#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://api.github.com/repos/openSUSE/obs-build/issues/([0-9]+)@build#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://api.github.com/repos/openSUSE/osc/issues/([0-9]+)@osc#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://progress.opensuse.org/issues/([0-9]+)@poo#\1@')"
+STR="$(echo "$STR" | sed -E -e 's@https?://developerbugs.linux-foundation.org/([0-9]+)@lf#\1@')"
+
+echo "$STR"