I have googled this for an hour now and have yet to find a solution. Is there a way to write a GIT hook that will put the git message from a commit into a SQL Server database on postreceive? What I'd like to do is store a table in my database with all my commits, and much like bitbuckets issue tracker, I would like to close issues in another table if the commit message is something like "close issue #2".
Asked
Active
Viewed 546 times
2
-
The way it's now, I'm not sure this question is a good fit for Stack Overflow. Have you chosen a programming language to write the hook? What have you got so far? What problems are you facing? – Álvaro González Nov 18 '13 at 17:50
-
@ÁlvaroG.Vicario I'm only familiar with the default hooks for GIT, I was unaware you could use different programming languages. I'm running in a windows environment. As far as the problems I'm facing I have no idea how to write the hook as the question indicates. – aaronmallen Nov 18 '13 at 19:31
1 Answers
1
If you have a script which knows how to update your sql server database, then it is a matter of writing a post-receive hook which collect the log message for each received commit.
You can take an idea in:
"git post-receive hook that grabs commit messages and posts back to URL".
Extract:for revision in `git rev-parse --not $other_branches | git rev-list --stdin $revspec`; do # I don't know if you need to url-escape the content # Also you may want to transmit the data in a POST request, wget "http://server.com/logthis.asp?msg=$(git log $revision~1..$revision)" done
campfire post-receive hook.
Extract:text = `#{GIT} log --all --since='#{revtime}' --reverse`
"
fogbugz-git-integration
", which is close to what you are looking for, as it parses the commit message, looking for certain keywords.
Extract:git log $oldrev..$newrev --pretty=format:~~CommitSubject:%s%n~~CommitHash:%H%n~~EOR%n | while read logentry; do # Parse out the commit subject if [ "${logentry:0:15}" == "~~CommitSubject" ]; then ...