Search in sources :

Example 1 with GitRebaser

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GitConflictResolver(git4idea.merge.GitConflictResolver) GitRebaser(git4idea.rebase.GitRebaser)

Example 2 with GitRebaser

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");
        }
    }
}
Also used : GitUpdateResult(git4idea.update.GitUpdateResult) GitRepositoryManager(git4idea.repo.GitRepositoryManager) GitRebaseProblemDetector(git4idea.rebase.GitRebaseProblemDetector) GitRebaser(git4idea.rebase.GitRebaser)

Aggregations

GitRebaser (git4idea.rebase.GitRebaser)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GitConflictResolver (git4idea.merge.GitConflictResolver)1 GitRebaseProblemDetector (git4idea.rebase.GitRebaseProblemDetector)1 GitRepositoryManager (git4idea.repo.GitRepositoryManager)1 GitUpdateResult (git4idea.update.GitUpdateResult)1