From: j8takagi Date: Fri, 15 Mar 2013 02:22:57 +0000 (+0900) Subject: GitのMakefileを追加 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3520851601e93547de9f7fbaad0fd9712a88632;p=makefiles.git GitのMakefileを追加 --- diff --git a/git/Makefile b/git/Makefile new file mode 100644 index 0000000..5d43e03 --- /dev/null +++ b/git/Makefile @@ -0,0 +1 @@ +-include gitremote.mk diff --git a/git/gitremote.mk b/git/gitremote.mk new file mode 100644 index 0000000..30c16aa --- /dev/null +++ b/git/gitremote.mk @@ -0,0 +1,31 @@ +CD := cd +ECHO := echo +GIT := git +LS := ls +MKDIR := mkdir +SSH := ssh + +SERVER := www.j8takagi.net +REPOSDIR := /home/git + +PROJECTNAME := $(notdir $(CURDIR)) +REPOSNAME := $(PROJECTNAME).git +REPOS := $(REPOSDIR)/$(REPOSNAME) +SERVERREPOS := $(SERVER):$(REPOS) + +REPOSEXT := $(strip $(shell $(SSH) $(SERVER) $(LS) -d $(REPOS) || $(ECHO))) +GITORIGIN := $(strip $(shell $(GIT) remote | grep origin)) + +.PHONY: gitorigin-add gitorigin-show gitpush gitorigin-clean gitrepos + +gitpush: gitorigin + $(GIT) push --set-upstream origin master + +gitorigin: gitrepos + $(if $(GITORIGIN),@($(ECHO) 'remote origin exists. git remote set-url origin '),$(GIT) remote add origin $(SERVERREPOS)) + +gitrepos: + $(if $(REPOSEXT),,$(SSH) $(SERVER) '$(MKDIR) $(REPOSDIR)/$(REPOSNAME) && $(CD) $(REPOS) && $(GIT) init --bare') + +gitorigin-clean: + $(GIT) remote remove origin