1
A
回答
1
使用最近SharpSvn版本中,您可以使用
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PreCommit, false, out ha))
{
Console.Error.WriteLine("Invalid arguments");
Environment.Exit(1);
}
解析一个pre-commit钩子的参数,然后使用
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)
{
}
}
去日志消息,改文件等
5
之前就存在,我不知道SharpSVN,但是如果你创建了一个钩子脚本为你描述,你作为参数%回购%和%TXN%
有了这些数据可以查看给定存储库的事务(%txn%)。通常你通过使用
svnlook -t %txn% %repo%
然后你会得到日志消息。
所以你应该在sharpSVN接口中寻找一个相当于svnlook的东西。
1
我刚刚完成了自己构建挂钩应用程序的过程,并且SharpSVN不需要查看提交消息。假设你已经建立了自己已经是一个控制台应用程序,试试这个代码svnlook.exe直接调用:
string repos = args[0];
string txn = args[1];
var processStartInfo = new ProcessStartInfo
{
FileName = "svnlook.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("log -t \"{0}\" \"{1}\"", txn, repos)
};
Process process = Process.Start(processStartInfo);
string message = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return message;
确保svnlook.exe的位置添加到您机器的PATH环境变量,因此,上述罐从任何位置执行。
2
前段时间我写了一个svnlook.exe的C#包装器。我使用这个发送提交消息给bug跟踪器(如果提供了ticket id)。在下面找到它,也许它对你有用。
/// <summary>
/// Encapsulates the SVNLook command in all of it's flavours
/// </summary>
public static class SvnLookCommand
{
/// <summary>
/// The string "" used as parameter for the svnlook.exe
/// </summary>
private static readonly string AUTHOR = "author";
/// <summary>
/// The string "cat" used as parameter for the svnlook.exe
/// </summary>
private static readonly string CAT = "cat";
/// <summary>
/// The string "changed" used as parameter for the svnlook.exe
/// </summary>
private static readonly string CHANGED = "changed";
/// <summary>
/// The string "date" used as parameter for the svnlook.exe
/// </summary>
private static readonly string DATE = "date";
/// <summary>
/// The string "diff" used as parameter for the svnlook.exe
/// </summary>
private static readonly string DIFF = "diff";
/// <summary>
/// The string "dirs-changed" used as parameter for the svnlook.exe
/// </summary>
private static readonly string DIRSCHANGED = "dirs-changed";
/// <summary>
/// The string "history" used as parameter for the svnlook.exe
/// </summary>
private static readonly string HISTORY = "history";
/// <summary>
/// The string "info" used as parameter for the svnlook.exe
/// </summary>
private static readonly string INFO = "info";
/// <summary>
/// The string "lock" used as parameter for the svnlook.exe
/// </summary>
private static readonly string LOCK = "lock";
/// <summary>
/// The string "log" used as parameter for the svnlook.exe
/// </summary>
private static readonly string LOG = "log";
/// <summary>
/// The string "tree" used as parameter for the svnlook.exe
/// </summary>
private static readonly string TREE = "tree";
/// <summary>
/// The string "uuid" used as parameter for the svnlook.exe
/// </summary>
private static readonly string UUID = "uuid";
/// <summary>
/// The string "youngest" used as parameter for the svnlook.exe
/// </summary>
private static readonly string YOUNGEST = "youngest";
/// <summary>
/// The full path of the svnlook.exe binary
/// </summary>
private static string commandPath = String.Empty;
/// <summary>
/// Initializes static members of the <see cref="SvnLookCommand"/> class.
/// </summary>
static SvnLookCommand()
{
commandPath = Settings.Default.SvnDirectoryPath;
if (!Path.IsPathRooted(commandPath))
{
Assembly entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null)
{
commandPath = new FileInfo(entryAssembly.Location).Directory.ToString() + Path.DirectorySeparatorChar + commandPath;
}
}
if (!commandPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
commandPath = commandPath + Path.DirectorySeparatorChar;
}
commandPath += "svnlook.exe";
}
/// <summary>
/// Gets the process info to start a svnlook.exe command with parameter "author"
/// </summary>
/// <param name="repository">The repository.</param>
/// <param name="revision">The revision.</param>
/// <returns>Gets the author of the revision in scope</returns>
public static ProcessStartInfo GetAuthor(string repository, string revision)
{
ProcessStartInfo svnLookProcessStartInfo = new ProcessStartInfo(commandPath);
svnLookProcessStartInfo.Arguments = String.Format("{0} {1} -r {2}", AUTHOR, repository, revision);
return svnLookProcessStartInfo;
}
/// <summary>
/// Gets the process info to start a svnlook.exe command with parameter "log"
/// </summary>
/// <param name="repository">The repository.</param>
/// <param name="revision">The revision.</param>
/// <returns>The svn log of the revision in scope</returns>
public static ProcessStartInfo GetLog(string repository, string revision)
{
ProcessStartInfo svnLookProcessStartInfo = new ProcessStartInfo(commandPath);
svnLookProcessStartInfo.Arguments = String.Format("{0} {1} -r {2}", LOG, repository, revision);
return svnLookProcessStartInfo;
}
/// <summary>
/// Gets the process info to start a svnlook.exe command with parameter "changed"
/// </summary>
/// <param name="repository">The repository.</param>
/// <param name="revision">The revision.</param>
/// <returns>The change log of the revision in scope</returns>
public static ProcessStartInfo GetChangeLog(string repository, string revision)
{
ProcessStartInfo svnLookProcessStartInfo = new ProcessStartInfo(commandPath);
svnLookProcessStartInfo.Arguments = String.Format("{0} {1} -r {2}", CHANGED, repository, revision);
return svnLookProcessStartInfo;
}
/// <summary>
/// Gets the process info to start a svnlook.exe command with parameter "info"
/// </summary>
/// <param name="repository">The repository.</param>
/// <param name="revision">The revision.</param>
/// <returns>The info of the revision in scope</returns>
public static ProcessStartInfo GetInfo(string repository, string revision)
{
ProcessStartInfo svnLookProcessStartInfo = new ProcessStartInfo(commandPath);
svnLookProcessStartInfo.Arguments = String.Format("{0} {1} -r {2}", INFO, repository, revision);
return svnLookProcessStartInfo;
}
}
+0
的svnlook命令用于共享代码和工作 – balexandre 2009-09-09 07:05:55
相关问题
- 1. 如何使用SharpSVN访问预提交钩子中的文件信息
- 2. svn提交消息
- 3. 使用sharpsvn API从ASP.Net访问Visual SVN
- 4. sharpsvn提交问题
- 5. 预先提交的SVN更改属性
- 6. 如何在c#中使用SharpSVN库设置SVN提交作者
- 7. 强制SVN提交“消息”?
- 8. SVN提交与消息
- 9. 预先接收钩子 - 如何获取提交消息
- 10. 用SharpSVN在C#中预先提交钩子
- 11. 避免SVN提交中未经过预先测试的提交
- 12. SVN需要锁定检查使用预先提交的钩子
- 13. 使用SharpSvn编写预先提交的钩子。它缺乏svnlook propget吗?
- 14. SVN控制提交访问
- 15. 使用sharpsvn获取乌龟svn提交任务的taskid
- 16. 在CVS预提交钩子中使用提交消息
- 17. SVN预先提交问题 - 无法获得参数
- 18. 提交sharpSVN
- 19. 如何访问Mercurial进程内挂钩中的提交消息?
- 20. SVN提交失败,错误消息
- 21. Git预先提交钩子检查消息
- 22. 在svn中用户定义的预先提交钩子?
- 23. 用sharpsvn更改提交的svn修订版
- 24. Android:如何预先填充SMS消息
- 25. 在sharpsvn中提交的问题
- 26. SVN - 通过VIM提交 - 恢复失败提交消息
- 27. 使用Perl构建SVN后提交钩子:IRC Bot打印提交消息
- 28. 如何从提交消息中删除svn url?
- 29. 如何创建SVN提交消息模板并挂钩验证
- 30. SVN预先提交:当提交进行时获取url的名称
是的,我已经做到了。我甚至问过关于该语法的问题,但回来:http://stackoverflow.com/questions/1258191/sharpsvn-svnlookclient 不幸的是使用SharpSVN的SVNLook没有工作。它没有得到日志消息(它怎么可能?它甚至存储在SVN中的txn = 486-1? 然而,我没有深入研究这个问题,并最终完成了它你说,将数据发送到一个文件: %svnlook的日志%-t%TXN%%REPOS%>%LOG_FILE% %〜dp0MyExeThatDoesOtherStuff.exe%LOG_FILE% – KevinDeus 2009-09-05 00:15:21
最近SharpSvn版本具有复制功能的SvnLookClient .Net – 2009-09-08 19:57:32