use of git4idea.commands.GitCommandResult in project intellij-community by JetBrains.
the class GitStashChangesSaver method loadRoot.
/**
* Returns true if the root was loaded with conflict.
* False is returned in all other cases: in the case of success and in case of some other error.
*/
private boolean loadRoot(final VirtualFile root) {
LOG.info("loadRoot " + root);
myProgressIndicator.setText(GitHandlerUtil.formatOperationName("Unstashing changes to", root));
GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository is null for root " + root);
return false;
}
GitSimpleEventDetector conflictDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.MERGE_CONFLICT_ON_UNSTASH);
GitCommandResult result = myGit.stashPop(repository, conflictDetector);
VfsUtil.markDirtyAndRefresh(false, true, false, root);
if (result.success()) {
return false;
} else if (conflictDetector.hasHappened()) {
return true;
} else {
LOG.info("unstash failed " + result.getErrorOutputAsJoinedString());
GitUIUtil.notifyImportantError(myProject, "Couldn't unstash", "<br/>" + result.getErrorOutputAsHtmlString());
return false;
}
}
use of git4idea.commands.GitCommandResult in project intellij-community by JetBrains.
the class GitStashChangesSaver method save.
@Override
protected void save(@NotNull Collection<VirtualFile> rootsToSave) throws VcsException {
LOG.info("saving " + rootsToSave);
for (VirtualFile root : rootsToSave) {
final String message = GitHandlerUtil.formatOperationName("Stashing changes from", root);
LOG.info(message);
final String oldProgressTitle = myProgressIndicator.getText();
myProgressIndicator.setText(message);
GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository is null for root " + root);
} else {
GitCommandResult result = myGit.stashSave(repository, myStashMessage);
if (result.success() && somethingWasStashed(result)) {
myStashedRoots.add(root);
} else {
String error = "stash " + repository.getRoot() + ": " + result.getErrorOutputAsJoinedString();
if (!result.success()) {
throw new VcsException(error);
} else {
LOG.warn(error);
}
}
}
myProgressIndicator.setText(oldProgressTitle);
}
}
use of git4idea.commands.GitCommandResult in project intellij-community by JetBrains.
the class GitFetcher method fetchNatively.
@NotNull
private static GitFetchResult fetchNatively(@NotNull GitRepository repository, @NotNull GitRemote remote, @Nullable String branch) {
Git git = Git.getInstance();
String[] additionalParams = branch != null ? new String[] { getFetchSpecForBranch(branch, remote.getName()) } : ArrayUtil.EMPTY_STRING_ARRAY;
GitFetchPruneDetector pruneDetector = new GitFetchPruneDetector();
GitCommandResult result = git.fetch(repository, remote, Collections.<GitLineHandlerListener>singletonList(pruneDetector), additionalParams);
GitFetchResult fetchResult;
if (result.success()) {
fetchResult = GitFetchResult.success();
} else if (result.cancelled()) {
fetchResult = GitFetchResult.cancel();
} else {
fetchResult = GitFetchResult.error(result.getErrorOutputAsJoinedString());
}
fetchResult.addPruneInfo(pruneDetector.getPrunedRefs());
return fetchResult;
}
use of git4idea.commands.GitCommandResult in project intellij-community by JetBrains.
the class GitRenameBranchOperation method execute.
@Override
protected void execute() {
while (hasMoreRepositories()) {
GitRepository repository = next();
GitCommandResult result = myGit.renameBranch(repository, myCurrentName, myNewName);
if (result.success()) {
refresh(repository);
markSuccessful(repository);
} else {
fatalError("Couldn't rename " + myCurrentName + " to " + myNewName, result.getErrorOutputAsJoinedString());
return;
}
}
notifySuccess();
}
use of git4idea.commands.GitCommandResult in project intellij-community by JetBrains.
the class GitPushOperation method doPush.
@NotNull
private ResultWithOutput doPush(@NotNull GitRepository repository, @NotNull PushSpec<GitPushSource, GitPushTarget> pushSpec) {
GitPushTarget target = pushSpec.getTarget();
GitLocalBranch sourceBranch = pushSpec.getSource().getBranch();
GitRemoteBranch targetBranch = target.getBranch();
GitLineHandlerListener progressListener = GitStandardProgressAnalyzer.createListener(myProgressIndicator);
boolean setUpstream = pushSpec.getTarget().isNewBranchCreated() && !branchTrackingInfoIsSet(repository, sourceBranch);
String tagMode = myTagMode == null ? null : myTagMode.getArgument();
String spec = sourceBranch.getFullName() + ":" + targetBranch.getNameForRemoteOperations();
GitCommandResult res = myGit.push(repository, targetBranch.getRemote(), spec, myForce, setUpstream, tagMode, progressListener);
return new ResultWithOutput(res);
}
Aggregations