Forum Discussion

ChrisPro's avatar
ChrisPro
Contributor
11 years ago

Display SVN version in log?

I would like to display in log message of "test complete" the svn version of my project.

Is ti possible?

1 Reply

  • Hi Chris,



    You can run the svn info command and parse its output. Here's how:



    function SVNInfo()

    {

      var strFileName = Project.FileName;

      var strSVNPath = "C:\\Program Files\\TortoiseSVN\\bin\\svn.exe";



      // Run "svn info" and wait for completion

      var strCommand = aqString.Quote(strSVNPath) + " info " + aqString.Quote(strFileName);

      var oExec = Sys.OleObject("WScript.Shell").Exec(strCommand);

      while (oExec.Status == 0)

      {

        Delay(100);

      }



      if (oExec.ExitCode == 0)

      {

        // Get "svn info" output

        var strInfo = oExec.StdOut.ReadAll();



        // Extract Revision and Last Changed Rev from the output

        var reRev = /^Revision: (\d+)$/im;

        var reLastRev = /^Last Changed Rev: (\d+)$/im;



        var strRev = strInfo.match(reRev)[1];

        var strLastRev = strInfo.match(reLastRev)[1];



        Log.Message("Revision: " + strRev);

        Log.Message("Last Changed Rev: " + strLastRev);

      }

      else

      {

        Log.Error("svn info error; see Additional Info", oExec.StdErr.ReadAll());

      }

    }