Skip to content
This repository
Browse code

Make the repo cache reset logic work with non-master branches

  • Loading branch information...
commit 5f88c411d3ea58b6895543845b7296d83b331c6b 1 parent cb5e19b
David Ebbo davidebbo authored

Showing 1 changed file with 17 additions and 1 deletion. Show diff stats Hide diff stats

  1. +17 1 Kudu.TestHarness/Git.cs
18 Kudu.TestHarness/Git.cs
@@ -129,7 +129,23 @@ private static string CreateCachedRepo(string repositoryName, string source, IDi
129 129 Trace.WriteLine(String.Format("Using cached copy at location {0}", cachedPath));
130 130
131 131 // Get it into a clean state that matches a clean clone from github
132   - gitExe.Execute("reset --hard origin/master");
  132 + try
  133 + {
  134 + gitExe.Execute("reset --hard origin/master");
  135 + }
  136 + catch (Exception e)
  137 + {
  138 + // Some repos like Drupal don't use a master branch (e.g. default branch is 7.x). In those cases,
  139 + // simply reset to the HEAD. That won't undo any test commits, but at least it does some cleanup.
  140 + if (e.Message.Contains("ambiguous argument 'origin/master'"))
  141 + {
  142 + gitExe.Execute("reset --hard HEAD");
  143 + }
  144 + else
  145 + {
  146 + throw;
  147 + }
  148 + }
133 149 gitExe.Execute("clean -dxf");
134 150 }
135 151 else

0 comments on commit 5f88c41

Please sign in to comment.
Something went wrong with that request. Please try again.