use of git4idea.rebase.GitRebaser in project intellij-community by JetBrains.
the class GitUpdateProcess method checkRebaseInProgress.
/**
* Check if rebase is in progress, propose to resolve conflicts.
* @return true if rebase is in progress, which means that update can't continue.
*/
private boolean checkRebaseInProgress() {
LOG.info("checkRebaseInProgress: checking if there is an unfinished rebase process...");
final GitRebaser rebaser = new GitRebaser(myProject, myGit, myProgressIndicator);
final Collection<VirtualFile> rebasingRoots = rebaser.getRebasingRoots();
if (rebasingRoots.isEmpty()) {
return false;
}
LOG.info("checkRebaseInProgress: roots with unfinished rebase: " + rebasingRoots);
GitConflictResolver.Params params = new GitConflictResolver.Params();
params.setErrorNotificationTitle("Can't update");
params.setMergeDescription("You have unfinished rebase process. These conflicts must be resolved before update.");
params.setErrorNotificationAdditionalDescription("Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing.");
params.setReverse(true);
return !new GitConflictResolver(myProject, myGit, rebasingRoots, params) {
@Override
protected boolean proceedIfNothingToMerge() {
return rebaser.continueRebase(rebasingRoots);
}
@Override
protected boolean proceedAfterAllMerged() {
return rebaser.continueRebase(rebasingRoots);
}
}.merge();
}
use of git4idea.rebase.GitRebaser in project intellij-community by JetBrains.
the class GithubRebaseAction method doRebaseCurrentBranch.
private static void doRebaseCurrentBranch(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final ProgressIndicator indicator) {
final GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project);
Git git = ServiceManager.getService(Git.class);
final GitRebaser rebaser = new GitRebaser(project, git, indicator);
final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.REBASE);
handler.setStdoutSuppressed(false);
handler.addParameters("upstream/master");
final GitRebaseProblemDetector rebaseConflictDetector = new GitRebaseProblemDetector();
handler.addLineListener(rebaseConflictDetector);
final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(root);
final GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(root, CHECKOUT);
handler.addLineListener(untrackedFilesDetector);
handler.addLineListener(localChangesDetector);
handler.addLineListener(GitStandardProgressAnalyzer.createListener(indicator));
String oldText = indicator.getText();
indicator.setText("Rebasing from upstream/master...");
GitCommandResult rebaseResult = git.runCommand(handler);
indicator.setText(oldText);
repositoryManager.updateRepository(root);
if (rebaseResult.success()) {
root.refresh(false, true);
GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
} else {
GitUpdateResult result = rebaser.handleRebaseFailure(handler, root, rebaseConflictDetector, untrackedFilesDetector, localChangesDetector);
if (result == GitUpdateResult.NOTHING_TO_UPDATE || result == GitUpdateResult.SUCCESS || result == GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS) {
GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
}
}
}
Aggregations