@Nullable
  private ForkInfo doAddFork(
      @NotNull GithubFullPath path,
      @Nullable String remoteName,
      @NotNull ProgressIndicator indicator) {
    for (ForkInfo fork : myForks) {
      if (fork.getPath().equals(path)) {
        if (fork.getRemoteName() == null && remoteName != null) {
          fork.setRemoteName(remoteName);
        }
        return fork;
      }
    }

    try {
      List<String> branches = loadBranches(path, indicator);
      String defaultBranch = doLoadDefaultBranch(path, indicator);

      ForkInfo fork = new ForkInfo(path, branches, defaultBranch);
      myForks.add(fork);
      if (remoteName != null) {
        fork.setRemoteName(remoteName);
      }
      return fork;
    } catch (IOException e) {
      GithubNotifications.showWarning(
          myProject, "Can't load branches for " + path.getFullName(), e);
      return null;
    }
  }
  private void doConfigureRemote(@NotNull ForkInfo fork) {
    if (fork.getRemoteName() != null) return;

    GithubFullPath path = fork.getPath();
    String url = GithubUrlUtil.getCloneUrl(path);

    if (GithubUtil.addGithubRemote(myProject, myGitRepository, path.getUser(), url)) {
      fork.setRemoteName(path.getUser());
    }
  }
  @Nullable
  private ForkInfo findRepositoryByUser(
      @NotNull final ProgressIndicator indicator, @NotNull final String user) {
    for (ForkInfo fork : myForks) {
      if (StringUtil.equalsIgnoreCase(user, fork.getPath().getUser())) {
        return fork;
      }
    }

    try {
      GithubRepo repo =
          GithubUtil.runTask(
              myProject,
              myAuthHolder,
              indicator,
              new ThrowableConvertor<GithubConnection, GithubRepo, IOException>() {
                @Nullable
                @Override
                public GithubRepo convert(@NotNull GithubConnection connection) throws IOException {
                  try {
                    GithubRepoDetailed target =
                        GithubApiUtil.getDetailedRepoInfo(
                            connection, user, mySource.getRepository());
                    if (target.getSource() != null
                        && StringUtil.equals(
                            target.getSource().getUserName(), mySource.getUser())) {
                      return target;
                    }
                  } catch (IOException ignore) {
                    // such repo may not exist
                  }

                  return GithubApiUtil.findForkByUser(
                      connection, mySource.getUser(), mySource.getRepository(), user);
                }
              });

      if (repo == null) return null;
      return doAddFork(repo, indicator);
    } catch (IOException e) {
      GithubNotifications.showError(myProject, "Can't find repository", e);
      return null;
    }
  }