public boolean checkAction(@NotNull String targetBranch) {
    DiffInfo info = getDiffInfoWithModal(targetBranch);
    if (info == null) {
      return true;
    }
    if (info.getInfo().getBranchToHeadCommits(myGitRepository).isEmpty()) {
      GithubNotifications.showWarningDialog(
          myProject,
          CANNOT_CREATE_PULL_REQUEST,
          "Can't create empty pull request: the branch"
              + getCurrentBranch()
              + " in fully merged to the branch "
              + targetBranch
              + ".");
      return false;
    }
    if (info.getInfo().getHeadToBranchCommits(myGitRepository).isEmpty()) {
      return GithubNotifications.showYesNoDialog(
              myProject,
              "The branch"
                  + targetBranch
                  + " in not fully merged to the branch "
                  + getCurrentBranch(),
              "Do you want to proceed anyway?")
          == Messages.YES;
    }

    return true;
  }
  public boolean checkAction(@Nullable final BranchInfo branch) {
    if (branch == null) {
      GithubNotifications.showWarningDialog(
          myProject, CANNOT_CREATE_PULL_REQUEST, "Target branch is not selected");
      return false;
    }

    DiffInfo info;
    try {
      info =
          GithubUtil.computeValueInModal(
              myProject,
              "Collecting diff data...",
              new ThrowableConvertor<ProgressIndicator, DiffInfo, IOException>() {
                @Override
                public DiffInfo convert(ProgressIndicator indicator) throws IOException {
                  return GithubUtil.runInterruptable(
                      indicator,
                      new ThrowableComputable<DiffInfo, IOException>() {
                        @Override
                        public DiffInfo compute() throws IOException {
                          return getDiffInfo(branch);
                        }
                      });
                }
              });
    } catch (IOException e) {
      GithubNotifications.showError(myProject, "Can't collect diff data", e);
      return true;
    }
    if (info == null) {
      return true;
    }

    ForkInfo fork = branch.getForkInfo();

    String localBranchName = "'" + myCurrentBranch + "'";
    String targetBranchName = "'" + fork.getRemoteName() + "/" + branch.getRemoteName() + "'";
    if (info.getInfo().getBranchToHeadCommits(myGitRepository).isEmpty()) {
      return GithubNotifications.showYesNoDialog(
          myProject,
          "Do you want to proceed anyway?",
          "Empty pull request: the branch "
              + localBranchName
              + " is fully merged to the branch "
              + targetBranchName);
    }
    if (!info.getInfo().getHeadToBranchCommits(myGitRepository).isEmpty()) {
      return GithubNotifications.showYesNoDialog(
          myProject,
          "Do you want to proceed anyway?",
          "The branch "
              + targetBranchName
              + " is not fully merged to the branch "
              + localBranchName);
    }

    return true;
  }
  @NotNull
  private static DiffDescription getDefaultDescriptionMessage(
      @NotNull String branch, @Nullable DiffInfo info, @NotNull GitRepository gitRepository) {
    if (info == null) {
      return new DiffDescription(branch, null, null);
    }

    if (info.getInfo().getBranchToHeadCommits(gitRepository).size() != 1) {
      return new DiffDescription(branch, info.getFrom(), null);
    }

    GitCommit commit = info.getInfo().getBranchToHeadCommits(gitRepository).get(0);
    return new DiffDescription(branch, commit.getSubject(), commit.getFullMessage());
  }
  public void showDiffDialog(@NotNull String branch) {
    if (canShowDiff()) {
      DiffInfo info = getDiffInfoWithModal(branch);
      if (info == null) {
        GithubNotifications.showErrorDialog(myProject, "Can't Show Diff", "Can't get diff info");
        return;
      }

      GitCompareBranchesDialog dialog =
          new GitCompareBranchesDialog(
              myProject, info.getTo(), info.getFrom(), info.getInfo(), myGitRepository);
      dialog.show();
    }
  }
  public void showDiffDialog(@Nullable final BranchInfo branch) {
    if (branch == null) {
      GithubNotifications.showWarningDialog(
          myProject, "Can't Show Diff", "Target branch is not selected");
      return;
    }

    DiffInfo info;
    try {
      info =
          GithubUtil.computeValueInModal(
              myProject,
              "Collecting diff data...",
              new ThrowableConvertor<ProgressIndicator, DiffInfo, IOException>() {
                @Override
                public DiffInfo convert(ProgressIndicator indicator) throws IOException {
                  return GithubUtil.runInterruptable(
                      indicator,
                      new ThrowableComputable<DiffInfo, IOException>() {
                        @Override
                        public DiffInfo compute() throws IOException {
                          return getDiffInfo(branch);
                        }
                      });
                }
              });
    } catch (IOException e) {
      GithubNotifications.showError(myProject, "Can't collect diff data", e);
      return;
    }
    if (info == null) {
      GithubNotifications.showErrorDialog(myProject, "Can't Show Diff", "Can't collect diff data");
      return;
    }

    GitCompareBranchesDialog dialog =
        new GitCompareBranchesDialog(
            myProject, info.getTo(), info.getFrom(), info.getInfo(), myGitRepository, true);
    dialog.show();
  }