私が設定できるのは、%repos%と%txn%SharpSVNを使用してSVNプリコミットメッセージにアクセスするにはどうすればよいですか?
です。コミットメッセージにアクセスするにはどうすればよいですか(私の場合はチケット番号を解析できるので、それは
私が設定できるのは、%repos%と%txn%SharpSVNを使用してSVNプリコミットメッセージにアクセスするにはどうすればよいですか?
です。コミットメッセージにアクセスするにはどうすればよいですか(私の場合はチケット番号を解析できるので、それは
ファイルなど
)それにコミットする前にバグデータベースに存在する場合、私はあなたが説明するように、あなたがフックスクリプトを作成する場合しかし、あなたは、引数%レポ取引として取得し、SharpSVNを知らない%と%TXN%これらにより
データでは、指定されたリポジトリのトランザクション(%txn%)を調べることができます。通常は次のようにして行います。
svnlook -t %txn% %repo%
ログメッセージが表示されます。
したがって、sharpSVNインターフェイスでsvnlookと同等のものを探す必要があります。
私はちょうどフックアプリを自分で作成するプロセスを経て、SharpSVNはコミットメッセージを見るために必要ではありません。 svnlook.exeの場所は、上記のことができるようにあなたのマシンのPATH環境変数に追加されていることを確認し
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のC#ラッパーを書きました。私はバグトラッカー(チケットIDが提供されている場合)にコミットメッセージを送信するためにこれを使用しました。下にそれを見つける、多分それはあなたのために便利です。
あなたは事前にコミットフックの引数を解析して、ログメッセージを取得する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)
{
}
}
を使用する
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PreCommit, false, out ha))
{
Console.Error.WriteLine("Invalid arguments");
Environment.Exit(1);
}
を使用することができ、最近の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コマンドの詳細 –