Skip to content

Commit

Permalink
Merge pull request #258 from spacewander/master
Browse files Browse the repository at this point in the history
use mixin to add 'is git repo' check.
  • Loading branch information
hemanth committed Sep 25, 2014
2 parents 4cd35e8 + d9724f3 commit 68455cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,29 @@ MANS = $(wildcard man/git-*.md)
MAN_HTML = $(MANS:.md=.html)
MAN_PAGES = $(MANS:.md=.1)

COMMANDS_USED_WITHOUT_GIT_REPO = git-alias git-extras git-fork git-setup
COMMANDS_USED_WITH_GIT_REPO = $(filter-out $(COMMANDS_USED_WITHOUT_GIT_REPO), \
$(subst bin/, , $(BINS)))

docs: $(MAN_HTML) $(MAN_PAGES)

install:
@mkdir -p $(DESTDIR)$(MANPREFIX)
@mkdir -p $(DESTDIR)$(BINPREFIX)
@echo "... installing bins to $(DESTDIR)$(BINPREFIX)"
@echo "... installing man pages to $(DESTDIR)$(MANPREFIX)"
@$(foreach BIN, $(BINS), \
echo "... installing $(notdir $(BIN))"; \
cp -f $(BIN) $(DESTDIR)$(BINPREFIX); \
$(eval TEMPFILE := $(shell mktemp))
@# chmod from rw-------(default) to rwxrwxr-x, so that users can exec the scripts
@chmod 775 $(TEMPFILE)
@$(foreach COMMAND, $(COMMANDS_USED_WITH_GIT_REPO), \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) | cat - ./helper/is-git-repo > $(TEMPFILE); \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
)
@$(foreach COMMAND, $(COMMANDS_USED_WITHOUT_GIT_REPO), \
echo "... installing $(COMMAND)"; \
cp -f bin/$(COMMAND) $(DESTDIR)$(BINPREFIX); \
)
cp -f man/git-*.1 $(DESTDIR)$(MANPREFIX)
@mkdir -p $(DESTDIR)/etc/bash_completion.d
Expand Down
14 changes: 14 additions & 0 deletions helper/is-git-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# check whether current directory is inside a git repository
#

is_git_repo() {
git rev-parse --show-toplevel > /dev/null 2>&1
result=$?
if test $result != 0; then
>&2 echo 'Not a git repo!'
exit $result
fi
}

is_git_repo

0 comments on commit 68455cf

Please sign in to comment.