forked from rock-core/autobuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_github
executable file
·40 lines (31 loc) · 1.01 KB
/
update_github
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
#! /bin/sh
PAGES_BRANCH=gh-pages
DOC_DIR=doc
set -e
git reset -q HEAD
# Create the tree object
git add -f $DOC_DIR
tree=$(git write-tree --prefix=$DOC_DIR)
# Get the parent commit for the tree. If the branch does not yet exist, create
# it
msg="generated from $head_sha"
head_sha=$(git show-ref -s -h HEAD)
if git show-ref -q --verify refs/heads/$PAGES_BRANCH; then
parent=$(git show-ref -s refs/heads/$PAGES_BRANCH)
# Check that some things changes since last time
last_tree=$(git cat-file commit refs/heads/$PAGES_BRANCH | grep tree | awk '{print $2}')
if test "x$last_tree" = "x$tree"; then
echo "no changes to commit"
else
echo "updating $PAGES_BRANCH"
commit=$(echo $msg | git commit-tree $tree -p $parent)
fi
else
echo "creating initial commit on the $PAGES_BRANCH branch"
commit=$(echo $msg | git commit-tree $tree)
fi
if test -n "$commit"; then
# And finally update the tip of the branch
echo $commit > .git/refs/heads/$PAGES_BRANCH
fi
git reset -q HEAD