Created
May 11, 2009 08:16
-
-
Save doudou/109911 to your computer and use it in GitHub Desktop.
This script takes a directory and creates a new commit in the gh-pages branch that represent the state of that directoy. This is used in my own project Roby to generate the documentation using webgen and rdoc, and automatically (and cheaply) update the gh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PAGES_BRANCH=gh-pages | |
| DOC_DIR=doc/html | |
| 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 $(git show-ref HEAD | awk '{print $1}')" | |
| parent=$(git show-ref refs/heads/$PAGES_BRANCH | awk '{ print $1 }') | |
| if test -n "$parent"; then | |
| # Check that some things changes since last time | |
| last_tree=$(git cat-file commit $PAGES_BRANCH | grep tree | awk '{print $2}') | |
| if test "x$last_tree" = "x$tree"; then | |
| echo "no changes to commit" | |
| else | |
| commit=$(echo $msg | git commit-tree $tree -p $parent) | |
| fi | |
| else | |
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment