From 4670d66a180e23dcea533f9c47b618c5ed0043f1 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 26 Jul 2021 10:30:06 -0300 Subject: src/, tests/: Stick to 80 columns with 8-chars wide tabs --- aux/80-columns.sh | 9 +++++++++ src/git-permalink.in | 44 ++++++++++++++++++++++++++++++-------------- tests/cli-opts.sh | 6 ++++-- tests/remotes.sh | 6 ++++-- tests/tests-lib.sh | 7 +++++-- 5 files changed, 52 insertions(+), 20 deletions(-) create mode 100755 aux/80-columns.sh diff --git a/aux/80-columns.sh b/aux/80-columns.sh new file mode 100755 index 0000000..02a8e81 --- /dev/null +++ b/aux/80-columns.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu + +for f in ${@:-$(cat -)}; do + sed 's/\t/ /g' "$f" | + awk -v FNAME="$f" 'length > 80 { + printf "%s:%s:%s\n", FNAME, NR, $0 + }' +done diff --git a/src/git-permalink.in b/src/git-permalink.in index a993791..0f7437c 100755 --- a/src/git-permalink.in +++ b/src/git-permalink.in @@ -31,16 +31,20 @@ MSG_MISSING_FILE_EO="La argumento DOSIERO mankas." MSG_UNSUPPORTED_ORIGIN_EN='Unsupported origin: %s. -Add an template override to use git-permalink (see "man git-permalink.1" for instructions).' +Add an template override to use git-permalink (see +"man git-permalink.1" for instructions).' MSG_UNSUPPORTED_ORIGIN_PT='Origem sem suporte: %s. -Adicione um modelo de substituição para usar o git-permalink (veja "man git-permalink.1" para mais instruções).' +Adicione um modelo de substituição para usar o git-permalink (veja +"man git-permalink.1" para mais instruções).' MSG_UNSUPPORTED_ORIGIN_FR='Origine n'"'"'es pas supporté: %s. -Ajouter un modèle de remplacement pour utilisér git-permalink (regarde "man git-permalink.1" pour les instructions).' +Ajouter un modèle de remplacement pour utilisér git-permalink (regarde +"man git-permalink.1" pour les instructions).' MSG_UNSUPPORTED_ORIGIN_EO='Origo ne estas subtenata: %s. -Aldoni anstataŭan ŝablonon por uzi git-permalink (vidu "man git-permalink.1" por instrukcioj).' +Aldoni anstataŭan ŝablonon por uzi git-permalink (vidu +"man git-permalink.1" por instrukcioj).' MSG_OPEN_EN='Opening %s' MSG_OPEN_PT='Abrindo %s' @@ -59,7 +63,8 @@ MSG_OPEN=\$MSG_OPEN_$lang } get_lang() { - # LC_MESSAGES="ll_CC.CODESET@modifier" -> ll_CC, where quotes are optional + # LC_MESSAGES="ll_CC.CODESET@modifier" -> ll_CC, where quotes are + # optional locale 2>/dev/null | \ grep LC_MESSAGES | \ cut -d. -f1 | \ @@ -172,19 +177,24 @@ lineno_with_l() { } euandreh() { - printf 'https://git.euandreh.xyz/%s/tree/%s?id=%s%s\n' "$REPOSITORY" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" + printf 'https://git.euandreh.xyz/%s/tree/%s?id=%s%s\n' \ + "$REPOSITORY" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" } sourcehut() { - printf '%s/tree/%s/item/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}" + printf '%s/tree/%s/item/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}" } kernel() { - printf '%s/tree/%s?id=%s%s\n' "$ORIGIN" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" + printf '%s/tree/%s?id=%s%s\n' \ + "$ORIGIN" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" } savannah() { - printf '%s/tree/%s?id=%s%s\n' "$(echo "$ORIGIN" | sed 's|gnu.org/git|gnu.org/cgit|')" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" + ORIGIN="$(echo "$ORIGIN" | sed 's|gnu.org/git|gnu.org/cgit|')" + printf '%s/tree/%s?id=%s%s\n' \ + "$ORIGIN" "$FILE" "$COMMIT" "${MYLINENO:+#n$MYLINENO}" } notabug() { @@ -194,26 +204,32 @@ notabug() { codeberg() { normalize_origin - printf '%s/src/commit/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)" + printf '%s/src/commit/%s/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)" } bitbucket() { normalize_origin - printf '%s/src/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#lines-$(echo "$MYLINENO" | tr '-' ':')}" + MYLINENO="${MYLINENO:+#lines-$(echo "$MYLINENO" | tr '-' ':')}" + printf '%s/src/%s/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "$MYLINENO" } pagure() { - printf '%s/blob/%s/f/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#_$MYLINENO}" + printf '%s/blob/%s/f/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#_$MYLINENO}" } gitlab() { normalize_origin - printf '%s/-/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}" + printf '%s/-/blob/%s/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "${MYLINENO:+#L$MYLINENO}" } github() { normalize_origin - printf '%s/blob/%s/%s%s\n' "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)" + printf '%s/blob/%s/%s%s\n' \ + "$ORIGIN" "$COMMIT" "$FILE" "$(lineno_with_l)" } guess_permalink() { diff --git a/tests/cli-opts.sh b/tests/cli-opts.sh index 9409aab..44dc6ce 100755 --- a/tests/cli-opts.sh +++ b/tests/cli-opts.sh @@ -98,7 +98,8 @@ test_help_flags() { N="$LINENO" OUT="$(mkstemp)" ERR="$(mkstemp)" - LANG=en_US.UTF-8 sh src/git-permalink --something something -h 1>"$OUT" 2>"$ERR" + LANG=en_US.UTF-8 sh src/git-permalink --something something -h \ + 1>"$OUT" 2>"$ERR" STATUS=$? assert_status 2 assert_usage "$ERR" @@ -106,7 +107,8 @@ test_help_flags() { N="$LINENO" OUT="$(mkstemp)" ERR="$(mkstemp)" - LANG=en_US.UTF-8 sh src/git-permalink --help more things 1>"$OUT" 2>"$ERR" + LANG=en_US.UTF-8 sh src/git-permalink --help more things \ + 1>"$OUT" 2>"$ERR" STATUS=$? assert_status 0 assert_empty_stderr diff --git a/tests/remotes.sh b/tests/remotes.sh index 7b1ba92..76aea04 100755 --- a/tests/remotes.sh +++ b/tests/remotes.sh @@ -165,7 +165,8 @@ test_unsupported_remote() { N="$LINENO" OUT="$(mkstemp)" ERR="$(mkstemp)" - git config git-permalink.template-commit-file 'before %s middle %s after' + git config git-permalink.template-commit-file \ + 'before %s middle %s after' git permalink -p README.md 123 1>"$OUT" 2>"$ERR" STATUS=$? assert_status 0 @@ -176,7 +177,8 @@ test_unsupported_remote() { OUT="$(mkstemp)" ERR="$(mkstemp)" git config --unset git-permalink.template-commit-file - git config git-permalink.template-file-commit 'before %s middle %s after' + git config git-permalink.template-file-commit \ + 'before %s middle %s after' git permalink -p README.md 123 1>"$OUT" 2>"$ERR" STATUS=$? assert_status 0 diff --git a/tests/tests-lib.sh b/tests/tests-lib.sh index 03edc2d..25079b9 100755 --- a/tests/tests-lib.sh +++ b/tests/tests-lib.sh @@ -16,7 +16,8 @@ ERROR() { } print_debug_info() { - printf 'LINENO: %s\nOUT: %s\nERR: %s\n' "$N" "$OUT" "$ERR" >&2 + printf 'LINENO: %s\nOUT: %s\nERR: %s\n' \ + "$N" "$OUT" "$ERR" >&2 } assert_status() { @@ -39,7 +40,9 @@ assert_usage() { assert_empty_stream() { if [ -s "$2" ]; then - printf '\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' \ + FMT='\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' + # shellcheck disable=2059 + printf "$FMT" \ "$(ERROR)" "$1" "$2" "$(cat "$2")" >&2 print_debug_info exit 1 -- cgit v1.2.3