mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Check commit existed before running some commands
This commit is contained in:
parent
c258e5d4e8
commit
64b4a599e8
3
Makefile
3
Makefile
|
|
@ -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
14
helper/has-git-commit
Normal 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
13
need_git_commit
Normal 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
|
||||
Loading…
Reference in a new issue