public void addOrResetGitRemote(CloudGitApplication application, GitRepository repository)
     throws ServerRuntimeException {
   GitRemote gitRemote = GitUtil.findRemoteByName(repository, getRemoteName());
   if (gitRemote == null) {
     addGitRemote(application);
   } else if (!gitRemote.getUrls().contains(application.getGitUrl())) {
     resetGitRemote(application);
   }
 }
Exemplo n.º 2
0
 @Nullable
 static String findGithubRemoteUrl(@NotNull GitRepository repository) {
   for (GitRemote remote : repository.getRemotes()) {
     for (String url : remote.getUrls()) {
       if (isGithubUrl(url)) {
         return url;
       }
     }
   }
   return null;
 }
 private void doLoadForksFromGit(@NotNull ProgressIndicator indicator) {
   for (GitRemote remote : myGitRepository.getRemotes()) {
     for (String url : remote.getUrls()) {
       if (GithubUrlUtil.isGithubUrl(url)) {
         GithubFullPath path = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
         if (path != null) {
           doAddFork(path, remote.getName(), indicator);
           break;
         }
       }
     }
   }
 }
Exemplo n.º 4
0
  @Nullable
  public static String getGithubUrl(final GitRemote gitRemote) {
    final GithubSettings githubSettings = GithubSettings.getInstance();
    final String host = githubSettings.getHost();
    final String username = githubSettings.getLogin();

    // TODO this doesn't work with organizational accounts
    final String userRepoMarkerSSHProtocol = host + ":" + username + "/";
    final String userRepoMarkerOtherProtocols = host + "/" + username + "/";
    for (String pushUrl : gitRemote.getUrls()) {
      if (pushUrl.contains(userRepoMarkerSSHProtocol)
          || pushUrl.contains(userRepoMarkerOtherProtocols)) {
        return pushUrl;
      }
    }
    return null;
  }