Search in sources :

Example 1 with GitRebaseProblemDetector

use of git4idea.rebase.GitRebaseProblemDetector 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

GitRebaseProblemDetector (git4idea.rebase.GitRebaseProblemDetector)1 GitRebaser (git4idea.rebase.GitRebaser)1 GitRepositoryManager (git4idea.repo.GitRepositoryManager)1 GitUpdateResult (git4idea.update.GitUpdateResult)1