|
|
|
@ -206,6 +206,28 @@ public class CheckoutCommandTest extends RepositoryTestCase {
|
|
|
|
|
assertEquals(initialCommit.name(), git.getRepository().getFullBranch()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCheckoutLightweightTag() throws Exception { |
|
|
|
|
git.tag().setAnnotated(false).setName("test-tag") |
|
|
|
|
.setObjectId(initialCommit).call(); |
|
|
|
|
Ref result = git.checkout().setName("test-tag").call(); |
|
|
|
|
|
|
|
|
|
assertNull(result); |
|
|
|
|
assertEquals(initialCommit.getId(), db.resolve(Constants.HEAD)); |
|
|
|
|
assertHeadDetached(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCheckoutAnnotatedTag() throws Exception { |
|
|
|
|
git.tag().setAnnotated(true).setName("test-tag") |
|
|
|
|
.setObjectId(initialCommit).call(); |
|
|
|
|
Ref result = git.checkout().setName("test-tag").call(); |
|
|
|
|
|
|
|
|
|
assertNull(result); |
|
|
|
|
assertEquals(initialCommit.getId(), db.resolve(Constants.HEAD)); |
|
|
|
|
assertHeadDetached(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCheckoutRemoteTrackingWithUpstream() throws Exception { |
|
|
|
|
Repository db2 = createRepositoryWithRemote(); |
|
|
|
@ -326,9 +348,7 @@ public class CheckoutCommandTest extends RepositoryTestCase {
|
|
|
|
|
co = git.checkout(); |
|
|
|
|
co.setName(commitId).call(); |
|
|
|
|
|
|
|
|
|
Ref head = db.getRef(Constants.HEAD); |
|
|
|
|
assertFalse(head.isSymbolic()); |
|
|
|
|
assertSame(head, head.getTarget()); |
|
|
|
|
assertHeadDetached(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -421,6 +441,12 @@ public class CheckoutCommandTest extends RepositoryTestCase {
|
|
|
|
|
assertNull(db.resolve("HEAD")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertHeadDetached() throws IOException { |
|
|
|
|
Ref head = db.getRef(Constants.HEAD); |
|
|
|
|
assertFalse(head.isSymbolic()); |
|
|
|
|
assertSame(head, head.getTarget()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertRepositoryCondition(int files) throws GitAPIException { |
|
|
|
|
org.eclipse.jgit.api.Status status = this.git.status().call(); |
|
|
|
|
assertFalse(status.isClean()); |
|
|
|
|