From 89ebf1fa3f740d200df804e1cc9885ec20b74c75 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 12:29:41 +0100 Subject: [PATCH 1/7] Fix ghpages script to work on branches --- docs/src/main/asciidoc/ghpages.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index 91905757..a108383f 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -12,13 +12,17 @@ if ! [ -d docs/target/generated-docs ]; then exit 0 fi +# Find name of current branch +################################################################### +branch=`git rev-parse --abbrev-ref HEAD` + # Stash any outstanding changes ################################################################### git diff-index --quiet HEAD dirty=$? if [ "$dirty" != "0" ]; then git stash; fi -# Switch to gh-pages branch to sync it with master +# Switch to gh-pages branch to sync it with current branch ################################################################### git checkout gh-pages @@ -31,16 +35,16 @@ for f in docs/target/generated-docs/*; do fi done -git commit -a -m "Sync docs from master to gh-pages" +git commit -a -m "Sync docs from $branch to gh-pages" # Uncomment the following push if you want to auto push to -# the gh-pages branch whenever you commit to master locally. +# the gh-pages branch whenever you commit to branch locally. # This is a little extreme. Use with care! ################################################################### git push origin gh-pages -# Finally, switch back to the master branch and exit block -git checkout master +# Finally, switch back to the current branch and exit block +git checkout $branch if [ "$dirty" != "0" ]; then git stash pop; fi exit 0 From c1cb0025c16e1ec0dc9c4a10e41e502b2d86c2c9 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 12:37:15 +0100 Subject: [PATCH 2/7] Use subdirectory for gh pages docs --- docs/src/main/asciidoc/ghpages.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index a108383f..00a208de 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -15,6 +15,8 @@ fi # Find name of current branch ################################################################### branch=`git rev-parse --abbrev-ref HEAD` +target=. +if [ "$branch" != "master" ]; then target=./$branch; mkdir -p $target; fi # Stash any outstanding changes ################################################################### @@ -30,8 +32,8 @@ for f in docs/target/generated-docs/*; do file=${f#docs/target/generated-docs/*} if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then # Not ignored... - cp -rf $f . - git add -A $file + cp -rf $f $target + git add -A $target/$file fi done From 56fae9330f1d30b1e8d77dba076ff910d2982233 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 12:44:08 +0100 Subject: [PATCH 3/7] Try to debug CI failures --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 95c6125c..876053a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,8 @@ install: - mvn --settings .settings.xml install -P docs -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true - ./docs/src/main/asciidoc/ghpages.sh script: +- git status +- ls -a - '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || mvn --settings .settings.xml deploy -P release -nsu -Dmaven.test.redirectTestOutputToFile=true' - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] || mvn --settings .settings.xml install -nsu -Dmaven.test.redirectTestOutputToFile=true' env: From c90582200546b06051c8ce5d0fb57afd08e121cb Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 12:54:17 +0100 Subject: [PATCH 4/7] Special treatnment of README --- docs/src/main/asciidoc/ghpages.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index 00a208de..64aaed8f 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -37,6 +37,7 @@ for f in docs/target/generated-docs/*; do fi done +[ -e README.adoc ] && git add -A README.adoc git commit -a -m "Sync docs from $branch to gh-pages" # Uncomment the following push if you want to auto push to From 00cc64c6c54dd8b824259fa1faff71c01e408a91 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 14:04:43 +0100 Subject: [PATCH 5/7] Different special treatment of README --- docs/src/main/asciidoc/ghpages.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index 64aaed8f..ed9a0005 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -37,14 +37,14 @@ for f in docs/target/generated-docs/*; do fi done -[ -e README.adoc ] && git add -A README.adoc -git commit -a -m "Sync docs from $branch to gh-pages" +git add -A README.adoc || echo "No change to README.adoc" +git commit -a -m "Sync docs from $branch to gh-pages" || echo "Nothing committed" # Uncomment the following push if you want to auto push to # the gh-pages branch whenever you commit to branch locally. # This is a little extreme. Use with care! ################################################################### -git push origin gh-pages +git push origin gh-pages || echo "Cannot push gh-pages" # Finally, switch back to the current branch and exit block git checkout $branch From b3ca7430b08964214afbb7eec9f6cb2ce42d1e54 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 14:15:51 +0100 Subject: [PATCH 6/7] Move ghpages to script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 876053a8..7f0e7eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ before_install: - gem install asciidoctor install: - mvn --settings .settings.xml install -P docs -q -U -DskipTests=true -Dmaven.test.redirectTestOutputToFile=true -- ./docs/src/main/asciidoc/ghpages.sh script: +- ./docs/src/main/asciidoc/ghpages.sh - git status - ls -a - '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || mvn --settings .settings.xml deploy -P release -nsu -Dmaven.test.redirectTestOutputToFile=true' From 7fc9811975b559b94b4686353305effed7b0bb5e Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 25 Aug 2015 14:52:31 +0100 Subject: [PATCH 7/7] Use TRAVIS_BRANCH if available --- docs/src/main/asciidoc/ghpages.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index ed9a0005..e1063ce3 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -14,7 +14,8 @@ fi # Find name of current branch ################################################################### -branch=`git rev-parse --abbrev-ref HEAD` +branch=$TRAVIS_BRANCH +[ "$branch" == "" ] && branch=`git rev-parse --abbrev-ref HEAD` target=. if [ "$branch" != "master" ]; then target=./$branch; mkdir -p $target; fi