本文整理汇总了Java中org.eclipse.jgit.api.Git.log方法的典型用法代码示例。如果您正苦于以下问题:Java Git.log方法的具体用法?Java Git.log怎么用?Java Git.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.Git
的用法示例。
在下文中一共展示了Git.log方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCommitNoRoots
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testCommitNoRoots () throws Exception {
File toCommit = new File(workDir, "testnotadd.txt");
write(toCommit, "blablabla");
GitClient client = getClient(workDir);
Map<File, GitStatus> statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, false, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_ADDED, false);
client.add(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
GitRevisionInfo info = client.commit(new File[0], "initial commit", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", info.getFullMessage());
assertEquals("initial commit", com.getFullMessage());
assertEquals(ObjectId.toString(com.getId()), info.getRevision());
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertTrue(modifiedFiles.get(toCommit).getStatus().equals(Status.ADDED));
}
示例2: testSingleFileCommit
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testSingleFileCommit () throws Exception {
repository.getConfig().setString("user", null, "name", "John");
repository.getConfig().setString("user", null, "email", "[email protected]");
repository.getConfig().save();
File toCommit = new File(workDir, "testnotadd.txt");
write(toCommit, "blablabla");
GitClient client = getClient(workDir);
Map<File, GitStatus> statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, false, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_ADDED, false);
client.add(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
long t1 = System.currentTimeMillis();
Thread.sleep(1000);
GitRevisionInfo info = client.commit(new File[] { toCommit }, "initial commit", null, null, NULL_PROGRESS_MONITOR);
Thread.sleep(1000);
long t2 = System.currentTimeMillis();
statuses = client.getStatus(new File[] { toCommit }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, toCommit, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertTrue(t1 <= info.getCommitTime() && t2 >= info.getCommitTime());
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", info.getFullMessage());
assertEquals("initial commit", com.getFullMessage());
assertEquals( "[email protected]", info.getAuthor().getEmailAddress());
assertEquals( "[email protected]", com.getAuthorIdent().getEmailAddress());
assertEquals(ObjectId.toString(com.getId()), info.getRevision());
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertTrue(modifiedFiles.get(toCommit).getStatus().equals(Status.ADDED));
}
示例3: testSingleTreeCommit
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testSingleTreeCommit () throws Exception {
File folder = new File(workDir, "folder");
File subfolder1 = new File(folder, "subfolder");
File subfolder11 = new File(subfolder1, "subfolder1");
File subfolder12 = new File(subfolder1, "subfolder2");
subfolder11.mkdirs();
subfolder12.mkdirs();
File file1 = new File(subfolder11, "file1");
File file2 = new File(subfolder12, "file2");
write(file1, "file1 content");
write(file2, "file2 content");
File[] files = new File[] { folder };
GitClient client = getClient(workDir);
client.add(files, NULL_PROGRESS_MONITOR);
GitRevisionInfo info = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertEquals(2, modifiedFiles.size());
assertTrue(modifiedFiles.get(file1).getStatus().equals(Status.ADDED));
assertTrue(modifiedFiles.get(file2).getStatus().equals(Status.ADDED));
Map<File, GitStatus> statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file1, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file2, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", com.getFullMessage());
}
示例4: testMultipleFileCommit
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testMultipleFileCommit () throws Exception {
repository.getConfig().setString("user", null, "name", "John");
repository.getConfig().setString("user", null, "email", "[email protected]");
repository.getConfig().save();
File dir = new File(workDir, "testdir");
File newOne = new File(dir, "test.txt");
File another = new File(dir, "test2.txt");
dir.mkdirs();
write(newOne, "this is test!");
write(another, "this is another test!");
GitClient client = getClient(workDir);
client.add(new File[] { newOne, another }, NULL_PROGRESS_MONITOR);
Map<File, GitStatus> statuses = client.getStatus(new File[] { newOne, another }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
GitRevisionInfo info = client.commit(new File[] { newOne, another }, "initial commit", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { newOne, another }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertTrue(modifiedFiles.get(newOne).getStatus().equals(Status.ADDED));
assertTrue(modifiedFiles.get(another).getStatus().equals(Status.ADDED));
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", com.getFullMessage());
assertEquals( "[email protected]", com.getAuthorIdent().getEmailAddress());
write(newOne, "!modification!");
write(another, "another modification!");
client.add(new File[] { workDir }, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
info = client.commit(new File[] { newOne, another }, "second commit", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(new File[] { workDir }, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, newOne, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, another, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
modifiedFiles = info.getModifiedFiles();
assertTrue(modifiedFiles.get(newOne).getStatus().equals(Status.MODIFIED));
assertTrue(modifiedFiles.get(another).getStatus().equals(Status.MODIFIED));
log = git.log();
com = log.call().iterator().next();
assertEquals("second commit", com.getFullMessage());
assertEquals( "[email protected]", com.getAuthorIdent().getEmailAddress());
}
示例5: testMultipleTreesCommit
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testMultipleTreesCommit () throws Exception {
File folder1 = new File(workDir, "folder1");
File subfolder11 = new File(folder1, "subfolder1");
File subfolder12 = new File(folder1, "subfolder2");
subfolder11.mkdirs();
subfolder12.mkdirs();
File file11 = new File(subfolder11, "file1");
File file12 = new File(subfolder12, "file2");
write(file11, "file1 content");
write(file12, "file2 content");
File folder2 = new File(workDir, "folder2");
File subfolder21 = new File(folder2, "subfolder1");
File subfolder22 = new File(folder2, "subfolder2");
subfolder21.mkdirs();
subfolder22.mkdirs();
File file21 = new File(subfolder21, "file1");
File file22 = new File(subfolder22, "file2");
write(file21, "file1 content");
write(file22, "file2 content");
File[] files = new File[] { folder1, folder2 };
GitClient client = getClient(workDir);
client.add(files, NULL_PROGRESS_MONITOR);
GitRevisionInfo info = client.commit(files, "initial commit", null, null, NULL_PROGRESS_MONITOR);
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertEquals(4, modifiedFiles.size());
Map<File, GitStatus> statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", com.getFullMessage());
write(file11, "!modification!");
write(file12, "another modification!");
write(file21, "!modification!");
write(file22, "another modification!");
client.add(files, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
client.commit(files, "second commit", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
log = git.log();
com = log.call().iterator().next();
assertEquals("second commit", com.getFullMessage());
}
示例6: testCommitOnlySomeOfAllFilesFromMultipleTrees
import org.eclipse.jgit.api.Git; //导入方法依赖的package包/类
public void testCommitOnlySomeOfAllFilesFromMultipleTrees () throws Exception {
File folder1 = new File(workDir, "folder1");
File subfolder11 = new File(folder1, "subfolder1");
File subfolder12 = new File(folder1, "subfolder2");
subfolder11.mkdirs();
subfolder12.mkdirs();
File file11 = new File(subfolder11, "file1");
File file12 = new File(subfolder12, "file2");
write(file11, "file1 content");
write(file12, "file2 content");
File folder2 = new File(workDir, "folder2");
File subfolder21 = new File(folder2, "subfolder1");
File subfolder22 = new File(folder2, "subfolder2");
subfolder21.mkdirs();
subfolder22.mkdirs();
File file21 = new File(subfolder21, "file1");
File file22 = new File(subfolder22, "file2");
write(file21, "file1 content");
write(file22, "file2 content");
File[] trees = new File[] { folder1, folder2 };
File[] filesToCommit = new File[] { folder1, subfolder21 };
File[] filesSingleFolder = new File[] { subfolder21 };
GitClient client = getClient(workDir);
client.add(trees, NULL_PROGRESS_MONITOR);
// COMMIT SOME
GitRevisionInfo info = client.commit(filesSingleFolder, "initial commit", null, null, NULL_PROGRESS_MONITOR);
Map<File, GitFileInfo> modifiedFiles = info.getModifiedFiles();
assertEquals(1, modifiedFiles.size());
Map<File, GitStatus> statuses = client.getStatus(trees, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_ADDED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_ADDED, false);
Git git = new Git(repository);
LogCommand log = git.log();
RevCommit com = log.call().iterator().next();
assertEquals("initial commit", com.getFullMessage());
// COMMIT ALL
info = client.commit(trees, "commit all", null, null, NULL_PROGRESS_MONITOR);
modifiedFiles = info.getModifiedFiles();
assertEquals(3, modifiedFiles.size());
statuses = client.getStatus(trees, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
write(file11, "!modification!");
write(file12, "another modification!");
write(file21, "!modification!");
write(file22, "another modification!");
client.add(trees, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(trees, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
info = client.commit(filesToCommit, "second commit", null, null, NULL_PROGRESS_MONITOR);
modifiedFiles = info.getModifiedFiles();
assertEquals(3, modifiedFiles.size());
statuses = client.getStatus(trees, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_MODIFIED, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_MODIFIED, false);
log = git.log();
com = log.call().iterator().next();
assertEquals("second commit", com.getFullMessage());
// COMMIT ALL
client.commit(trees, "commit all", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(trees, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, file11, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file12, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file21, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
assertStatus(statuses, workDir, file22, true, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, GitStatus.Status.STATUS_NORMAL, false);
}