private int RunGitVersionTool(GitVersionOptions gitVersionOptions) { var mutexName = gitVersionOptions.WorkingDirectory.Replace(Path.DirectorySeparatorChar.ToString(), ""); using var mutex = new Mutex(true, $@"Global\{mutexName}", out var acquired); try { if (!acquired) { mutex.WaitOne(); } var variables = gitVersionCalculateTool.CalculateVersionVariables(); var configuration = configProvider.Provide(overrideConfig: gitVersionOptions.ConfigInfo.OverrideConfig); gitVersionOutputTool.OutputVariables(variables, configuration.UpdateBuildNumber ?? true); gitVersionOutputTool.UpdateAssemblyInfo(variables); gitVersionOutputTool.UpdateWixVersionFile(variables); } catch (WarningException exception) { var error = $"An error occurred:{System.Environment.NewLine}{exception.Message}"; log.Warning(error); return(1); } catch (Exception exception) { var error = $"An unexpected error occurred:{System.Environment.NewLine}{exception}"; log.Error(error); if (gitVersionOptions == null) { return(1); } log.Info("Attempting to show the current git graph (please include in issue): "); log.Info("Showing max of 100 commits"); try { GitExtensions.DumpGraph(gitVersionOptions.WorkingDirectory, mess => log.Info(mess), 100); } catch (Exception dumpGraphException) { log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException); } return(1); } finally { mutex.ReleaseMutex(); } return(0); }
private int RunGitVersionTool(GitVersionOptions gitVersionOptions) { try { var variables = gitVersionCalculateTool.CalculateVersionVariables(); var configuration = configProvider.Provide(overrideConfig: gitVersionOptions.ConfigInfo.OverrideConfig); gitVersionOutputTool.OutputVariables(variables, configuration.UpdateBuildNumber ?? true); gitVersionOutputTool.UpdateAssemblyInfo(variables); gitVersionOutputTool.UpdateWixVersionFile(variables); } catch (WarningException exception) { var error = $"An error occurred:{System.Environment.NewLine}{exception.Message}"; log.Warning(error); return(1); } catch (Exception exception) { var error = $"An unexpected error occurred:{System.Environment.NewLine}{exception}"; log.Error(error); if (gitVersionOptions == null) { return(1); } log.Info("Attempting to show the current git graph (please include in issue): "); log.Info("Showing max of 100 commits"); try { GitExtensions.DumpGraph(gitVersionOptions.WorkingDirectory, mess => log.Info(mess), 100); } catch (Exception dumpGraphException) { log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException); } return(1); } return(0); }