Java Code Examples for org.eclipse.jgit.revwalk.RevCommit#equals()

The following examples show how to use org.eclipse.jgit.revwalk.RevCommit#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitMergeUtil.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@code git status} {@code git cherry}
 */
private void checkStatus() {
	try {
		final Status result = repo.status().call();
		if (!result.isClean()) {
			exception = new MergeUnitException(String.format("The local repository is not clean: '%s'", repo)); //$NON-NLS-1$
		} else {
			/*
			 * JGit does not support "git cherry", so checking for unpushed commits is done
			 * by comparing the last commit id of the local and the remote branch. If JGit
			 * supports "git cherry" it should be refactored to this command.
			 */
			final String localTargetBranch = getLocalTargetBranch();
			if (localTargetBranch == null) {
				return;
			}
			final RevCommit lastCommitOfLocalBranch = getLastCommit(localTargetBranch);
			if (lastCommitOfLocalBranch == null) {
				return;
			}
			final RevCommit lastCommitOfRemoteBranch = getLastCommit(mergeUnit.getBranchTarget());
			if (lastCommitOfRemoteBranch == null) {
				return;
			}
			if (!lastCommitOfLocalBranch.equals(lastCommitOfRemoteBranch)) {
				exception = new MergeUnitException(
						String.format("The local repository is not clean: '%s'", repo)); //$NON-NLS-1$
			}
		}
	} catch (GitAPIException e) {
		exception = new MergeUnitException(
				String.format("Could not check the status of the local repository '%s'.", repo), e); //$NON-NLS-1$
	}
}
 
Example 2
Source File: PullRequest.java    From onedev with MIT License 5 votes vote down vote up
private boolean contains(ObjectId commitId) {
	if (commitId.equals(getBaseCommit()))
		return true;
	for (PullRequestUpdate update: getUpdates()) {
		for (RevCommit commit: update.getCommits()) {
			if (commit.equals(commitId))
				return true;
		}
	}
	return false;
}
 
Example 3
Source File: Tags.java    From gradle-gitsemver with Apache License 2.0 4 votes vote down vote up
private static boolean nonNullOrEnd(RevCommit end, RevCommit c) {
    return (c != null) && !c.equals(end);
}