Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Jones <git@serebit.com>2023-03-25 17:53:27 -0400
committerLevente Polyak <anthraxx@archlinux.org>2023-05-20 00:08:12 +0200
commita981ef40e84398475cfe04ac49b8118385249a96 (patch)
tree7de734be950a7f8ca30a2caae12a2e6132b2e555
parentfe2eb3076df36c619c22bf65c68e68f38ab39b83 (diff)
edit: improve editor presence checking
Adds a check for the configured Git editor (git config core.editor) in both commitpkg and build.sh. Additionally, instead of blindly executing vi when all other options are exhausted, remove it instead as it is a none standard installed editor anyway. Closes #106 Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--src/commitpkg.in4
-rw-r--r--src/lib/build/build.sh11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/commitpkg.in b/src/commitpkg.in
index 7573d9b..26117dc 100644
--- a/src/commitpkg.in
+++ b/src/commitpkg.in
@@ -198,8 +198,10 @@ if [[ -n $(git status --short --untracked-files=no) ]]; then
$VISUAL "$msgfile" || die
elif [[ -n $EDITOR ]]; then
$EDITOR "$msgfile" || die
+ elif giteditor=$(git config --get core.editor); then
+ $giteditor "$msgfile" || die
else
- vi "$msgfile" || die
+ die "No usable editor found (tried \$GIT_EDITOR, \$VISUAL, \$EDITOR, git config [core.editor])."
fi
[[ -s $msgfile ]] || die
stat_busy 'Committing changes'
diff --git a/src/lib/build/build.sh b/src/lib/build/build.sh
index e32c79f..72ee4fb 100644
--- a/src/lib/build/build.sh
+++ b/src/lib/build/build.sh
@@ -335,18 +335,21 @@ pkgctl_build() {
# edit PKGBUILD
if (( EDIT )); then
stat_busy 'Editing PKGBUILD'
- if [[ -n $VISUAL ]]; then
+ if [[ -n $GIT_EDITOR ]]; then
+ $GIT_EDITOR PKGBUILD || die
+ elif [[ -n $VISUAL ]]; then
$VISUAL PKGBUILD || die
elif [[ -n $EDITOR ]]; then
$EDITOR PKGBUILD || die
- elif command -v vi &>/dev/null; then
- vi PKGBUILD || die
+ elif giteditor=$(git config --get core.editor); then
+ $giteditor PKGBUILD || die
else
- die "need \$VISUAL or \$EDITOR to edit the PKGBUILD"
+ die "No usable editor found (tried \$GIT_EDITOR, \$VISUAL, \$EDITOR, git config [core.editor])."
fi
stat_done
fi
+
# update checksums if any sources are declared
if (( UPDPKGSUMS )) && (( ${#source[@]} >= 1 )); then
updpkgsums