*/
package git4idea.push;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.VcsException;
import git4idea.GitBranch;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author Kirill Likhodedov
*/
public class GitPushSpec {
- private static final Logger LOG = Logger.getInstance(GitPushSpec.class);
-
- private final GitRemote myRemote;
+ @NotNull private final GitRemote myRemote;
@NotNull private final GitBranch mySource;
@NotNull private final GitBranch myDest;
- private final boolean myPushAll;
GitPushSpec(@NotNull GitRemote remote, @NotNull GitBranch source, @NotNull GitBranch dest) {
myRemote = remote;
mySource = source;
myDest = dest;
- myPushAll = false;
- }
-
- private GitPushSpec() {
- myRemote = null;
- mySource = null;
- myDest = null;
- myPushAll = true;
}
- static GitPushSpec pushAllSpec() {
- return new GitPushSpec();
- }
-
- @Nullable
+ @NotNull
public GitRemote getRemote() {
return myRemote;
}
return myDest;
}
- /**
- * Parses the refspec to identify local branches that are to be pushed together with remote "destination" branches.
- * @throws VcsException When looking for thacking branches.
- * TODO read tracking information from the config file, i.e. getting rid from the possible exception here.
- */
- @NotNull
- static List<GitBranchPair> getBranchesForPushAll(@NotNull GitRepository repository) throws VcsException {
- List<GitBranchPair> sourceDests = new ArrayList<GitBranchPair>();
- for (GitBranch branch : repository.getBranches().getLocalBranches()) {
- GitBranchPair forBranch = findSourceDestForBranch(repository, branch);
- if (forBranch != null) {
- sourceDests.add(forBranch);
- }
- }
- return sourceDests;
- }
-
- public boolean isPushAll() {
- return myPushAll;
- }
-
@Nullable
private static GitBranchPair findSourceDestForBranch(GitRepository repository, GitBranch branch) throws VcsException {
GitBranch trackedBranch = branch.tracked(repository.getProject(), repository.getRoot());