@Override
  public void actionPerformed(@NotNull AnActionEvent e) {
    FileDocumentManager.getInstance().saveAllDocuments();

    Project project = Objects.requireNonNull(e.getData(CommonDataKeys.PROJECT));

    GitRepositoryManager gitRepositoryManager = project.getServiceIfCreated(GitRepositoryManager.class);
    if (gitRepositoryManager == null) {
      LOG.warn("Unable to get the GitRepositoryManager service");
      return;
    }

    if (gitRepositoryManager.getRepositories().size() > 1) {
      GithubNotifications.showError(project,
                                    GithubNotificationIdsHolder.REBASE_MULTI_REPO_NOT_SUPPORTED,
                                    GithubBundle.message("rebase.error"),
                                    GithubBundle.message("rebase.error.multi.repo.not.supported"));
      return;
    }

    GHHostedRepositoriesManager ghRepositoriesManager = project.getServiceIfCreated(GHHostedRepositoriesManager.class);
    if (ghRepositoriesManager == null) {
      LOG.warn("Unable to get the GHProjectRepositoriesManager service");
      return;
    }

    Set<GHGitRepositoryMapping> repositories = HostedGitRepositoriesManagerKt.getKnownRepositories(ghRepositoriesManager);
    GHGitRepositoryMapping originMapping = ContainerUtil.find(repositories, mapping ->
      mapping.getRemote().getRemote().getName().equals(ORIGIN_REMOTE_NAME));
    if (originMapping == null) {
      GithubNotifications.showError(project,
                                    GithubNotificationIdsHolder.REBASE_REMOTE_ORIGIN_NOT_FOUND,
                                    GithubBundle.message("rebase.error"),
                                    GithubBundle.message("rebase.error.remote.origin.not.found"));
      return;
    }

    GHAccountManager accountManager = ApplicationManager.getApplication().getService(GHAccountManager.class);
    GithubServerPath serverPath = originMapping.getRepository().getServerPath();
    GithubAccount githubAccount;
    List<GithubAccount> accounts = ContainerUtil.filter(accountManager.getAccountsState().getValue(),
                                                        account -> serverPath.equals(account.getServer()));
    if (accounts.size() == 0) {
      githubAccount = GHCompatibilityUtil.requestNewAccountForServer(serverPath, project);
    }
    else if (accounts.size() == 1) {
      githubAccount = accounts.get(0);
    }
    else {
      GithubChooseAccountDialog chooseAccountDialog = new GithubChooseAccountDialog(project,
                                                                                    null,
                                                                                    accounts,
                                                                                    GithubBundle.message("account.choose.for", serverPath),
                                                                                    false,
                                                                                    true);
      DialogManager.show(chooseAccountDialog);
      if (chooseAccountDialog.isOK()) {
        githubAccount = chooseAccountDialog.getAccount();
      }
      else {
        GithubNotifications.showError(project,
                                      GithubNotificationIdsHolder.REBASE_ACCOUNT_NOT_FOUND,
                                      GithubBundle.message("rebase.error"),
                                      GithubBundle.message("rebase.error.no.suitable.account.found"));
        return;
      }
    }
    if (githubAccount == null) {
      GithubNotifications.showError(project,
                                    GithubNotificationIdsHolder.REBASE_ACCOUNT_NOT_FOUND,
                                    GithubBundle.message("rebase.error"),
                                    GithubBundle.message("rebase.error.no.suitable.account.found"));
      return;
    }

    new SyncForkTask(project, Git.getInstance(), githubAccount,
                     originMapping.getRemote().getRepository(),
                     originMapping.getRepository().getRepositoryPath()).queue();
  }
@Override
  public void actionPerformed(@NotNull AnActionEvent e)