Domanda

vedo che tutto quello che posso impostato è% pronti contro termine% e% TXN%

come posso usare quelli per arrivare al messaggio di commit (nel mio caso, in modo che io possa analizzare fuori il numero del biglietto così posso vedere se esiste nel database dei bug prima di impegnarsi ad esso)

È stato utile?

Soluzione

Utilizzo di un recente SharpSvn rilascio è possibile utilizzare

SvnHookArguments ha; 
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PreCommit, false, out ha))
{
    Console.Error.WriteLine("Invalid arguments");
    Environment.Exit(1);  
}

per analizzare gli argomenti di un pre-commit hook e quindi utilizzare

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)
    {

    }
}

per arrivare al messaggio di log, file modificati, ecc.

Altri suggerimenti

Non so SharpSVN, se si crea uno script gancio come si descrive, si ottiene come argomenti% pronti contro termine% e% TXN%

Con questi dati si può guardare nella transazione (% TXN%) della data repository. Di solito si esegue questa operazione utilizzando

svnlook -t %txn%  %repo%

Poi si aprirà il registro-messaggi.

Quindi, si dovrebbe cercare un equivalente svnlook nell'interfaccia sharpSVN.

Qualche tempo fa ho scritto un C # wrapper per lo svnlook.exe. Ho usato questo per inviare messaggi di commit a un bug tracker (se è stato fornito un ID di biglietto). Chi cerca di sotto, forse è utile per voi.

/// <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;
    }
}

Ho appena passato attraverso il processo di costruzione di un ganci App me stesso e SharpSVN non è necessario per guardare messaggi di commit. Supponendo che hai costruito tu stesso una console app già, provare questo codice che chiama svnlook.exe direttamente:

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;

Assicurarsi che la posizione del svnlook.exe viene aggiunto alla variabile di ambiente percorso della vostra macchina in modo quanto sopra può essere eseguita da qualsiasi luogo.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top