简体   繁体   中英

Capturing Data before SVN Commit

We have bug system where users can file bugs. 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.

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

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.

This is exactly what we have done to integrate SVN with OnTime.

Example commit message:

E1234 added the code to enhance the enhancement.

The post-commit-hook reads the commit information, finds the E1234 , and looks up the item using the 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#:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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