Merge branch 'Indore-2017.1.x'
authorDmitry Neverov <dmitry.neverov@gmail.com>
Mon, 17 Jul 2017 13:59:01 +0000 (15:59 +0200)
committerDmitry Neverov <dmitry.neverov@gmail.com>
Mon, 17 Jul 2017 13:59:01 +0000 (15:59 +0200)
git-agent/src/jetbrains/buildServer/buildTriggers/vcs/git/agent/UpdaterImpl.java
git-tests/src/jetbrains/buildServer/buildTriggers/vcs/git/tests/AgentVcsSupportTest.java

index 9e1a6e544130ab09b4eced5f0fbcd01d30040308..40e2ae3f3a013a23388a0cdaba602dcea30207de 100644 (file)
@@ -558,8 +558,8 @@ public class UpdaterImpl implements Updater {
       fetchAllBranches();
       if (!myFullBranchName.startsWith("refs/heads/")) {
         Ref remoteRef = getRef(myTargetDirectory, GitUtils.createRemoteRef(myFullBranchName));
-        if (!fetchRequired && remoteRef != null && myRevision.equals(remoteRef.getObjectId().name()) && hasRevision(myTargetDirectory, myRevision))
-          return;
+        if (fetchRequired || remoteRef == null || !myRevision.equals(remoteRef.getObjectId().name()) || !hasRevision(myTargetDirectory, myRevision))
+          fetchDefaultBranch();
       }
     } else {
       Ref remoteRef = getRef(myTargetDirectory, GitUtils.createRemoteRef(myFullBranchName));
index 81b2234fa228a220b49297afc9d4d0b59b61e35c..80f4a58ff250c55800c0fee896d04dc7e8b3093f 100644 (file)
@@ -910,6 +910,17 @@ public class AgentVcsSupportTest {
   }
 
 
+  @TestFor(issues = "TW-50714")
+  @Test(dataProvider = "mirrors")
+  public void fetch_all_heads__non_head_ref(boolean useMirrors) throws Exception {
+    AgentRunningBuild build = createRunningBuild(map(PluginConfigImpl.FETCH_ALL_HEADS, "true"));
+
+    myRoot = vcsRoot().withAgentGitPath(getGitPath()).withFetchUrl(GitUtils.toURL(myMainRepo)).withUseMirrors(useMirrors).withBranch("refs/pull/1").build();
+
+    myVcsSupport.updateSources(myRoot, CheckoutRules.DEFAULT, "b896070465af79121c9a4eb5300ecff29453c164", myCheckoutDir, build, false);
+  }
+
+
   private void removeTag(@NotNull File dotGitDir, @NotNull String tagName) {
     delete(tagFile(dotGitDir, tagName));
   }