은 내가으로 설정할 수 있습니다 모든 %의 repos 것을 볼 % 및 % TXN %SharpSVN을 사용하여 SVN 사전 커밋 메시지에 액세스하려면 어떻게해야합니까?
나는 내 경우에는 (커밋 메시지에 도착하는 사람들을 사용할 수 있습니다, 그래서 내가 이렇게 내가 볼 수있는 티켓 번호를 구문 분석 할 수있는 방법 이
은 내가으로 설정할 수 있습니다 모든 %의 repos 것을 볼 % 및 % TXN %SharpSVN을 사용하여 SVN 사전 커밋 메시지에 액세스하려면 어떻게해야합니까?
나는 내 경우에는 (커밋 메시지에 도착하는 사람들을 사용할 수 있습니다, 그래서 내가 이렇게 내가 볼 수있는 티켓 번호를 구문 분석 할 수있는 방법 이
당신은 사전 커밋 후크의 인수를 구문 분석
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PreCommit, 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)
{
}
}
을 사용할 수 있습니다 파일 등
) 그것을 커밋하기 전에 버그 데이터베이스에 존재하는 경우 나는 당신이 설명하는대로 후크 스크립트를 만들 경우, 당신은 인수 %의 repos로 얻을 SharpSVN를 모르는 % 및 % TXN % 다음으로
데이터는 주어진 저장소의 트랜잭션 (% txn %)을 조사 할 수 있습니다. 일반적으로 다음을 사용하여이 작업을 수행하십시오.
svnlook -t %txn% %repo%
그러면 로그 메시지가 나타납니다.
그래서 sharpSVN 인터페이스에서 svnlook과 동일한 기능을 찾아야합니다.
나는 스스로 훅 앱을 만드는 과정을 밟았으며 SharpSVN은 커밋 메시지를 보는 데 필요하지 않습니다.
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의 위치가 상기 할 수 있도록 컴퓨터의 경로 환경 변수에 추가되어 있는지 확인합니다 : 당신은 이미 자신에게 콘솔 응용 프로그램을 구축했습니다 가정하면, svnlook.exe 직접 호출이 코드를 시도 어느 위치에서나 실행될 수 있습니다.
얼마 전에 svnlook.exe에 대한 C# 래퍼를 작성했습니다. 이 코드를 사용하여 버그 추적기에 커밋 메시지를 보냈습니다 (티켓 ID가 제공된 경우). 아래에서 찾으십시오, 아마 당신에게 유용 할 것입니다. 최근 SharpSvn 릴리스를 사용
/// <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;
}
}
+1 공유 코드 및 작업 – balexandre
예, 이미 했어요. 나는 그 문법에 관한 질문을 잠시 뒤로 물었다 : http://stackoverflow.com/questions/1258191/sharpsvn-svnlookclient 불행히도 SharpSVN의 SVNLook을 사용하면 작동하지 않았다. 로그 메시지를 얻지 못했습니다 (어떻게 될까요? txn = 486-1? 지점에 SVN에 저장되어 있습니까?) 그러나 나는 그 문제에 대해 깊이 파고 들지 않았습니다. 당신은 파일에 데이터를 전송 말했다 % SVNLOOK %의 로그 -t % TXN % % REPOS %> % LOG_FILE % % ~ dp0MyExeThatDoesOtherStuff.exe % LOG_FILE % – KevinDeus
최근 SharpSvn 버전은 기능을 복제하는 SvnLookClient이 NET에서 svnlook 명령의 –