Created
February 4, 2012 00:39
-
-
Save anaisbetts/1734073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="true" language="C#" #> | |
<#@ import namespace="System.IO" #> | |
<#@ output extension=".cs" #> | |
using System; | |
using System.Windows; | |
<# | |
var pathEntries = System.Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator); | |
FileInfo gitFileInfo = null; | |
foreach(var item in pathEntries) { | |
var fi = new FileInfo(Path.Combine(item, "git.cmd")); | |
if (fi.Exists) { | |
gitFileInfo = fi; | |
break; | |
} | |
} | |
var psi = new System.Diagnostics.ProcessStartInfo(gitFileInfo.FullName, "show-ref HEAD") { | |
WorkingDirectory = Host.ResolvePath(""), | |
RedirectStandardOutput = true, | |
CreateNoWindow = true, | |
UseShellExecute = false, | |
}; | |
var proc = System.Diagnostics.Process.Start(psi); | |
proc.WaitForExit(); | |
var commit = proc.StandardOutput.ReadToEnd(); | |
var commitLine = commit.Split('\n')[2]; | |
var commitValue = commitLine.Split(' ')[0]; | |
#> | |
namespace MyCoolApplication | |
{ | |
public partial class App : Application | |
{ | |
public const string VersionSHA1 = @"<#= commitValue #>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment