2013-11-15 43 views
1

我已经用google搜索了一个小时,但还没有找到解决方案。有没有办法编写一个GIT钩子,将来自提交的git消息放入SQL Server数据库的postreceive?我想要做的就是在我的数据库中存储一个包含所有提交的表,并且非常像bitbuckets问题跟踪器,如果提交消息类似于“关闭问题#2”,我想在另一个表中关闭问题。GIT钩子更新提交的T-SQL数据库

+0

它现在的样子,我不知道这个问题是非常适合堆栈溢出。你选择了一种编程语言来编写钩子吗?你到目前为止有什么?你面临什么问题? –

+0

@ÁlvaroG.Vicario我只熟悉GIT的默认钩子,我不知道你可以使用不同的编程语言。我在Windows环境中运行。至于我所面临的问题,我不知道如何编写问题所示的钩子。 – aaronmallen

回答

1

如果你有一个知道如何更新你的sql server数据库的脚本,那么这是一个编写post-receive钩子的问题,它为每个收到的提交收集日志消息。

您可以采取的想法:

  • git post-receive hook that grabs commit messages and posts back to URL”。
    提取物:

    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
    提取物:

    text = `#{GIT} log --all --since='#{revtime}' --reverse` 
    
  • fogbugz-git-integration”,这是接近你在找什么,因为它解析提交信息,寻找特定关键字。
    提取物:

    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 
         ...