Skip to content
Browse files

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

  • Loading branch information...
1 parent cb5e19b commit 5f88c411d3ea58b6895543845b7296d83b331c6b @davidebbo davidebbo committed Dec 6, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 Kudu.TestHarness/Git.cs
View
18 Kudu.TestHarness/Git.cs
@@ -129,7 +129,23 @@ private static string CreateCachedRepo(string repositoryName, string source, IDi
Trace.WriteLine(String.Format("Using cached copy at location {0}", cachedPath));
// Get it into a clean state that matches a clean clone from github
- gitExe.Execute("reset --hard origin/master");
+ try
+ {
+ gitExe.Execute("reset --hard origin/master");
+ }
+ catch (Exception e)
+ {
+ // Some repos like Drupal don't use a master branch (e.g. default branch is 7.x). In those cases,
+ // simply reset to the HEAD. That won't undo any test commits, but at least it does some cleanup.
+ if (e.Message.Contains("ambiguous argument 'origin/master'"))
+ {
+ gitExe.Execute("reset --hard HEAD");
+ }
+ else
+ {
+ throw;
+ }
+ }
gitExe.Execute("clean -dxf");
}
else

0 comments on commit 5f88c41

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