Basic Git integration with Google App Engine

So we at sendapatch.se use Git a lot for the our productions. It's great.

One vital detail you need to know in App Engine development is what’s up there, … y'know, up in the cloud.

The solution is as obvious as it is useful and tedious to write, for your consideration: a script that updates App Engine from the current HEAD and bookmarks it in a branch named uploaded-<version>.

#!/bin/bash

# updates appengine from current HEAD and puts tree in uploaded-<version>

BASE=.
PYTHON=python2.7
APPENGINE=$BASE/google_appengine
APP=$BASE/app
VERSION="$(grep '^version: ' "$APP/app.yaml" | cut -c 10-)"
BRANCH="uploaded-$VERSION"

echo "Creating snapshot for $VERSION" >&2

TREE="$(git write-tree)"
COMMIT="$(git commit-tree $TREE -p HEAD <<COMMIT
Upload $VERSION to Google App Engine
COMMIT
)"
echo "commit $COMMIT"
git branch -f "$BRANCH" "$COMMIT" || exit

exec "$PYTHON" "$APPENGINE/appcfg.py" update app "$@"

Comments
Posted by: DaveE §

Why do you use the low level git commands here instead of the porcelain commands?



could you have done:

COMMIT="$(git commit -m <<COMMIT

Upload $VERSION to Google App Engine

COMMIT

)"



Is it because you don't want to commit the current index to your current branch? You only want to commit it to a new branch and push it?

2012-06-13 @ 16:55:49
URL: http://dave.edelste.in
Posted by: Ludvig Ericson §

Because a mere git commit won't necessarily commit, for example if there are no unstaged changes or otherwise. This script writes the current index and sets a branch to a commit pointing to that tree.

2012-06-13 @ 16:57:29
URL: http://sendapatch.se/

Comment the entry:

Name: (required, possibly pseudonym)
Remember me (cookie)

E-mail: (not required, never published, solely for me to reply to you in person)

URL:

Comment:

RSS 2.0