Explorar el Código

Fix post-update to match production

Oz N Tiram hace 9 años
padre
commit
897c96157a
Se han modificado 1 ficheros con 8 adiciones y 3 borrados
  1. 8 3
      hooks/post-update.sh

+ 8 - 3
hooks/post-update.sh

@@ -30,15 +30,20 @@ for HEAD in $@; do
 	#BRANCH=${BRANCH[2]}
 	REST_OF_JSON=$(git --no-pager log -n 1 --format='{"hashes":{"commit":"%H", "tree":"%T", "parents":"%P" }, "author":{"date": "%ai", "name":"%an", "email":"%ae" }, "committer":{"date": "%ci", "name": "%cn", "email":"%ce" }')
 	REST_OF_JSON=$REST_OF_JSON,\"branch\":\""${BRANCH}"\"
-	#REST_OF_JSON=$REST_OF_JSON,\"giturl\":\"$GITURL\""}"
+	#REST_OF_JSON=$REST_OF_JSON,\"giturl\":\"$GITURL\"
 	JSON_TO_SUBMIT=$JSON_TO_SUBMIT{\"$BRANCH\":$REST_OF_JSON\}
-	JSON_TO_SUBMIT=$JSON_TO_SUBMIT,\\n
+	JSON_TO_SUBMIT=$JSON_TO_SUBMIT}
 	REST_OF_JSON=""
 done
 
+t=`mktemp`
+echo $JSON_TO_SUBMIT > $t
 # Calculate the digest of JSON
 SECRET=$(echo -n $JSON_TO_SUBMIT | openssl dgst -sha1 -hmac $SECRET_KEY)
 SECRET=`echo $SECRET | cut -d'=' -f2`
 # TODO: Consider submiting to HTTPS!
 # Github uses X-Hub-Signature, we use X-Secret
-curl  -H "Content-Type: application/json" -H "X-Secret:${SECRET}" -X POST http://${SUBMIT_HOST}:${SUBMIT_PORT}/ -d ${JSON_TO_SUBMIT}
+curl -H "Content-Type: application/json" -H "X-Secret:${SECRET}" -X POST http://${SUBMIT_HOST}:${SUBMIT_PORT}/ --data @$t
+if [ $? -eq 0 ]; then
+   rm $t
+fi