Search in sources :

Example 1 with GitStandardRemoteBranch

use of git4idea.GitStandardRemoteBranch in project intellij-community by JetBrains.

the class GitPushTarget method parse.

@NotNull
public static GitPushTarget parse(@NotNull GitRepository repository, @Nullable String remoteName, @NotNull String branchName) throws ParseException {
    if (remoteName == null) {
        throw new ParseException("No remotes defined", -1);
    }
    if (!GitRefNameValidator.getInstance().checkInput(branchName)) {
        throw new ParseException("Invalid destination branch name: " + branchName, -1);
    }
    GitRemote remote = findRemote(repository.getRemotes(), remoteName);
    if (remote == null) {
        LOG.error("Remote [" + remoteName + "] is not found among " + repository.getRemotes());
        throw new ParseException("Invalid remote: " + remoteName, -1);
    }
    GitRemoteBranch existingRemoteBranch = findRemoteBranch(repository, remote, branchName);
    if (existingRemoteBranch != null) {
        return new GitPushTarget(existingRemoteBranch, false);
    }
    GitRemoteBranch rb = new GitStandardRemoteBranch(remote, branchName);
    return new GitPushTarget(rb, true);
}
Also used : GitRemote(git4idea.repo.GitRemote) GitStandardRemoteBranch(git4idea.GitStandardRemoteBranch) ParseException(java.text.ParseException) GitRemoteBranch(git4idea.GitRemoteBranch) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GitStandardRemoteBranch

use of git4idea.GitStandardRemoteBranch in project intellij-community by JetBrains.

the class GitPushResultNotificationTest method to.

private static GitRemoteBranch to(String to) {
    int firstSlash = to.indexOf('/');
    GitRemote remote = new GitRemote(to.substring(0, firstSlash), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    return new GitStandardRemoteBranch(remote, to.substring(firstSlash + 1));
}
Also used : GitRemote(git4idea.repo.GitRemote) GitStandardRemoteBranch(git4idea.GitStandardRemoteBranch)

Aggregations

GitStandardRemoteBranch (git4idea.GitStandardRemoteBranch)2 GitRemote (git4idea.repo.GitRemote)2 GitRemoteBranch (git4idea.GitRemoteBranch)1 ParseException (java.text.ParseException)1 NotNull (org.jetbrains.annotations.NotNull)1