File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,11 @@ function init() {
1010
1111# 验证当前是否为Git项目
1212function verify {
13- git status & > /dev/null
14- if [[ $? -ne 0 ]]; then
15- echo " fatal: Not a git repository (or any of the parent directories): .git"
16- exit 1
13+ git rev-parse --show-toplevel > /dev/null 2>&1
14+ GIT_VERIFY=$?
15+ if test $GIT_VERIFY ! = 0; then
16+ >&2 echo " fatal: Not a git repository (or any of the parent directories): .git"
17+ exit $GIT_VERIFY
1718 fi
1819}
1920# 消息主体
@@ -62,7 +63,7 @@ function build() {
6263 else
6364 ALL=$@
6465 fi
65- MSGFILE=" . git/ COMMIT-MSG.tmp"
66+ MSGFILE=" ` git rev-parse --git-dir ` COMMIT-MSG.tmp"
6667
6768 echo " $type ($scope ): $subject " > $MSGFILE
6869 echo " " >> $MSGFILE
@@ -73,17 +74,16 @@ function build() {
7374 echo " $SOB " >> $MSGFILE
7475
7576}
76- # 清除临时文件
77- function clean() {
78- rm -f $MSGFILE
79- }
8077# 执行提交
8178function run() {
8279 GIT_COMMIT_CMD=" git commit -F $MSGFILE $ALL "
8380 echo $GIT_COMMIT_CMD
8481 eval $GIT_COMMIT_CMD
8582}
86-
83+ # 清除临时文件
84+ function clean() {
85+ rm -f $MSGFILE
86+ }
8787case $1 in
8888 * )
8989 init
You can’t perform that action at this time.
0 commit comments