use of org.eclipse.jgit.lib.RepositoryState in project egit by eclipse.
the class RevUtils method getConflictCommits.
/**
* @param repository
* @param path
* repository-relative path of file with conflicts
* @return an object with the interesting commits for this path
* @throws IOException
*/
public static ConflictCommits getConflictCommits(Repository repository, String path) throws IOException {
try (RevWalk walk = new RevWalk(repository)) {
RevCommit ourCommit;
RevCommit theirCommit = null;
walk.setTreeFilter(AndTreeFilter.create(PathFilterGroup.createFromStrings(path), TreeFilter.ANY_DIFF));
RevCommit head = walk.parseCommit(repository.resolve(Constants.HEAD));
walk.markStart(head);
ourCommit = walk.next();
RepositoryState state = repository.getRepositoryState();
if (state == RepositoryState.REBASING || state == RepositoryState.CHERRY_PICKING) {
ObjectId cherryPickHead = repository.readCherryPickHead();
if (cherryPickHead != null) {
RevCommit cherryPickCommit = walk.parseCommit(cherryPickHead);
theirCommit = cherryPickCommit;
}
} else if (state == RepositoryState.MERGING) {
List<ObjectId> mergeHeads = repository.readMergeHeads();
Assert.isNotNull(mergeHeads);
if (mergeHeads.size() == 1) {
ObjectId mergeHead = mergeHeads.get(0);
RevCommit mergeCommit = walk.parseCommit(mergeHead);
walk.reset();
walk.markStart(mergeCommit);
theirCommit = walk.next();
}
}
return new ConflictCommits(ourCommit, theirCommit);
}
}
use of org.eclipse.jgit.lib.RepositoryState in project egit by eclipse.
the class CommitHelper method calculateCommitInfo.
private void calculateCommitInfo() {
Repository mergeRepository = null;
isMergedResolved = false;
isCherryPickResolved = false;
RepositoryState state = repository.getRepositoryState();
canCommit = state.canCommit();
if (!canCommit) {
cannotCommitMessage = NLS.bind(UIText.CommitAction_repositoryState, state.getDescription());
return;
}
if (state.equals(RepositoryState.MERGING_RESOLVED)) {
isMergedResolved = true;
mergeRepository = repository;
} else if (state.equals(RepositoryState.CHERRY_PICKING_RESOLVED)) {
isCherryPickResolved = true;
mergeRepository = repository;
}
previousCommit = getHeadCommit(repository);
final UserConfig config = repository.getConfig().get(UserConfig.KEY);
author = config.getAuthorName();
final String authorEmail = config.getAuthorEmail();
// $NON-NLS-1$ //$NON-NLS-2$
author = author + " <" + authorEmail + ">";
committer = config.getCommitterName();
final String committerEmail = config.getCommitterEmail();
// $NON-NLS-1$ //$NON-NLS-2$
committer = committer + " <" + committerEmail + ">";
if (isMergedResolved || isCherryPickResolved) {
commitMessage = getMergeResolveMessage(mergeRepository);
}
if (isCherryPickResolved) {
author = getCherryPickOriginalAuthor(mergeRepository);
}
}
use of org.eclipse.jgit.lib.RepositoryState in project egit by eclipse.
the class ReflogView method getRepositoryName.
private static String getRepositoryName(Repository repository) {
String repoName = Activator.getDefault().getRepositoryUtil().getRepositoryName(repository);
RepositoryState state = repository.getRepositoryState();
if (state != RepositoryState.SAFE)
return repoName + '|' + state.getDescription();
else
return repoName;
}
use of org.eclipse.jgit.lib.RepositoryState in project egit by eclipse.
the class RebaseActionHandler method isEnabled.
@Override
public boolean isEnabled() {
Repository repo = getRepository();
if (repo == null)
return false;
// Either we want this to be enabled because a new rebase can be started
// (main action) or an active rebase can be continued, skipped or
// aborted (menu items). Even when the main action is not enabled we
// must enable this because otherwise the menu items cannot be opened.
RepositoryState state = repo.getRepositoryState();
return state.isRebasing() || RebaseCurrentRefCommand.isEnabledForState(repo, state);
}
Aggregations