From b3372c1b7c1f5313c304188e2702804d873b4268 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 20:54:32 +0100 Subject: [PATCH 1/2] (#45) Make it clear when are error has happened When trying to grab the branch name, make it very clear that it hasn't been able to get it, and also report the version of git which is currently being used. --- .../Content/localbuild.cake | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Chocolatey.Cake.Recipe/Content/localbuild.cake b/Chocolatey.Cake.Recipe/Content/localbuild.cake index f50b453..6adbf70 100644 --- a/Chocolatey.Cake.Recipe/Content/localbuild.cake +++ b/Chocolatey.Cake.Recipe/Content/localbuild.cake @@ -77,6 +77,9 @@ public class LocalBuildRepositoryInfo : IRepositoryInfo } else { + context.Information("What version of git are we using..."); + context.StartProcess("git", new ProcessSettings { Arguments = "--version" }); + context.Information("Getting current branch name..."); IEnumerable redirectedStandardOutput; IEnumerable redirectedError; @@ -101,6 +104,25 @@ public class LocalBuildRepositoryInfo : IRepositoryInfo context.Information("Branch name is {0}", Branch); } } + else + { + context.Error("Unable to find branch name!"); + context.Information("Writing out standard out..."); + var standardOutLines = redirectedStandardOutput.ToList(); + foreach (var standardOutLine in standardOutLines) + { + context.Information(standardOutLine); + } + + context.Information("Writing out standard error..."); + var standardErrorLines = redirectedError.ToList(); + foreach (var standardErrorLine in standardErrorLines) + { + context.Information(standardErrorLine); + } + + Branch = "unknown"; + } Name = "Local"; Tag = new LocalBuildTagInfo(context); From c6e5d63cd61ee30ece0453748f9823a61a4e7a15 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 3 May 2022 20:54:58 +0100 Subject: [PATCH 2/2] (maint) Fix string formatting There was an extra - in the generated string. --- Chocolatey.Cake.Recipe/Content/gitversion.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chocolatey.Cake.Recipe/Content/gitversion.cake b/Chocolatey.Cake.Recipe/Content/gitversion.cake index b89966b..1e67218 100644 --- a/Chocolatey.Cake.Recipe/Content/gitversion.cake +++ b/Chocolatey.Cake.Recipe/Content/gitversion.cake @@ -125,7 +125,7 @@ public class BuildVersion prerelease, prerelease == "alpha" || prerelease == "beta" ? buildDate : string.Empty, BuildParameters.BuildCounter != "-1" ? string.Format("-{0}", BuildParameters.BuildCounter) : string.Empty); - informationalVersion = string.Format("{0}-{1}-{2}-{3}", majorMinorPatch, prerelease, buildDate, sha); + informationalVersion = string.Format("{0}-{1}{2}-{3}", majorMinorPatch, prerelease, buildDate, sha); context.Information("There is no tag."); } else