diff options
author | Trevor Elliott <trevor@galois.com> | 2013-06-21 16:53:40 -0700 |
---|---|---|
committer | Trevor Elliott <trevor@galois.com> | 2013-06-21 16:53:40 -0700 |
commit | a1100b640f2ed9469158cb0bc42f2f9bf288f917 (patch) | |
tree | 4ffbe51b63f6eb2f23207a788e8a73083ee97a0c /mk/gh-pages.mk | |
parent | 4b9a4468238b96482478b3fabdfe6fb8cabb4fd6 (diff) |
Move gh-pages management stuff to mk/gh-pages.mk
Diffstat (limited to 'mk/gh-pages.mk')
-rw-r--r-- | mk/gh-pages.mk | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mk/gh-pages.mk b/mk/gh-pages.mk new file mode 100644 index 0000000..cfa67c5 --- /dev/null +++ b/mk/gh-pages.mk @@ -0,0 +1,53 @@ + +# gh-pages Branch Management ################################################### + +gh-pages-dir := $(build-dir)/gh-pages + +ifeq "$(git-cmd)" "" +$(call strict-error,"unable to locate git") +else + +# figure out the url of the origin that the current work repo uses +remote-url := $(shell $(git-cmd) config remote.origin.url) + +endif + + +# Pull in the gh-pages directory. +.PHONY: pull-gh-pages +ifeq "$(pull)" "0" +pull-gh-pages: +else +pull-gh-pages: | $(gh-pages-dir) + $(call label,PULL $(call drop-prefix,$(gh-pages-dir)))\ + ( cd $(gh-pages-dir) \ + && $(git-cmd) pull $(if $(Q),-q) ) +endif + + +# checkout the gh-pages branch in a temp repo under the build tree +$(gh-pages-dir): | $(build-dir) + $(call label,CLONE $(call drop-prefix,$@))\ + ( $(git-cmd) clone $(if $(Q),-q) $(topdir) $@ \ + && cd $(gh-pages-dir) \ + && $(git-cmd) remote set-url origin $(remote-url) \ + && $(git-cmd) fetch $(if $(Q),-q) origin gh-pages \ + && $(git-cmd) checkout $(if $(Q),-q) gh-pages ) + + +# Generate a commit in the gh-pages-dir, after adding some files that may have +# changed. +commit = $(call label,COMMIT $(call drop-prefix,$(gh-pages-dir)))\ + ( cd $(gh-pages-dir) \ + && if test -n "`$(git-cmd) status -s`"; then \ + $(git-cmd) add $1 \ + && $(git-cmd) commit $(if $(Q),-q) -m $2 \ + ; fi ) + + + +# push to the gh-pages branch from the temp repo +deploy: | pull-gh-pages + $(call label,DEPLOY)\ + ( cd $(gh-pages-dir) \ + && git push $(if $(Q),-q) origin gh-pages ) |