use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GitBranchUtil method findRemoteByNameOrLogError.
@Nullable
@Deprecated
public static GitRemote findRemoteByNameOrLogError(@NotNull Project project, @NotNull VirtualFile root, @NotNull String remoteName) {
GitRepository repository = GitUtil.getRepositoryForRootOrLogError(project, root);
if (repository == null) {
return null;
}
GitRemote remote = GitUtil.findRemoteByName(repository, remoteName);
if (remote == null) {
LOG.warn("Couldn't find remote with name " + remoteName);
return null;
}
return remote;
}
use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class CloudGitDeploymentRuntime method addOrResetGitRemote.
public void addOrResetGitRemote(CloudGitApplication application, GitRepository repository) throws ServerRuntimeException {
String gitUrl = application.getGitUrl();
if (myRemoteName == null) {
for (GitRemote gitRemote : repository.getRemotes()) {
if (gitRemote.getUrls().contains(gitUrl)) {
myRemoteName = gitRemote.getName();
return;
}
}
}
GitRemote gitRemote = GitUtil.findRemoteByName(repository, getRemoteName());
if (gitRemote == null) {
addGitRemote(application);
} else if (!gitRemote.getUrls().contains(gitUrl)) {
resetGitRemote(application);
}
}
use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GitDeleteRemoteBranchOperation method doDeleteRemote.
private boolean doDeleteRemote(@NotNull String branchName, @NotNull Collection<GitRepository> repositories) {
Couple<String> pair = splitNameOfRemoteBranch(branchName);
String remoteName = pair.getFirst();
String branch = pair.getSecond();
GitCompoundResult result = new GitCompoundResult(myProject);
for (GitRepository repository : repositories) {
GitCommandResult res;
GitRemote remote = getRemoteByName(repository, remoteName);
if (remote == null) {
String error = "Couldn't find remote by name: " + remoteName;
LOG.error(error);
res = GitCommandResult.error(error);
} else {
res = pushDeletion(repository, remote, branch);
if (!res.success() && isAlreadyDeletedError(res.getErrorOutputAsJoinedString())) {
res = myGit.remotePrune(repository, remote);
}
}
result.append(repository, res);
repository.update();
}
if (!result.totalSuccess()) {
VcsNotifier.getInstance(myProject).notifyError("Failed to delete remote branch " + branchName, result.getErrorOutputWithReposIndication());
}
return result.totalSuccess();
}
use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GitVcsSettings method getPushTarget.
@Nullable
public GitRemoteBranch getPushTarget(@NotNull GitRepository repository, @NotNull String sourceBranch) {
PushTargetInfo targetInfo = find(myState.PUSH_TARGETS, repository, sourceBranch);
if (targetInfo == null)
return null;
GitRemote remote = GitUtil.findRemoteByName(repository, targetInfo.targetRemoteName);
if (remote == null)
return null;
return GitUtil.findOrCreateRemoteBranch(repository, remote, targetInfo.targetBranchName);
}
use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GitRefManager method getAllRemoteBranches.
@NotNull
private static Map<String, GitRemote> getAllRemoteBranches(@NotNull GitRepository repository) {
Set<GitRemoteBranch> all = new HashSet<>(repository.getBranches().getRemoteBranches());
Map<String, GitRemote> allRemote = ContainerUtil.newHashMap();
for (GitRemoteBranch remoteBranch : all) {
allRemote.put(remoteBranch.getName(), remoteBranch.getRemote());
}
return allRemote;
}
Aggregations