-
Notifications
You must be signed in to change notification settings - Fork 161
/
ghpages.sh
executable file
·46 lines (36 loc) · 1.36 KB
/
ghpages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash -x
git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'`
if ! (git remote set-branches --add origin gh-pages && git fetch -q); then
echo "No gh-pages, so not syncing"
exit 0
fi
if ! [ -d docs/build/asciidoc/html5 ]; then
echo "No gh-pages sources in docs/build/asciidoc/html5, so not syncing"
exit 0
fi
# 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
###################################################################
git checkout gh-pages
for f in docs/build/asciidoc/html5/*; do
file=${f#docs/build/asciidoc/html5/*}
if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then
# Not ignored...
cp -rf $f .
git add -A $file
fi
done
git commit -a -m "Sync docs from master to gh-pages"
# Uncomment the following push if you want to auto push to
# the gh-pages branch whenever you commit to master 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
if [ "$dirty" != "0" ]; then git stash pop; fi
exit 0