Check commit existed before running some commands

This commit is contained in:
spacewander 2017-01-27 18:58:16 +08:00
parent c258e5d4e8
commit 64b4a599e8
3 changed files with 30 additions and 0 deletions

View file

@ -38,6 +38,9 @@ install:
if ! grep "$(COMMAND)" not_need_git_repo >/dev/null; then \
cat ./helper/is-git-repo >> $(TEMPFILE); \
fi; \
if grep "$(COMMAND)" need_git_commit >/dev/null; then \
cat ./helper/has-git-commit >> $(TEMPFILE); \
fi; \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
fi; \

14
helper/has-git-commit Normal file
View file

@ -0,0 +1,14 @@
#
# check whether current directory contains any git commit
#
has_git_commit() {
git rev-parse --short HEAD > /dev/null 2>&1
result=$?
if test $result != 0; then
>&2 echo 'Not git commit found!'
exit $result
fi
}
has_git_commit

13
need_git_commit Normal file
View file

@ -0,0 +1,13 @@
# A list of the commands that require has_git_commit(), and should have
# it included in the "built" version of the command
git-authors
git-back
git-changelog
git-commits-since
git-count
git-effort
git-local-commits
git-reauthor
git-stamp
git-summary
git-undo