简体   繁体   English

在SVN提交之前捕获数据

[英]Capturing Data before SVN Commit

We have bug system where users can file bugs. 我们有bug系统,用户可以在其中提交错误。 Once a bug is resolved through a code checkin we have to manually go and update the bug to the revision number. 一旦通过代码签入解决了错误,我们必须手动将错误更新到修订号。

I was looking for a way where before the checkin occurs, it will ask the user to fill some details like status change of the bug etc which will be added to to the bug through its api. 我正在寻找一种方式,在签入之前,它会要求用户填写一些细节,如bug等状态更改,这些将通过其api添加到bug中。

Only after a success the commit will occur. 只有在成功之后才会发生提交。 Is this possible. 这可能吗。

As far as "asking the user for details"... no, or at least not easily unless you have tools that integrate with your bug tracking system that can capture that when committing (TortoiseSVN can integrate with some, I think...). 至于“向用户询问详细信息”......不,或者至少不容易,除非你有与你的bug跟踪系统集成的工具,可以在提交时捕获它(TortoiseSVN可以与某些集成,我认为......) 。

What you can do is require/suggest the user to put the required information in the commit message. 可以做的是要求/建议用户将所需信息放在提交消息中。

Then you write a post-commit-hook to parse the comments to get the bug tracking number, status change, etc. and then use that with the bug system API to update the items. 然后你编写一个post-commit-hook来解析注释以获取bug跟踪号,状态变化等,然后将其与bug系统API一起使用来更新项目。

This is exactly what we have done to integrate SVN with OnTime. 这正是我们将SVN与OnTime集成的方法。

Example commit message: 示例提交消息:

E1234 added the code to enhance the enhancement. E1234添加了代码以增强增强功能。

The post-commit-hook reads the commit information, finds the E1234 , and looks up the item using the API. post-commit-hook读取提交信息,找到E1234 ,并使用API​​查找项目。 We also update fields with the full commit information, such as revision, user, and file paths. 我们还使用完整的提交信息更新字段,例如修订,用户和文件路径。

Rough idea of what this could look like in C#: 粗略了解C#中的情况:

  static void Main(string[] args)
  {
        string sRepository = "file:///" + args[0]; //might need to flip the \
        int nRevision = int.Parse(args[1]);

        //use SVN commands or library to get commit information
        //from sRepository for nRevision

        string pattern = @"\b[DFET][0-9]+\b";
        MatchCollection matches = Regex.Matches(log.log, pattern);
        foreach (Match thisMatch in matches)
        {
           //find the matching bug tracking items
           //and update using your API
        }
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM