Skip to content

Commit 973deaf

Browse files
committed
release scripts respects configured git editor
1 parent d58f1be commit 973deaf

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

release-lab-instructions.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ while getopts ":v:m:r:yh" opt; do
7676
done
7777

7878
if [[ -z "$VERSION" ]]; then
79-
VERSION="$(date +%Y-%m-%d)"
80-
echo "Ingen version angiven. Använder dagens datum som version: $VERSION"
79+
echo "Fel: -v <version> krävs."
80+
usage
81+
exit 1
8182
fi
8283

8384
TAG="lab_${VERSION}"
@@ -103,7 +104,14 @@ if [[ -z "$MESSAGE" ]]; then
103104
echo "(Skriv ditt meddelande ovan. Ta inte bort sista raden.)"
104105
echo "---"
105106
} > "$tmpfile"
106-
"${GIT_EDITOR:-${VISUAL:-vi}}" "$tmpfile"
107+
108+
editor_cmd="$(git config --get core.editor || true)"
109+
if [[ -z "$editor_cmd" ]]; then
110+
echo "core.editor är inte satt. Ex: git config --global core.editor 'nano -w'" >&2
111+
exit 1
112+
fi
113+
sh -c "$editor_cmd \"\$1\"" _ "$tmpfile"
114+
107115
MESSAGE="$(sed '/^---$/,$d' "$tmpfile" | sed -e '${/^$/d}')"
108116
rm -f "$tmpfile"
109117
[[ -z "$MESSAGE" ]] && MESSAGE="Lab instructions $VERSION"

release-slides.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ if [[ -z "$MESSAGE" ]]; then
133133
echo "(Skriv ditt meddelande ovan. Ta inte bort sista raden.)"
134134
echo "---"
135135
} > "$tmpfile"
136-
"${GIT_EDITOR:-${VISUAL:-vi}}" "$tmpfile"
136+
137+
editor_cmd="$(git config --get core.editor || true)"
138+
if [[ -z "$editor_cmd" ]]; then
139+
echo "core.editor är inte satt. Ex: git config --global core.editor 'nano -w'" >&2
140+
exit 1
141+
fi
142+
sh -c "$editor_cmd \"\$1\"" _ "$tmpfile"
143+
137144
MESSAGE="$(sed '/^---$/,$d' "$tmpfile" | sed -e '${/^$/d}')"
138145
rm -f "$tmpfile"
139146

0 commit comments

Comments
 (0)