From 92cdec05521001ebf84851e7c741d06d2c13384e Mon Sep 17 00:00:00 2001 From: serras Date: Wed, 29 Feb 2012 21:18:03 +0100 Subject: [PATCH] Add default version when compiling without Git installed --- SparkleLib/windows/getversion.tt | 66 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/SparkleLib/windows/getversion.tt b/SparkleLib/windows/getversion.tt index 7aa89216..4ec956db 100644 --- a/SparkleLib/windows/getversion.tt +++ b/SparkleLib/windows/getversion.tt @@ -4,35 +4,45 @@ <#@ import namespace="System.Text.RegularExpressions" #> <# - // Add msysgit to path, as we cannot asume it is added to the path - // Asume it is installed in @"C:\msysgit\bin" for now - string MSysGit=@"C:\msysgit"; - - string newPath = MSysGit + @"\bin" + ";" - + MSysGit + @"\mingw\bin" + ";" - + MSysGit + @"\cmd" + ";" - + System.Environment.ExpandEnvironmentVariables ("%PATH%"); - System.Environment.SetEnvironmentVariable ("PATH", newPath); - - Process process = new Process(); - process.StartInfo.UseShellExecute = false; - process.StartInfo.RedirectStandardOutput = true; - process.StartInfo.CreateNoWindow = true; - process.StartInfo.FileName = "git"; - process.StartInfo.Arguments = "describe --tags"; - process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Host.TemplateFile); - process.Start(); - - String DescribeOutput=process.StandardOutput.ReadLine(); - - Match m = Regex.Match(DescribeOutput, @"(\d+)\.(\d+)(?:-rc(\d+))?-(\d+)"); - int[] version = new int [4]; - for(int i=1; i <= 4; i++) - Int32.TryParse(m.Groups[i].Value, out version[i-1]); + String VERSION; + String ASM_VERSION; + String ASM_FILE_VERSION; - String VERSION=DescribeOutput; - String ASM_VERSION=String.Format("{0}.{1}",version[0],version[1]); - String ASM_FILE_VERSION=String.Format("{0}.{1}.{2}.{3}",version[0],version[1],version[2],version[3]); + try { + // Add msysgit to path, as we cannot asume it is added to the path + // Asume it is installed in @"C:\msysgit\bin" for now + string MSysGit=@"C:\msysgit"; + + string newPath = MSysGit + @"\bin" + ";" + + MSysGit + @"\mingw\bin" + ";" + + MSysGit + @"\cmd" + ";" + + System.Environment.ExpandEnvironmentVariables ("%PATH%"); + System.Environment.SetEnvironmentVariable ("PATH", newPath); + + Process process = new Process(); + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.CreateNoWindow = true; + process.StartInfo.FileName = "git"; + process.StartInfo.Arguments = "describe --tags"; + process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Host.TemplateFile); + process.Start(); + + String DescribeOutput=process.StandardOutput.ReadLine(); + + Match m = Regex.Match(DescribeOutput, @"(\d+)\.(\d+)(?:-rc(\d+))?-(\d+)"); + int[] version = new int [4]; + for(int i=1; i <= 4; i++) + Int32.TryParse(m.Groups[i].Value, out version[i-1]); + + VERSION=DescribeOutput; + ASM_VERSION=String.Format("{0}.{1}",version[0],version[1]); + ASM_FILE_VERSION=String.Format("{0}.{1}.{2}.{3}",version[0],version[1],version[2],version[3]); + + } catch (Exception e) { + // Current defaults + VERSION = ASM_VERSION = ASM_FILE_VERSION = "0.8.3"; + } #>