2009-09-04 13 views

答えて

1

ファイルなど

5

)それにコミットする前にバグデータベースに存在する場合、私はあなたが説明するように、あなたがフックスクリプトを作成する場合しかし、あなたは、引数%レポ取引として取得し、SharpSVNを知らない%と%TXN%これらにより

データでは、指定されたリポジトリのトランザクション(%txn%)を調べることができます。通常は次のようにして行います。

svnlook -t %txn% %repo% 

ログメッセージが表示されます。

したがって、sharpSVNインターフェイスでsvnlookと同等のものを探す必要があります。

+0

ええ、私はすでにやった。私はその構文についての質問をしばらく前に聞いたこともある:http://stackoverflow.com/questions/1258191/sharpsvn-svnlookclient 残念ながら、SharpSVNのSVNLookを使用してもうまくいきませんでした。それはログメッセージを取得できませんでした(どのように?それはtxn = 486-1? の時点でSVNにも格納されていますか?しかし、私はその問題を深く掘り下げずに、あなたは、ファイルにデータを送信し、言った: %SVNLOOK%のログ-t%TXN%%REPOS%>%LOG_FILE% %〜dp0MyExeThatDoesOtherStuff.exe%LOG_FILE% – KevinDeus

+2

最近SharpSvnのバージョンでは、機能を複製SvnLookClientを持っています.Netのsvnlookコマンドの詳細 –

1

私はちょうどフックアプリを自分で作成するプロセスを経て、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直接呼び出して、このコードを試してみてくださいどの場所からでも実行できます。

2

私は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 &quot;&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string AUTHOR = "author"; 

    /// <summary> 
    /// The string &quot;cat&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string CAT = "cat"; 

    /// <summary> 
    /// The string &quot;changed&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string CHANGED = "changed"; 

    /// <summary> 
    /// The string &quot;date&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string DATE = "date"; 

    /// <summary> 
    /// The string &quot;diff&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string DIFF = "diff"; 

    /// <summary> 
    /// The string &quot;dirs-changed&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string DIRSCHANGED = "dirs-changed"; 

    /// <summary> 
    /// The string &quot;history&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string HISTORY = "history"; 

    /// <summary> 
    /// The string &quot;info&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string INFO = "info"; 

    /// <summary> 
    /// The string &quot;lock&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string LOCK = "lock"; 

    /// <summary> 
    /// The string &quot;log&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string LOG = "log"; 

    /// <summary> 
    /// The string &quot;tree&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string TREE = "tree"; 

    /// <summary> 
    /// The string &quot;uuid&quot; used as parameter for the svnlook.exe 
    /// </summary> 
    private static readonly string UUID = "uuid"; 

    /// <summary> 
    /// The string &quot;youngest&quot; 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 &quot;author&quot; 
    /// </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 &quot;log&quot; 
    /// </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 &quot;changed&quot; 
    /// </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 &quot;info&quot; 
    /// </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

+1とコードの共有 – balexandre

関連する問題