forked from shimokei53/git_simple_commit_message_editor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gscme
executable file
·44 lines (36 loc) · 1.01 KB
/
gscme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
set -e
# 在這邊設定常用的 Editor
# 當不是 commit 而是 merge, rebase 的時候會使用這邊設定的 Editor
CORE_EDITOR=vi
# 當不是 commit 而是 merge, rebase 的時候會使用 CORE_EDITOR 處理
if [[ ! "$1" = *COMMIT_EDITMSG ]]; then
$CORE_EDITOR $1
exit 0
fi
CURRENT_DIR=$(pwd)
MSGLIST_FILE=$CURRENT_DIR/.gscme_msglist
SAMPLE_MSGLIST_FILE=$CURRENT_DIR/sample_msglist/.gscme_msglist_present_tense_subject
# 專案 folder 中沒有 .gscme_msglist 的話印出提示
# 如果有 sample 的話設定為 sample。
if [[ ! -r $MSGLIST_FILE ]]; then
/bin/echo "please edit .gscme_msglist file in current project path"
cat $SAMPLE_MSGLIST_FILE > $MSGLIST_FILE
fi
COMMIT_MSG=""
exec 3< $MSGLIST_FILE
while read line 0<&3
do
if [[ ${line} == \#* ]]; then
continue
fi
if [[ ${line} ]]; then
/bin/echo -n "$line > "
read msg
COMMIT_MSG="${COMMIT_MSG}${msg}"
fi
COMMIT_MSG="${COMMIT_MSG}\n"
done
exec 3<&-
echo $COMMIT_MSG >> $1
exit 0