How can I view the changes made after a revision is committed and parse it for comments?

拟墨画扇 提交于 2019-12-07 02:26:03

问题


I was hoping to automate some tasks related to SubVersion, so I got SharpSvn. Unfortunately I cant find much documentation for it.

I want to be able to view the changes after a user commits a new revision so I can parse the code for special comments that can then be uploaded into my ticket system.


回答1:


If you just want to browse SharpSvn you can use http://docs.sharpsvn.net/. The documentation there is far from complete as the focus is primarily on providing features. Any help on enhancing the documentation (or SharpSvn itself) is welcome ;-)

To use log messages for your issue tracker you can use two routes:

  1. A post-commit hook that processes changes one at a time
  2. A scheduled service that calls 'svn log -r <last-retrieved>:HEAD' every once in a while.

The last daily builds of SharpSvn have some support for commit hooks, but that part is not really api-stable yet.

You could create a post commit hook (post-commit.exe) with:

static void Main(string[] args)
{
  SvnHookArguments ha;
  if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PostCommit, false, out ha))
  {
    Console.Error.WriteLine("Invalid arguments");
    Environment.Exit(1);
  }

  using (SvnLookClient cl = new SvnLookClient())
  {
    SvnChangeInfoEventArgs ci;
    cl.GetChangeInfo(ha.LookOrigin, out ci);

    // ci contains information on the commit e.g.
    Console.WriteLine(ci.LogMessage); // Has log message

    foreach(SvnChangeItem i in ci.ChangedPaths)
    {
       //
    }
  }
}

(For a complete solution you would also have to hook the post-revprop-change, as your users might change the log message after the first commit)




回答2:


Is this of any use?

http://blogs.open.collab.net/svn/2008/04/sharpsvn-brings.html




回答3:


I wonder whether subversion hooks (at the svn server) might not be another approach here? I have not tried it, but CaptainHook appears to offer svn->.NET hook integration.



来源:https://stackoverflow.com/questions/293582/how-can-i-view-the-changes-made-after-a-revision-is-committed-and-parse-it-for-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!