aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-19 09:30:50 -0300
committerEuAndreh <eu@euandre.org>2021-06-19 09:30:50 -0300
commit0ee7b1fa813809e2e86e4e322999d3d56f1d180d (patch)
treed59f60b11f6b4f98bc37d77cdb8147a32922bb9b
parentaux/workflow/manpages.sh: Suppress ShellCheck warnings (diff)
downloadgit-permalink-0ee7b1fa813809e2e86e4e322999d3d56f1d180d.tar.gz
git-permalink-0ee7b1fa813809e2e86e4e322999d3d56f1d180d.tar.xz
Add support for notabug.org
-rwxr-xr-xsrc/git-permalink.sh52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/git-permalink.sh b/src/git-permalink.sh
index 2deb97e..f2da926 100755
--- a/src/git-permalink.sh
+++ b/src/git-permalink.sh
@@ -124,6 +124,26 @@ OVERRIDE_CF="$(git config git-permalink.template-commit-file ||:)"
OVERRIDE_FC="$(git config git-permalink.template-file-commit ||:)"
REPOSITORY="$(basename "$PWD")"
+normalize_origin() {
+ if echo "$ORIGIN" | grep -q '^git@'; then
+ NAME="$(echo "$ORIGIN" | cut -d: -f2 | cut -d/ -f1)"
+ URL="$(echo "$ORIGIN" | cut -d@ -f2 | cut -d: -f1)"
+ ORIGIN="https://$URL/$NAME/$REPOSITORY"
+ fi
+}
+
+lineno_with_l() {
+ if echo "$MYLINENO" | grep -q -- -; then
+ P1="$(echo "$MYLINENO" | cut -d- -f1)"
+ P2="$(echo "$MYLINENO" | cut -d- -f2)"
+ printf '#L%s-L%s' "$P1" "$P2"
+ elif [ -n "$MYLINENO" ]; then
+ printf '#L%s' "${MYLINENO}"
+ else
+ printf ''
+ fi
+}
+
euandreh() {
printf 'https://git.euandreh.xyz/%s/tree/%s?id=%s%s\n' "$REPOSITORY" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}"
}
@@ -136,32 +156,19 @@ savannah() {
printf '%s/tree/%s?id=%s%s\n' "$(echo "$ORIGIN" | sed 's|gnu.org/git|gnu.org/cgit|')" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}"
}
-gitlab() {
- if echo "$ORIGIN" | grep -q '^git@gitlab.com:'; then
- NAME="$(echo "$ORIGIN" | cut -d: -f2 | cut -d/ -f1)"
- ORIGIN="https://gitlab.com/$NAME/$REPOSITORY"
- fi
- printf '%s/-/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}"
+notabug() {
+ normalize_origin
+ printf '%s/src/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)"
}
-damnyou_github() {
- if echo "$MYLINENO" | grep -q -- -; then
- P1="$(echo "$MYLINENO" | cut -d- -f1)"
- P2="$(echo "$MYLINENO" | cut -d- -f2)"
- printf '#L%s-L%s' "$P1" "$P2"
- elif [ -n "$MYLINENO" ]; then
- printf '#L%s' "${MYLINENO}"
- else
- printf ''
- fi
+gitlab() {
+ normalize_origin
+ printf '%s/-/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}"
}
github() {
- if echo "$ORIGIN" | grep -q '^git@github.com:'; then
- NAME="$(echo "$ORIGIN" | cut -d: -f2 | cut -d/ -f1)"
- ORIGIN="https://github.com/$NAME/$REPOSITORY"
- fi
- printf '%s/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "$(damnyou_github)"
+ normalize_origin
+ printf '%s/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)"
}
guess_permalink() {
@@ -182,6 +189,9 @@ guess_permalink() {
*git.savannah.gnu.org*)
savannah
;;
+ *notabug.org*)
+ notabug
+ ;;
*gitlab.com*)
gitlab
;;