log.all(); } else { Memory range = settings.valueOfIndex("range");
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { Iterable<RevCommit> commits = git.log().all().call(); int count = 0; for (RevCommit commit : commits) { System.out.println("LogCommit: " + commit); count++; } System.out.println(count); } } } }
public static void main(String[] args) throws IOException, GitAPIException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { try (Git git = new Git(repository)) { Iterable<RevCommit> commits = git.log().all().call(); int count = 0; for (RevCommit commit : commits) { System.out.println("LogCommit: " + commit); count++; } System.out.println(count); } } } }
public GitTool() { File gitWorkDir = new File("."); try { Git git = Git.open(gitWorkDir); Iterable<RevCommit> commits = git.log().all().call(); Repository repo = git.getRepository(); branch = repo.getBranch(); RevCommit latestCommit = commits.iterator().next(); name = latestCommit.getName(); message = latestCommit.getFullMessage(); } catch (Throwable e) { name = ""; message = ""; branch = ""; } }
.all() .call(); count = 0;
.all() .call(); count = 0;
private ArrayList<String> getContributorsFromRepo() { ArrayList<String> contributors = new ArrayList<>(); try { // get authors Iterable<RevCommit> commits = git.log().all().call(); for (RevCommit commit : commits) { String author = commit.getAuthorIdent().getName(); if (!contributors.contains(author)) { contributors.add(author); } } log.info("getting the contributors " + contributors); } catch (Exception e) { log.warn("Failed to get authors from repo: " + e.getMessage()); } return contributors; }
public static boolean hasGitHead(Git git) throws GitAPIException, IOException { boolean hasHead = true; try { git.log().all().call(); hasHead = git.getRepository().getAllRefs().containsKey("HEAD"); } catch (NoHeadException e) { hasHead = false; } return hasHead; }
public static boolean hasGitHead(Git git) throws GitAPIException, IOException { boolean hasHead = true; try { git.log().all().call(); hasHead = git.getRepository().getAllRefs().containsKey("HEAD"); } catch (NoHeadException e) { hasHead = false; } return hasHead; }
@Override protected int poll() throws Exception { int count = 0; Iterable<RevCommit> commits = getGit().log().all().call(); for (RevCommit commit : commits) { if (!commitsConsumed.contains(commit.getId())) { Exchange e = getEndpoint().createExchange(); e.getOut().setBody(commit); getProcessor().process(e); commitsConsumed.add(commit.getId()); count++; } } return count; }
/** * Returns the hash of the last commit before a job was deleted. * * This method uses the following git command equivalent: * <pre> * git log --all --skip=1 -n 1 -- jobs/[jobId] * </pre> * which only works as intended with deleted jobs. * * @param jobId The id of a deleted job. * @throws GitAPIException * @throws IOException */ public String getCommitHashBeforeJobDeletion(String jobId) throws GitAPIException, IOException { // skip=1 skips the deletion, and -n 1 returns only the commit immediately before that Iterable<RevCommit> iter = git.log().all().addPath(getPathForJobId(jobId)).setSkip(1).setMaxCount(1).call(); RevCommit commit = Iterables.getFirst(iter, null); return commit == null ? null : commit.getName(); }
git.log().all().call(); hasHead = git.getRepository().getAllRefs().containsKey("HEAD"); } catch (NoHeadException e) {
boolean hasHead = true; try { git.log().all().call(); hasHead = git.getRepository().getAllRefs().containsKey("HEAD"); } catch (NoHeadException e) {
@Test public void testCreateFileIntoRepositoryWithFolder() throws IOException, GitAPIException { final Map<String, ?> env = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}; String oldPath = "git://test/old"; final URI oldUri = URI.create(oldPath); final JGitFileSystem fs = (JGitFileSystem) provider.newFileSystem(oldUri, env); final Path path = provider.getPath(URI.create("git://master@test/old/some/path/myfile.txt")); provider.setAttribute(path, FileSystemState.FILE_SYSTEM_STATE_ATTR, FileSystemState.BATCH); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my cool content").getBytes()); outStream.close(); assertThat(new File(provider.getGitRepoContainerDir(), "test/old" + ".git")).exists(); int commitsCount = 0; for (RevCommit com : ((GitImpl) fs.getGit())._log().all().call()) { commitsCount++; } }
@Test public void testCreateFileIntoRepositoryWithFolder() throws IOException, GitAPIException { final Map<String, ?> env = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}; String oldPath = "git://test/old"; final URI oldUri = URI.create(oldPath); final JGitFileSystem fs = (JGitFileSystem) provider.newFileSystem(oldUri, env); final Path path = provider.getPath(URI.create("git://master@test/old/some/path/myfile.txt")); provider.setAttribute(path, FileSystemState.FILE_SYSTEM_STATE_ATTR, FileSystemState.BATCH); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my cool content").getBytes()); outStream.close(); assertThat(new File(provider.getGitRepoContainerDir(), "test/old" + ".git")).exists(); int commitsCount = 0; for (RevCommit com : ((GitImpl) fs.getGit())._log().all().call()) { commitsCount++; } }
for (RevCommit com : ((GitImpl) fs.getGit())._log().all().call()) { commitsCount++; System.out.println(com.getName() + " - " + com.getFullMessage());
for (RevCommit com : ((GitImpl) fs.getGit())._log().all().call()) { commitsCount++; System.out.println(com.getName() + " - " + com.getFullMessage());
boolean hasHead = true; try { git.log().all().call(); hasHead = git.getRepository().getAllRefs().containsKey("HEAD"); } catch (NoHeadException e) {
public Ref newEmptyLocalBranch(String branchName) throws Exception { Iterable<RevCommit> revItr = git.log().all().call(); RevCommit oldestRev = null; for(RevCommit rev : revItr) { if(oldestRev == null || rev.getCommitTime() < oldestRev.getCommitTime()) { oldestRev = rev; } } Ref newBranch = null; String currentBranch = getBranchName(); if(oldestRev != null) { newBranch = git.checkout().setName(branchName).setCreateBranch(true).setStartPoint(oldestRev.getName()).call(); } else { newBranch = git.checkout().setName(branchName).setCreateBranch(true).call(); } switchBranch(currentBranch); return newBranch; }
final RevCommit lastCommit = git.log().all().call().iterator().next(); assertThat(lastCommit.getParentCount()).isEqualTo(2); assertThat(lastCommit.getParents()).containsExactlyInAnyOrder(commit1, commit2);