Skip to content

Commit 746286e

Browse files
committed
fix(1.0.1): 修复提交出现的异常
使用git rev-parse命令来获取git相关信息,解决验证git项目和提交的问题 fix #3 Signed-off-by: Tony Deng <wolf.deng@gmail.com>
1 parent f4c2777 commit 746286e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

command/git-ci

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ function init() {
1010

1111
# 验证当前是否为Git项目
1212
function 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
# 执行提交
8178
function 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+
}
8787
case $1 in
8888
*)
8989
init

0 commit comments

Comments
 (0)