|
|
@ -51,6 +51,7 @@ import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.junit.RepositoryTestCase; |
|
|
|
import org.eclipse.jgit.junit.RepositoryTestCase; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.PersonIdent; |
|
|
|
import org.eclipse.jgit.lib.Ref; |
|
|
|
import org.eclipse.jgit.lib.Ref; |
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
@ -89,6 +90,30 @@ public class LogCommandTest extends RepositoryTestCase { |
|
|
|
assertFalse(log.hasNext()); |
|
|
|
assertFalse(log.hasNext()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void logAllCommitsWithTag() throws Exception { |
|
|
|
|
|
|
|
List<RevCommit> commits = new ArrayList<RevCommit>(); |
|
|
|
|
|
|
|
Git git = Git.wrap(db); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writeTrashFile("Test.txt", "Hello world"); |
|
|
|
|
|
|
|
git.add().addFilepattern("Test.txt").call(); |
|
|
|
|
|
|
|
commits.add(git.commit().setMessage("initial commit").call()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TagCommand tagCmd = git.tag(); |
|
|
|
|
|
|
|
tagCmd.setName("tagname"); |
|
|
|
|
|
|
|
tagCmd.setObjectId(commits.get(0)); |
|
|
|
|
|
|
|
tagCmd.setTagger(new PersonIdent(db)); |
|
|
|
|
|
|
|
Ref tag = tagCmd.call(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Iterator<RevCommit> log = git.log().all().call().iterator(); |
|
|
|
|
|
|
|
assertTrue(log.hasNext()); |
|
|
|
|
|
|
|
RevCommit commit = log.next(); |
|
|
|
|
|
|
|
tag = db.peel(tag); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals(commit.getName(), tag.getPeeledObjectId().getName()); |
|
|
|
|
|
|
|
assertTrue(commits.contains(commit)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<RevCommit> createCommits(Git git) throws Exception { |
|
|
|
private List<RevCommit> createCommits(Git git) throws Exception { |
|
|
|
List<RevCommit> commits = new ArrayList<RevCommit>(); |
|
|
|
List<RevCommit> commits = new ArrayList<RevCommit>(); |
|
|
|
writeTrashFile("Test.txt", "Hello world"); |
|
|
|
writeTrashFile("Test.txt", "Hello world"); |
|
|
|