From 779d26901deb102512df5a3eb7be1a760fb63ae7 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Tue, 28 Feb 2017 11:33:37 -0800 Subject: [PATCH] Make update-dependencies idempotent in the only update case Today, if you run update-dependencies --Update and there are no changes that need to be made (for example, you ran it previously) and there are pending changes (i.e. git status shows diffs) the program crashes with an unhandled exception because some code in VersionTools is upset that there are pending changes since it thinks there should be none. Re-structure the code such that we don't call the method that's going to throw when we are just updating dependencies. This also means devs (or the composed build) who want to run this more than once do longer have to reset changes beforehand. --- build_projects/update-dependencies/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_projects/update-dependencies/Program.cs b/build_projects/update-dependencies/Program.cs index 991d86af0..67caf4aef 100644 --- a/build_projects/update-dependencies/Program.cs +++ b/build_projects/update-dependencies/Program.cs @@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Scripts disabledPackages: Enumerable.Empty())); DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos); - if (updateResults.ChangesDetected() && !onlyUpdate) + if (!onlyUpdate && updateResults.ChangesDetected()) { GitHubAuth gitHubAuth = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email); GitHubProject origin = new GitHubProject(s_config.GitHubProject, s_config.UserName);