public Commit(final Git git, final String branchName, final CommitInfo commitInfo, final boolean amend, final ObjectId originId, final CommitContent content) { this.git = git; this.branchName = branchName; this.commitInfo = commitInfo; this.amend = amend; this.content = content; try { if (originId == null) { this.originId = git.getLastCommit(branchName); } else { this.originId = originId; } } catch (final Throwable t) { throw new RuntimeException(t); } }
public ObjectId execute() { final RevCommit commit = git.getLastCommit(treeRefName); if (commit == null) { return null; } return commit.getTree().getId(); } }
public List<String> execute() { existsBranch(git, sourceBranch); existsBranch(git, targetBranch); final Repository repo = git.getRepository(); final RevCommit lastSourceCommit = git.getLastCommit(sourceBranch); final RevCommit lastTargetCommit = git.getLastCommit(targetBranch); final RevCommit commonAncestor = getCommonAncestor(lastSourceCommit, lastTargetCommit); final List<RevCommit> commits = git.listCommits(commonAncestor, lastSourceCommit); Collections.reverse(commits); final String[] commitsIDs = commits.stream().map(AnyObjectId::getName).toArray(String[]::new); canMerge(repo, commonAncestor, lastSourceCommit, lastTargetCommit, sourceBranch, targetBranch); git.cherryPick(targetBranch, commitsIDs); if (logger.isDebugEnabled()) { logger.debug("Merging commits from <{}> to <{}>", sourceBranch, targetBranch); } return Arrays.asList(commitsIDs); }
@Override public FileTime lastModifiedTime() { if (lastModifiedDate == null) { try { lastModifiedDate = new FileTimeImpl(fs.getGit().getLastCommit(ref).getCommitterIdent().getWhen().getTime()); } catch (final Exception e) { lastModifiedDate = new FileTimeImpl(0); } } return lastModifiedDate; }
assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); } catch (Exception ex) { fail(); assertNotNull(git.getLastCommit("master")); fail("forced to fail!"); } catch (RuntimeException ex) {
public void execute() throws IOException, ConcurrentRefUpdateException { final ObjectId headId = git.getLastCommit(Constants.R_HEADS + name); final RefUpdate ru = git.getRepository().updateRef(Constants.R_HEADS + name); if (headId == null) { ru.setExpectedOldObjectId(ObjectId.zeroId()); } else { ru.setExpectedOldObjectId(headId); } ru.setNewObjectId(commit.getId()); ru.setRefLogMessage(commit.getShortMessage(), false); forceUpdate(ru, commit.getId()); }
assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); assertNotNull(git.getLastCommit("master")); } catch (Exception ex) { fail(); assertNotNull(git.getLastCommit("master")); fail("forced to fail!"); } catch (RuntimeException ex) {
}}).execute(); final RevCommit commit = git.getLastCommit("master"); try { assertNotNull(git.listCommits(null,
}}).execute(); final RevCommit commit = git.getLastCommit("master"); try { assertNotNull(git.listCommits(null,