From e3520851601e93547de9f7fbaad0fd9712a88632 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Fri, 15 Mar 2013 11:22:57 +0900 Subject: [PATCH] =?utf8?q?Git=E3=81=AEMakefile=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- git/Makefile | 1 + git/gitremote.mk | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 git/Makefile create mode 100644 git/gitremote.mk 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 -- 2.18.0