|
|
@@ -52,8 +52,10 @@ import java.util.Collection; |
|
|
|
import org.eclipse.jgit.api.errors.GitAPIException; |
|
|
|
import org.eclipse.jgit.api.errors.JGitInternalException; |
|
|
|
import org.eclipse.jgit.junit.RepositoryTestCase; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.Ref; |
|
|
|
import org.eclipse.jgit.lib.RefUpdate; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.lib.StoredConfig; |
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
@@ -168,4 +170,27 @@ public class FetchCommandTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
assertEquals(originalId, db.resolve(tagName)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void fetchWithExplicitTagsShouldUpdateLocal() throws Exception { |
|
|
|
final String tagName = "foo"; |
|
|
|
remoteGit.commit().setMessage("commit").call(); |
|
|
|
Ref tagRef1 = remoteGit.tag().setName(tagName).call(); |
|
|
|
|
|
|
|
RefSpec spec = new RefSpec("refs/heads/*:refs/remotes/origin/*"); |
|
|
|
git.fetch().setRemote("test").setRefSpecs(spec) |
|
|
|
.setTagOpt(TagOpt.AUTO_FOLLOW).call(); |
|
|
|
assertEquals(tagRef1.getObjectId(), db.resolve(tagName)); |
|
|
|
|
|
|
|
remoteGit.commit().setMessage("commit 2").call(); |
|
|
|
Ref tagRef2 = remoteGit.tag().setName(tagName).setForceUpdate(true) |
|
|
|
.call(); |
|
|
|
|
|
|
|
FetchResult result = git.fetch().setRemote("test").setRefSpecs(spec) |
|
|
|
.setTagOpt(TagOpt.FETCH_TAGS).call(); |
|
|
|
TrackingRefUpdate update = result.getTrackingRefUpdate(Constants.R_TAGS |
|
|
|
+ tagName); |
|
|
|
assertEquals(RefUpdate.Result.FORCED, update.getResult()); |
|
|
|
assertEquals(tagRef2.getObjectId(), db.resolve(tagName)); |
|
|
|
} |
|
|
|
} |