【问题标题】:GIT hook updated T-SQL database on commitGIT 钩子在提交时更新了 T-SQL 数据库
【发布时间】:2023-03-06 04:34:01
【问题描述】:

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

【问题讨论】:

  • 现在的情况,我不确定这个问题是否适合 Stack Overflow。您是否选择了一种编程语言来编写钩子?到目前为止你有什么?您面临什么问题?
  • @ÁlvaroG.Vicario 我只熟悉 GIT 的默认挂钩,我不知道您可以使用不同的编程语言。我在windows环境下运行。至于我面临的问题,我不知道如何编写问题所示的钩子。

标签: git tsql sql-server-2005 githooks git-post-receive


【解决方案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
           ...
    

【讨论】:

    猜你喜欢
    • 2013-12-15
    • 1970-01-01
    • 2019-01-09
    • 2012-06-06
    • 2016-04-02
    • 2019-07-12
    • 2015-01-13
    • 2018-05-21
    相关资源
    最近更新 更多