use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitMergeProvider method resolveMergeHead.
@Nullable
private GitRevisionNumber resolveMergeHead(@NotNull VirtualFile root) {
try {
return GitRevisionNumber.resolve(myProject, root, MERGE_HEAD);
} catch (VcsException e) {
// this may be not a bug, just cherry-pick
LOG.info("Couldn't resolve the MERGE_HEAD in " + root + ": " + e.getMessage());
}
try {
return GitRevisionNumber.resolve(myProject, root, CHERRY_PICK_HEAD);
} catch (VcsException e) {
LOG.info("Couldn't resolve the CHERRY_PICK_HEAD in " + root + ": " + e.getMessage());
}
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(root);
assert repository != null;
File rebaseApply = repository.getRepositoryFiles().getRebaseApplyDir();
GitRevisionNumber rebaseRevision = readRevisionFromFile(new File(rebaseApply, "original-commit"));
if (rebaseRevision != null)
return rebaseRevision;
File rebaseMerge = repository.getRepositoryFiles().getRebaseMergeDir();
GitRevisionNumber mergeRevision = readRevisionFromFile(new File(rebaseMerge, "stopped-sha"));
if (mergeRevision != null)
return mergeRevision;
return null;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitPullDialog method updateBranches.
private void updateBranches() {
final String selectedRemote = getRemote();
myBranchChooser.removeAllElements();
if (selectedRemote == null) {
return;
}
GitRepository repository = getRepository();
if (repository == null) {
return;
}
GitBranchTrackInfo trackInfo = GitUtil.getTrackInfoForCurrentBranch(repository);
GitRemoteBranch currentRemoteBranch = trackInfo == null ? null : trackInfo.getRemoteBranch();
List<GitRemoteBranch> remoteBranches = new ArrayList<>(repository.getBranches().getRemoteBranches());
Collections.sort(remoteBranches);
myBranchChooser.setElements(ContainerUtil.mapNotNull(remoteBranches, new Function<GitRemoteBranch, String>() {
@Override
public String fun(GitRemoteBranch branch) {
return branch.getRemote().getName().equals(selectedRemote) ? branch.getNameForLocalOperations() : null;
}
}), false);
if (currentRemoteBranch != null && currentRemoteBranch.getRemote().getName().equals(selectedRemote)) {
myBranchChooser.setElementMarked(currentRemoteBranch.getNameForLocalOperations(), true);
}
validateDialog();
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitPullDialog method getRepository.
@Nullable
private GitRepository getRepository() {
VirtualFile root = gitRoot();
GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository is null for " + root);
return null;
}
return repository;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitPullDialog method updateRemotes.
private void updateRemotes() {
GitRepository repository = getRepository();
if (repository == null) {
return;
}
GitRemote currentRemote = getCurrentOrDefaultRemote(repository);
myRemote.setRenderer(getGitRemoteListCellRenderer(currentRemote != null ? currentRemote.getName() : null));
myRemote.removeAllItems();
for (GitRemote remote : repository.getRemotes()) {
myRemote.addItem(remote);
}
myRemote.setSelectedItem(currentRemote);
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GroupedPushResult method group.
@NotNull
static GroupedPushResult group(@NotNull Map<GitRepository, GitPushRepoResult> results) {
Map<GitRepository, GitPushRepoResult> successful = ContainerUtil.newHashMap();
Map<GitRepository, GitPushRepoResult> rejected = ContainerUtil.newHashMap();
Map<GitRepository, GitPushRepoResult> customRejected = ContainerUtil.newHashMap();
Map<GitRepository, GitPushRepoResult> errors = ContainerUtil.newHashMap();
for (Map.Entry<GitRepository, GitPushRepoResult> entry : results.entrySet()) {
GitRepository repository = entry.getKey();
GitPushRepoResult result = entry.getValue();
if (result.getType() == GitPushRepoResult.Type.REJECTED_NO_FF) {
rejected.put(repository, result);
} else if (result.getType() == GitPushRepoResult.Type.ERROR) {
errors.put(repository, result);
} else if (result.getType() == GitPushRepoResult.Type.REJECTED_OTHER) {
customRejected.put(repository, result);
} else {
successful.put(repository, result);
}
}
return new GroupedPushResult(successful, errors, rejected, customRejected);
}
Aggregations