use of git4idea.repo.GitRepository 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.GitRepository in project intellij-community by JetBrains.
the class GitBranchUtil method getCommonBranches.
@NotNull
public static Collection<String> getCommonBranches(Collection<GitRepository> repositories, boolean local) {
Collection<String> commonBranches = null;
for (GitRepository repository : repositories) {
GitBranchesCollection branchesCollection = repository.getBranches();
Collection<String> names = local ? convertBranchesToNames(branchesCollection.getLocalBranches()) : getBranchNamesWithoutRemoteHead(branchesCollection.getRemoteBranches());
if (commonBranches == null) {
commonBranches = names;
} else {
commonBranches = ContainerUtil.intersection(commonBranches, names);
}
}
if (commonBranches != null) {
ArrayList<String> common = new ArrayList<>(commonBranches);
Collections.sort(common);
return common;
} else {
return Collections.emptyList();
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchWorker method loadCommitsToCompare.
private GitCommitCompareInfo loadCommitsToCompare(List<GitRepository> repositories, String branchName) {
GitCommitCompareInfo compareInfo = new GitCommitCompareInfo();
for (GitRepository repository : repositories) {
compareInfo.put(repository, loadCommitsToCompare(repository, branchName));
compareInfo.put(repository, loadTotalDiff(repository, branchName));
}
return compareInfo;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCheckoutNewBranchOperation method execute.
@Override
protected void execute() {
boolean fatalErrorHappened = false;
while (hasMoreRepositories() && !fatalErrorHappened) {
final GitRepository repository = next();
GitSimpleEventDetector unmergedDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_CHECKOUT);
GitCommandResult result = myGit.checkoutNewBranch(repository, myNewBranchName, unmergedDetector);
if (result.success()) {
refresh(repository);
markSuccessful(repository);
} else if (unmergedDetector.hasHappened()) {
fatalUnmergedFilesError();
fatalErrorHappened = true;
} else {
fatalError("Couldn't create new branch " + myNewBranchName, result.getErrorOutputAsJoinedString());
fatalErrorHappened = true;
}
}
if (!fatalErrorHappened) {
notifySuccess();
updateRecentBranch();
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCheckoutNewBranchOperation method rollback.
@Override
protected void rollback() {
GitCompoundResult checkoutResult = new GitCompoundResult(myProject);
GitCompoundResult deleteResult = new GitCompoundResult(myProject);
Collection<GitRepository> repositories = getSuccessfulRepositories();
for (GitRepository repository : repositories) {
GitCommandResult result = myGit.checkout(repository, myCurrentHeads.get(repository), null, true, false);
checkoutResult.append(repository, result);
if (result.success()) {
deleteResult.append(repository, myGit.branchDelete(repository, myNewBranchName, false));
}
refresh(repository);
}
if (checkoutResult.totalSuccess() && deleteResult.totalSuccess()) {
VcsNotifier.getInstance(myProject).notifySuccess("Rollback successful", String.format("Checked out %s and deleted %s on %s %s", stringifyBranchesByRepos(myCurrentHeads), code(myNewBranchName), StringUtil.pluralize("root", repositories.size()), successfulRepositoriesJoined()));
} else {
StringBuilder message = new StringBuilder();
if (!checkoutResult.totalSuccess()) {
message.append("Errors during checkout: ");
message.append(checkoutResult.getErrorOutputWithReposIndication());
}
if (!deleteResult.totalSuccess()) {
message.append("Errors during deleting ").append(code(myNewBranchName));
message.append(deleteResult.getErrorOutputWithReposIndication());
}
VcsNotifier.getInstance(myProject).notifyError("Error during rollback", message.toString());
}
}
Aggregations