Browse Source

Fixed UpdateAssemblyInfo error when git repository exists but git.exe cannot be found.

pull/26/merge
Daniel Grunwald 14 years ago
parent
commit
b6fe975de1
  1. 16
      src/Tools/UpdateAssemblyInfo/Main.cs

16
src/Tools/UpdateAssemblyInfo/Main.cs

@ -203,8 +203,12 @@ namespace UpdateAssemblyInfo
{ {
if (revisionNumber == null) { if (revisionNumber == null) {
if (Directory.Exists(".git")) { if (Directory.Exists(".git")) {
ReadRevisionNumberFromGit(); try {
ReadBranchNameFromGit(); ReadRevisionNumberFromGit();
ReadBranchNameFromGit();
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
} else { } else {
Console.WriteLine("There's no git working copy in " + Path.GetFullPath(".")); Console.WriteLine("There's no git working copy in " + Path.GetFullPath("."));
} }
@ -234,10 +238,12 @@ namespace UpdateAssemblyInfo
} }
revNum++; revNum++;
} }
revisionNumber = revNum.ToString();
p.WaitForExit(); p.WaitForExit();
if (p.ExitCode != 0) if (p.ExitCode != 0)
throw new Exception("git-rev-list exit code was " + p.ExitCode); throw new Exception("git-rev-list exit code was " + p.ExitCode);
// Only set revisionNuber once we ensured the operation was successful,
// so that we retrieve the number from the REVISION file in case of errors
revisionNumber = revNum.ToString();
} }
} }
@ -277,11 +283,11 @@ namespace UpdateAssemblyInfo
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Build continues with revision number '0'..."); Console.WriteLine("Build continues with revision number '0'...");
revisionNumber = "0"; revisionNumber = null;
gitCommitHash = "0000000000000000000000000000000000000000";
} }
if (revisionNumber == null || revisionNumber.Length == 0) { if (revisionNumber == null || revisionNumber.Length == 0) {
revisionNumber = "0"; revisionNumber = "0";
gitCommitHash = "0000000000000000000000000000000000000000";
//throw new ApplicationException("Error reading revision number"); //throw new ApplicationException("Error reading revision number");
} }
} }

Loading…
Cancel
Save