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; }
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; }