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