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; }
@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(); } }