Created
January 26, 2013 20:43
-
-
Save williscool/4644509 to your computer and use it in GitHub Desktop.
Git lab references post commit hook
This file contains 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
#!/bin/sh | |
PRIVATE_TOKEN="YOU_SECRET_TOKEN" | |
GITLAB_URL="http://gitlab.example.com/" | |
URL=`git config --get remote.origin.url` | |
PROJECT=`basename ${URL} .git | cut -d':' -f2` | |
COMMIT_MSG="git log -1 HEAD" | |
COMMIT_HASH_MSG=`git log -1 HEAD | head -1` | |
for issue_id in `${COMMIT_MSG} | grep -o -e "\(closes\|fixes\) #[0-9]\+" | cut -d'#' -f2`; do | |
curl -X POST -d "body=fixed in ${COMMIT_HASH_MSG}" \ | |
${GITLAB_URL}api/v3/projects/${PROJECT}/issues/${issue_id}/notes/?private_token=${PRIVATE_TOKEN} | |
done | |
for issue_id in `${COMMIT_MSG} | grep -o -e "\(re\|refs\) #[0-9]\+" | cut -d'#' -f2`; do | |
curl -X POST -d "body=refenced in ${COMMIT_HASH_MSG}" \ | |
${GITLAB_URL}api/v3/projects/${PROJECT}/issues/${issue_id}/notes/?private_token=${PRIVATE_TOKEN} | |
done |
Moral of the story backtick placement is important
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dont forget to make it executable with
chmod +x .git/hooks/post-commit