void DetermineBundleHashes(Context context) { GitRunner git = CreateGitRunner(context); Log.StatusLine($" {context.Characters.Bullet} LibZip commit hash", ConsoleColor.Gray); FullLibZipHash = git.GetTopCommitHash(context.Properties.GetRequiredValue(KnownProperties.LibZipSourceFullPath), shortHash: false); LibZipHash = EnsureHash("LibZip", Utilities.ShortenGitHash(FullLibZipHash)); Log.StatusLine($" {context.Characters.Bullet} Mono commit hash", ConsoleColor.Gray); FullMonoHash = git.GetTopCommitHash(context.Properties.GetRequiredValue(KnownProperties.MonoSourceFullPath), shortHash: false); MonoHash = EnsureHash("Mono", Utilities.ShortenGitHash(FullMonoHash)); if (Configurables.Paths.BundleVersionHashFiles == null || Configurables.Paths.BundleVersionHashFiles.Count == 0) { Log.WarningLine("Bundle version hash files not specified"); return; } Log.StatusLine($" {context.Characters.Bullet} Generating bundle version hash", ConsoleColor.Gray); using (var ha = HashAlgorithm.Create(context.HashAlgorithm)) { HashFiles(ha, Configurables.Paths.BundleVersionHashFiles); VersionHash = FormatHash(ha.Hash).Substring(0, (int)Configurables.Defaults.AbbreviatedHashLength); Log.StatusLine(" Hash: ", VersionHash, tailColor: ConsoleColor.Cyan); } string EnsureHash(string name, string hash) { if (String.IsNullOrEmpty(hash)) { throw new InvalidOperationException($"Unable to determine {name} commit hash"); } Log.StatusLine(" Commit: ", hash, tailColor: ConsoleColor.Cyan); Log.StatusLine(); return(hash); } }
void DetermineBundleHashes(Context context) { GitRunner git = CreateGitRunner(context); Log.StatusLine($" {context.Characters.Bullet} LibZip commit hash", ConsoleColor.Gray); FullLibZipHash = git.GetTopCommitHash(context.Properties.GetRequiredValue(KnownProperties.LibZipSourceFullPath), shortHash: false); LibZipHash = EnsureHash("LibZip", Utilities.ShortenGitHash(FullLibZipHash)); Log.StatusLine($" {context.Characters.Bullet} Mono commit hash", ConsoleColor.Gray); List <ExternalGitDependency> externalDependencies = ExternalGitDependency.GetDependencies(context, Configurables.Paths.ExternalGitDepsFilePath, quiet: true); ExternalGitDependency mono = externalDependencies?.Where( eg => eg != null && String.Compare("mono", eg.Owner, StringComparison.Ordinal) == 0 && String.Compare("mono", eg.Name, StringComparison.Ordinal) == 0).FirstOrDefault(); FullMonoHash = mono?.Commit?.Trim(); MonoHash = EnsureHash("Mono", Utilities.ShortenGitHash(FullMonoHash)); if (Configurables.Paths.BundleVersionHashFiles == null || Configurables.Paths.BundleVersionHashFiles.Count == 0) { Log.WarningLine("Bundle version hash files not specified"); return; } Log.StatusLine($" {context.Characters.Bullet} Generating bundle version hash", ConsoleColor.Gray); using (var ha = HashAlgorithm.Create(context.HashAlgorithm)) { HashFiles(ha, Configurables.Paths.BundleVersionHashFiles); VersionHash = FormatHash(ha.Hash).Substring(0, (int)Configurables.Defaults.AbbreviatedHashLength); Log.StatusLine(" Hash: ", VersionHash, tailColor: ConsoleColor.Cyan); } string EnsureHash(string name, string hash) { if (String.IsNullOrEmpty(hash)) { throw new InvalidOperationException($"Unable to determine {name} commit hash"); } Log.StatusLine(" Commit: ", hash, tailColor: ConsoleColor.Cyan); Log.StatusLine(); return(hash); } }