本文整理汇总了Java中git4idea.commands.GitCommandResult类的典型用法代码示例。如果您正苦于以下问题:Java GitCommandResult类的具体用法?Java GitCommandResult怎么用?Java GitCommandResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitCommandResult类属于git4idea.commands包,在下文中一共展示了GitCommandResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasBranch
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
/**
* Asks the remote repository if it's aware of a given branch.
*/
public boolean hasBranch(Repository repository, GitLocalBranch branch) throws BranchException
{
GitCommandResult result = this.git.lsRemote(
repository.project(),
repository.root(),
this.remote,
this.remote.getFirstUrl(),
branch.getFullName(),
"--heads"
);
if (!result.success()) {
throw BranchException.couldNotFetchBranchesFromRemoteRepository(result.getOutputAsJoinedString());
}
return (result.getOutput().size() == 1);
}
开发者ID:ben-gibson,项目名称:GitLink,代码行数:21,代码来源:Remote.java
示例2: createPullRequest
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
public void createPullRequest(@NotNull final BranchInfo branch,
@NotNull final String title,
@NotNull final String description) {
new Task.Backgroundable(myProject, "Creating pull request...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
LOG.info("Pushing current branch");
indicator.setText("Pushing current branch...");
GitCommandResult result = myGit.push(myGitRepository, myRemoteName, myRemoteUrl, myCurrentBranch, true);
if (!result.success()) {
GithubNotifications.showError(myProject, CANNOT_CREATE_PULL_REQUEST, "Push failed:<br/>" + result.getErrorOutputAsHtmlString());
return;
}
LOG.info("Creating pull request");
indicator.setText("Creating pull request...");
GithubPullRequest request = doCreatePullRequest(indicator, branch, title, description);
if (request == null) {
return;
}
GithubNotifications.showInfoURL(myProject, "Successfully created pull request",
"Pull request #" + request.getNumber(), request.getHtmlUrl());
}
}.queue();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GithubCreatePullRequestWorker.java
示例3: proposeSmartReset
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private GitCommandResult proposeSmartReset(@NotNull GitLocalChangesWouldBeOverwrittenDetector detector,
@NotNull final GitRepository repository, @NotNull final String target) {
Collection<String> absolutePaths = GitUtil.toAbsolute(repository.getRoot(), detector.getRelativeFilePaths());
List<Change> affectedChanges = GitUtil.findLocalChangesForPaths(myProject, repository.getRoot(), absolutePaths, false);
int choice = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "reset", "&Hard Reset");
if (choice == GitSmartOperationDialog.SMART_EXIT_CODE) {
final Ref<GitCommandResult> result = Ref.create();
new GitPreservingProcess(myProject, myFacade, myGit, Collections.singleton(repository.getRoot()), "reset", target,
GitVcsSettings.UpdateChangesPolicy.STASH, myIndicator,
new Runnable() {
@Override
public void run() {
result.set(myGit.reset(repository, myMode, target));
}
}).execute();
return result.get();
}
if (choice == GitSmartOperationDialog.FORCE_EXIT_CODE) {
return myGit.reset(repository, GitResetMode.HARD, target);
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GitResetOperation.java
示例4: notifyResult
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private void notifyResult(@NotNull Map<GitRepository, GitCommandResult> results) {
Map<GitRepository, GitCommandResult> successes = ContainerUtil.newHashMap();
Map<GitRepository, GitCommandResult> errors = ContainerUtil.newHashMap();
for (Map.Entry<GitRepository, GitCommandResult> entry : results.entrySet()) {
GitCommandResult result = entry.getValue();
GitRepository repository = entry.getKey();
if (result.success()) {
successes.put(repository, result);
}
else {
errors.put(repository, result);
}
}
if (errors.isEmpty()) {
myNotifier.notifySuccess("", "Reset successful");
}
else if (!successes.isEmpty()) {
myNotifier.notifyImportantWarning("Reset partially failed",
"Reset was successful for " + joinRepos(successes.keySet())
+ "<br/>but failed for " + joinRepos(errors.keySet()) + ": <br/>" + formErrorReport(errors));
}
else {
myNotifier.notifyError("Reset Failed", formErrorReport(errors));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GitResetOperation.java
示例5: validateRemoteUnderModal
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@Nullable
private String validateRemoteUnderModal(@NotNull String name, @NotNull final String url) throws ProcessCanceledException {
if (url.isEmpty()) {
return "URL can't be empty";
}
if (!GitRefNameValidator.getInstance().checkInput(name)) {
return "Remote name contains illegal characters";
}
return ProgressManager.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<String, ProcessCanceledException>() {
@Override
public String compute() throws ProcessCanceledException {
final GitCommandResult result = myGit.lsRemote(myRepository.getProject(), VfsUtilCore.virtualToIoFile(myRepository.getRoot()), url);
return !result.success() ? "Remote URL test failed: " + result.getErrorOutputAsHtmlString() : null;
}
}, "Checking URL...", true, myRepository.getProject());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GitDefineRemoteDialog.java
示例6: findFilesWithoutAttrs
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private Collection<VirtualFile> findFilesWithoutAttrs(@NotNull VirtualFile root, @NotNull Collection<VirtualFile> files) {
GitRepository repository = myPlatformFacade.getRepositoryManager(myProject).getRepositoryForRoot(root);
if (repository == null) {
LOG.warn("Repository is null for " + root);
return Collections.emptyList();
}
Collection<String> interestingAttributes = Arrays.asList(GitAttribute.TEXT.getName(), GitAttribute.CRLF.getName());
GitCommandResult result = myGit.checkAttr(repository, interestingAttributes, files);
if (!result.success()) {
LOG.warn(String.format("Couldn't git check-attr. Attributes: %s, files: %s", interestingAttributes, files));
return Collections.emptyList();
}
GitCheckAttrParser parser = GitCheckAttrParser.parse(result.getOutput());
Map<String, Collection<GitAttribute>> attributes = parser.getAttributes();
Collection<VirtualFile> filesWithoutAttrs = new ArrayList<VirtualFile>();
for (VirtualFile file : files) {
ProgressIndicatorProvider.checkCanceled();
String relativePath = FileUtil.getRelativePath(root.getPath(), file.getPath(), '/');
Collection<GitAttribute> attrs = attributes.get(relativePath);
if (attrs == null || !attrs.contains(GitAttribute.TEXT) && !attrs.contains(GitAttribute.CRLF)) {
filesWithoutAttrs.add(file);
}
}
return filesWithoutAttrs;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GitCrlfProblemsDetector.java
示例7: fetchNatively
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private static GitFetchResult fetchNatively(@NotNull GitRepository repository, @NotNull GitRemote remote, @Nullable String branch) {
Git git = ServiceManager.getService(Git.class);
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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GitFetcher.java
示例8: initOrNotifyError
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
protected boolean initOrNotifyError(@NotNull final VirtualFile projectDir) {
VcsNotifier vcsNotifier = VcsNotifier.getInstance(myProject);
GitCommandResult result = myGit.init(myProject, projectDir);
if (result.success()) {
refreshVcsDir(projectDir, GitUtil.DOT_GIT);
vcsNotifier.notifySuccess("Created Git repository in " + projectDir.getPresentableUrl());
return true;
}
else {
if (myVcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
vcsNotifier.notifyError("Couldn't git init " + projectDir.getPresentableUrl(), result.getErrorOutputAsHtmlString());
LOG.info(result.getErrorOutputAsHtmlString());
}
return false;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitIntegrationEnabler.java
示例9: loadRoot
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
/**
* 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;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitStashChangesSaver.java
示例10: pushChangesToRemoteRepo
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private boolean pushChangesToRemoteRepo(final Project project, final GitRepository localRepository,
final com.microsoft.alm.sourcecontrol.webapi.model.GitRepository remoteRepository,
final ServerContext localContext, final ProgressIndicator indicator) {
localRepository.update();
final String remoteGitUrl = UrlHelper.getCmdLineFriendlyUrl(remoteRepository.getRemoteUrl());
//push all branches in local Git repo to remote
indicator.setText(TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_GIT_PUSH));
final Git git = ServiceManager.getService(Git.class);
final GitCommandResult result = git.push(localRepository, REMOTE_ORIGIN, remoteGitUrl, "*", true);
if (!result.success()) {
logger.error("pushChangesToRemoteRepo: push to remote: {} failed with error: {}, outuput: {}",
remoteGitUrl, result.getErrorOutputAsJoinedString(), result.getOutputAsJoinedString());
notifyImportError(project,
result.getErrorOutputAsJoinedString(),
ACTION_NAME, localContext);
return false;
}
return true;
}
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:22,代码来源:ImportPageModelImpl.java
示例11: push
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private GtPushResult push(final TagsPushSpec pushSpec, final GitRepository repository,
final GitRemote remote, final String url) {
final GitLineHandlerListener progressListener = GitStandardProgressAnalyzer.createListener(progressIndicator);
final GitPushRejectedDetector rejectedDetector = new GitPushRejectedDetector();
GitCommandResult result = git.runCommand(() -> {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(),
GitCommand.PUSH);
h.setUrl(url);
h.setSilent(false);
h.setStdoutSuppressed(false);
h.addLineListener(progressListener);
h.addLineListener(rejectedDetector);
h.addProgressParameter();
h.addParameters(remote.getName());
h.addParameters(pushSpec.specs());
return h;
});
if (rejectedDetector.rejected()) {
return GtPushResult.reject(rejectedDetector.getRejectedBranches());
} else {
return translate(result);
}
}
开发者ID:zielu,项目名称:GitToolBox,代码行数:24,代码来源:GitTagsPusher.java
示例12: pushNatively
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private GitSimplePushResult pushNatively(GitRepository repository, GitPushSpec pushSpec, @NotNull String url) {
GitPushRejectedDetector rejectedDetector = new GitPushRejectedDetector();
GitLineHandlerListener progressListener = GitStandardProgressAnalyzer.createListener(myProgressIndicator);
GitCommandResult res = myGit.push(repository, pushSpec, url, rejectedDetector, progressListener);
if (rejectedDetector.rejected()) {
Collection<String> rejectedBranches = rejectedDetector.getRejectedBranches();
return GitSimplePushResult.reject(rejectedBranches);
}
else if (res.success()) {
return GitSimplePushResult.success();
}
else {
return GitSimplePushResult.error(res.getErrorOutputAsHtmlString());
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GitPusher.java
示例13: loadRoot
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
/**
* 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) throws VcsException {
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);
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;
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:GitStashChangesSaver.java
示例14: doDeleteRemote
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private boolean doDeleteRemote(@NotNull String branchName, @NotNull Collection<GitRepository> repositories) {
GitCompoundResult result = new GitCompoundResult(myProject);
for (GitRepository repository : repositories) {
Pair<String, String> pair = splitNameOfRemoteBranch(branchName);
String remote = pair.getFirst();
String branch = pair.getSecond();
GitCommandResult res = pushDeletion(repository, remote, branch);
result.append(repository, res);
repository.update();
}
if (!result.totalSuccess()) {
Notificator.getInstance(myProject).notifyError("Failed to delete remote branch " + branchName,
result.getErrorOutputWithReposIndication());
}
return result.totalSuccess();
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GitDeleteRemoteBranchOperation.java
示例15: pushDeletion
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private GitCommandResult pushDeletion(@NotNull GitRepository repository, @NotNull String remoteName, @NotNull String branchName) {
GitRemote remote = getRemoteByName(repository, remoteName);
if (remote == null) {
String error = "Couldn't find remote by name: " + remoteName;
LOG.error(error);
return GitCommandResult.error(error);
}
String remoteUrl = remote.getFirstUrl();
if (remoteUrl == null) {
LOG.warn("No urls are defined for remote: " + remote);
return GitCommandResult.error("There is no urls defined for remote " + remote.getName());
}
if (GitHttpAdapter.shouldUseJGit(remoteUrl)) {
String fullBranchName = branchName.startsWith(GitBranch.REFS_HEADS_PREFIX) ? branchName : GitBranch.REFS_HEADS_PREFIX + branchName;
String spec = ":" + fullBranchName;
GitSimplePushResult simplePushResult = GitHttpAdapter.push(repository, remote.getName(), remoteUrl, spec);
return convertSimplePushResultToCommandResult(simplePushResult);
}
else {
return pushDeletionNatively(repository, remoteName, remoteUrl, branchName);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:GitDeleteRemoteBranchOperation.java
示例16: execute
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
public void execute() {
saveAllDocuments();
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
Map<GitRepository, GitCommandResult> results = ContainerUtil.newHashMap();
try {
for (Map.Entry<GitRepository, VcsFullCommitDetails> entry : myCommits.entrySet()) {
GitRepository repository = entry.getKey();
VirtualFile root = repository.getRoot();
String target = entry.getValue().getId().asString();
GitLocalChangesWouldBeOverwrittenDetector detector = new GitLocalChangesWouldBeOverwrittenDetector(root, RESET);
GitCommandResult result = myGit.reset(repository, myMode, target, detector);
if (!result.success() && detector.wasMessageDetected()) {
GitCommandResult smartResult = proposeSmartReset(detector, repository, target);
if (smartResult != null) {
result = smartResult;
}
}
results.put(repository, result);
repository.update();
VfsUtil.markDirtyAndRefresh(true, true, false, root);
VcsDirtyScopeManager.getInstance(myProject).dirDirtyRecursively(root);
}
}
finally {
DvcsUtil.workingTreeChangeFinished(myProject, token);
}
notifyResult(results);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitResetOperation.java
示例17: formErrorReport
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private static String formErrorReport(@NotNull Map<GitRepository, GitCommandResult> errorResults) {
MultiMap<String, GitRepository> grouped = groupByResult(errorResults);
if (grouped.size() == 1) {
return "<code>" + grouped.keySet().iterator().next() + "</code>";
}
return StringUtil.join(grouped.entrySet(), new Function<Map.Entry<String, Collection<GitRepository>>, String>() {
@NotNull
@Override
public String fun(@NotNull Map.Entry<String, Collection<GitRepository>> entry) {
return joinRepos(entry.getValue()) + ":<br/><code>" + entry.getKey() + "</code>";
}
}, "<br/>");
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GitResetOperation.java
示例18: groupByResult
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@NotNull
private static MultiMap<String, GitRepository> groupByResult(@NotNull Map<GitRepository, GitCommandResult> results) {
MultiMap<String, GitRepository> grouped = MultiMap.create();
for (Map.Entry<GitRepository, GitCommandResult> entry : results.entrySet()) {
grouped.putValue(entry.getValue().getErrorOutputAsHtmlString(), entry.getKey());
}
return grouped;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GitResetOperation.java
示例19: addRemoteUnderModal
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
private void addRemoteUnderModal(@NotNull final String remoteName, @NotNull final String remoteUrl) {
ProgressManager.getInstance().run(new Task.Modal(myRepository.getProject(), "Adding remote...", true) {
private GitCommandResult myResult;
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
myResult = myGit.addRemote(myRepository, remoteName, remoteUrl);
myRepository.update();
}
@Override
public void onSuccess() {
if (myResult.success()) {
updateComponents(myPushSupport.getDefaultTarget(myRepository));
if (myFireOnChangeAction != null) {
myFireOnChangeAction.run();
}
}
else {
String message = "Couldn't add remote: " + myResult.getErrorOutputAsHtmlString();
LOG.warn(message);
Messages.showErrorDialog(myProject, message, "Add Remote");
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GitPushTargetPanel.java
示例20: doPush
import git4idea.commands.GitCommandResult; //导入依赖的package包/类
@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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GitPushOperation.java
注:本文中的git4idea.commands.GitCommandResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论