diff --git a/builder/templates/builder b/builder/templates/builder index ac662aa17a..3e0465bb7a 100755 --- a/builder/templates/builder +++ b/builder/templates/builder @@ -11,13 +11,6 @@ get_app_name() { echo $1 | awk -F"." '{print $1}' } -get_git_sha() { - repo=$1 - branch=$2 - branch_file="${repo}/${branch}" - cat $branch_file -} - indent() { echo " $@" } @@ -35,7 +28,7 @@ puts-warn() { } usage() { - echo "Usage: $0 " + echo "Usage: $0 " } if [ $# -ne $ARGS ]; then @@ -45,7 +38,8 @@ fi USER=$1 REPO=$2 -BRANCH=$3 +GIT_SHA=$3 +SHORT_SHA=${GIT_SHA:0:8} APP_NAME=$(get_app_name $REPO) cd $(dirname $0) # ensure we are in the root dir @@ -56,10 +50,6 @@ REPO_DIR="${ROOT_DIR}/${REPO}" BUILD_DIR="${REPO_DIR}/build" CACHE_DIR="${REPO_DIR}/cache" -# get git sha of branch -GIT_SHA=$(get_git_sha $REPO_DIR $BRANCH) -SHORT_SHA=${GIT_SHA:0:8} - # define image names IMAGE_NAME="$APP_NAME:git-$SHORT_SHA" TMP_IMAGE="{{ .deis_registry_host }}:{{ .deis_registry_port }}/$IMAGE_NAME" @@ -70,8 +60,7 @@ mkdir -p $BUILD_DIR $CACHE_DIR TMP_DIR=$(mktemp -d --tmpdir=$BUILD_DIR) cd $REPO_DIR -# extract git branch -git archive $BRANCH | tar -xmC $TMP_DIR +git archive $GIT_SHA | tar -xmC $TMP_DIR # switch to app context cd $TMP_DIR diff --git a/builder/templates/gitreceive b/builder/templates/gitreceive index 6eb94660d5..67860a56d0 100755 --- a/builder/templates/gitreceive +++ b/builder/templates/gitreceive @@ -35,37 +35,26 @@ case "$1" in cat | $SELF pre-receive EOF chmod +x $PRERECEIVE_HOOK - POSTRECEIVE_HOOK="$REPO_PATH/hooks/post-receive" - # inject a post-receive hook - cat > $POSTRECEIVE_HOOK <&1 | strip_remote_prefix + sudo $GITHOME/builder $RECEIVE_USER $RECEIVE_REPO $newrev 2>&1 | strip_remote_prefix fi done ;;