File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,13 +11,6 @@ get_app_name() {
1111 echo $1 | awk -F" ." ' {print $1}'
1212}
1313
14- get_git_sha () {
15- repo=$1
16- branch=$2
17- branch_file=" ${repo} /${branch} "
18- cat $branch_file
19- }
20-
2114indent () {
2215 echo " $@ "
2316}
@@ -35,7 +28,7 @@ puts-warn() {
3528}
3629
3730usage () {
38- echo " Usage: $0 <user> <repo> <branch >"
31+ echo " Usage: $0 <user> <repo> <sha >"
3932}
4033
4134if [ $# -ne $ARGS ]; then
4538
4639USER=$1
4740REPO=$2
48- BRANCH=$3
41+ GIT_SHA=$3
42+ SHORT_SHA=${GIT_SHA: 0: 8}
4943APP_NAME=$( get_app_name $REPO )
5044
5145cd $( dirname $0 ) # ensure we are in the root dir
@@ -56,10 +50,6 @@ REPO_DIR="${ROOT_DIR}/${REPO}"
5650BUILD_DIR=" ${REPO_DIR} /build"
5751CACHE_DIR=" ${REPO_DIR} /cache"
5852
59- # get git sha of branch
60- GIT_SHA=$( get_git_sha $REPO_DIR $BRANCH )
61- SHORT_SHA=${GIT_SHA: 0: 8}
62-
6353# define image names
6454IMAGE_NAME=" $APP_NAME :git-$SHORT_SHA "
6555TMP_IMAGE=" {{ .deis_registry_host }}:{{ .deis_registry_port }}/$IMAGE_NAME "
@@ -70,8 +60,7 @@ mkdir -p $BUILD_DIR $CACHE_DIR
7060TMP_DIR=$( mktemp -d --tmpdir=$BUILD_DIR )
7161
7262cd $REPO_DIR
73- # extract git branch
74- git archive $BRANCH | tar -xmC $TMP_DIR
63+ git archive $GIT_SHA | tar -xmC $TMP_DIR
7564
7665# switch to app context
7766cd $TMP_DIR
Original file line number Diff line number Diff line change @@ -35,37 +35,26 @@ case "$1" in
3535cat | $SELF pre-receive
3636EOF
3737 chmod +x $PRERECEIVE_HOOK
38- POSTRECEIVE_HOOK=" $REPO_PATH /hooks/post-receive"
39- # inject a post-receive hook
40- cat > $POSTRECEIVE_HOOK << EOF
41- #!/bin/bash
42- cat | $SELF post-receive
43- EOF
44- chmod +x $POSTRECEIVE_HOOK
38+ # call the original git-shell
4539 git-shell -c " $SSH_ORIGINAL_COMMAND "
4640 ;;
4741
4842 pre-receive)
4943 while read oldrev newrev refname
5044 do
45+ # check for authorization on this repo
5146 $GITHOME /receiver " $RECEIVE_REPO " " $newrev " " $RECEIVE_USER " " $RECEIVE_FINGERPRINT "
5247 rc=$?
5348 if [[ $rc != 0 ]] ; then
5449 echo " ERROR: failed on rev $newrev - push denied"
5550 exit $rc
5651 fi
57- done
58- ;;
59-
60- post-receive)
61- while read oldrev newrev refname
62- do
6352 # builder assumes that we are running this script from $GITHOME
6453 cd $GITHOME
6554 # if we're processing a receive-pack on an existing repo, run a build
6655 if [[ $SSH_ORIGINAL_COMMAND == git-receive-pack* ]]; then
6756 # SECURITY: git user runs the builder as root (for docker access)
68- sudo $GITHOME /builder $RECEIVE_USER $RECEIVE_REPO $refname 2>&1 | strip_remote_prefix
57+ sudo $GITHOME /builder $RECEIVE_USER $RECEIVE_REPO $newrev 2>&1 | strip_remote_prefix
6958 fi
7059 done
7160 ;;
You can’t perform that action at this time.
0 commit comments