@Override
    @NbBundle.Messages({
      "ComparePullRequestPropertyChangeListener.message.no.compare=There isn't anything to compare.",
      "ComparePullRequestPropertyChangeListener.message.conflict=Can't automatically merge."
    })
    public void propertyChange(PropertyChangeEvent evt) {
      if (evt != null
          && !evt.getPropertyName().equals(CreatePullRequestPanel.PROP_COMPARE_PULL_REQUEST)) {
        return;
      }
      errorMessage = null;
      compare = null;
      panel.setCompareButtonEnabled(false);
      try {
        // validate
        // same commit
        RepositoryBranch baseBranch = panel.getSelectedBaseBranch();
        RepositoryBranch headBranch = panel.getSelectedHeadBranch();
        if (baseBranch.getCommit().getSha().equals(headBranch.getCommit().getSha())) {
          panel.setErrorMessage(
              Bundle.ComparePullRequestPropertyChangeListener_message_no_compare());
          descriptor.setValid(false);
        }

        // compare two commits
        compare();
        if (compare == null) {
          panel.setErrorMessage(errorMessage);
          descriptor.setValid(false);
          return;
        }

        String status = compare.getStatus();
        switch (status) {
          case "identical": // no break NOI18N
          case "behind": // NOI18N
            panel.setErrorMessage(
                Bundle.ComparePullRequestPropertyChangeListener_message_no_compare());
            descriptor.setValid(false);
            return;
          case "diverged": // NOI18N
            panel.setErrorMessage(
                Bundle.ComparePullRequestPropertyChangeListener_message_conflict());
            descriptor.setValid(true);
            return;
          case "ahead": // NOI18N
            break;
          default:
            break;
        }

        // everything ok
        panel.setErrorMessage(""); // NOI18N
        descriptor.setValid(true);
      } finally {
        panel.setCompareButtonEnabled(true);
      }
    }
 private void compare() {
   Repository headRepo = panel.getSelectedHeadRepository();
   final User owner = headRepo.getOwner();
   BaseProgressUtils.runOffEventDispatchThread(
       new Runnable() {
         @Override
         public void run() {
           try {
             compare =
                 repository.compare(
                     panel.getSelectedBaseBranch().getName(),
                     owner.getLogin() + ":" + panel.getSelectedHeadBranch().getName());
           } catch (IOException ex) {
             errorMessage = ex.getMessage();
           }
         }
       },
       "Comparing...",
       new AtomicBoolean(),
       false); // NOI18N
 }