GitのMakefileを追加
authorj8takagi <j8takagi@nifty.com>
Fri, 15 Mar 2013 02:22:57 +0000 (11:22 +0900)
committerj8takagi <j8takagi@nifty.com>
Fri, 15 Mar 2013 02:22:57 +0000 (11:22 +0900)
git/Makefile [new file with mode: 0644]
git/gitremote.mk [new file with mode: 0644]

diff --git a/git/Makefile b/git/Makefile
new file mode 100644 (file)
index 0000000..5d43e03
--- /dev/null
@@ -0,0 +1 @@
+-include gitremote.mk
diff --git a/git/gitremote.mk b/git/gitremote.mk
new file mode 100644 (file)
index 0000000..30c16aa
--- /dev/null
@@ -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 <url>'),$(GIT) remote add origin $(SERVERREPOS))
+
+gitrepos:
+       $(if $(REPOSEXT),,$(SSH) $(SERVER) '$(MKDIR) $(REPOSDIR)/$(REPOSNAME) && $(CD) $(REPOS) && $(GIT) init --bare')
+
+gitorigin-clean:
+       $(GIT) remote remove origin