当前位置: 首页>>代码示例>>Java>>正文


Java GitRepository.update方法代码示例

本文整理汇总了Java中git4idea.repo.GitRepository.update方法的典型用法代码示例。如果您正苦于以下问题:Java GitRepository.update方法的具体用法?Java GitRepository.update怎么用?Java GitRepository.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git4idea.repo.GitRepository的用法示例。


在下文中一共展示了GitRepository.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addGithubRemote

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
public static boolean addGithubRemote(@NotNull Project project,
                                      @NotNull GitRepository repository,
                                      @NotNull String remote,
                                      @NotNull String url) {
  final GitSimpleHandler handler = new GitSimpleHandler(project, repository.getRoot(), GitCommand.REMOTE);
  handler.setSilent(true);

  try {
    handler.addParameters("add", remote, url);
    handler.run();
    if (handler.getExitCode() != 0) {
      GithubNotifications.showError(project, "Can't add remote", "Failed to add GitHub remote: '" + url + "'. " + handler.getStderr());
      return false;
    }
    // catch newly added remote
    repository.update();
    return true;
  }
  catch (VcsException e) {
    GithubNotifications.showError(project, "Can't add remote", e);
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GithubUtil.java

示例2: deployApplication

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private void deployApplication(CloudGitApplication application) throws ServerRuntimeException {
  boolean firstDeploy = findRepository() == null;

  GitRepository repository = findOrCreateRepository();
  addOrResetGitRemote(application, repository);

  final LocalChangeList activeChangeList = myChangeListManager.getDefaultChangeList();

  if (activeChangeList != null && !firstDeploy) {
    commitWithChangesDialog(activeChangeList);
  }
  else {
    add();
    commit();
  }
  repository.update();
  pushApplication(application);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CloudGitDeploymentRuntime.java

示例3: detectApplicationRoot

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private static void detectApplicationRoot(@NotNull File dir, @NotNull List<DetectedProjectRoot> result) {
  VirtualFile repositoryRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
  if (repositoryRoot == null) {
    return;
  }
  if (GitUtil.findGitDir(repositoryRoot) == null) {
    return;
  }

  Project project = ProjectManager.getInstance().getDefaultProject();
  GitRepository repository
    = GitRepositoryImpl.getLightInstance(repositoryRoot, project, ServiceManager.getService(project, GitPlatformFacade.class), project);
  repository.update();

  for (CloudGitDeploymentDetector deploymentDetector : CloudGitDeploymentDetector.EP_NAME.getExtensions()) {
    String applicationName = deploymentDetector.getFirstApplicationName(repository);
    if (applicationName != null) {
      result.add(new CloudGitProjectRoot(deploymentDetector, dir, repositoryRoot, applicationName));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CloudGitProjectStructureDetector.java

示例4: readBranches

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@NotNull
private Set<VcsRef> readBranches(@NotNull GitRepository repository) {
  StopWatch sw = StopWatch.start("readBranches in " + repository.getRoot().getName());
  VirtualFile root = repository.getRoot();
  repository.update();
  Collection<GitLocalBranch> localBranches = repository.getBranches().getLocalBranches();
  Collection<GitRemoteBranch> remoteBranches = repository.getBranches().getRemoteBranches();
  Set<VcsRef> refs = new THashSet<VcsRef>(localBranches.size() + remoteBranches.size());
  for (GitLocalBranch localBranch : localBranches) {
    refs.add(myVcsObjectsFactory.createRef(localBranch.getHash(), localBranch.getName(), GitRefManager.LOCAL_BRANCH, root));
  }
  for (GitRemoteBranch remoteBranch : remoteBranches) {
    refs.add(
      myVcsObjectsFactory.createRef(remoteBranch.getHash(), remoteBranch.getNameForLocalOperations(), GitRefManager.REMOTE_BRANCH, root));
  }
  String currentRevision = repository.getCurrentRevision();
  if (currentRevision != null) { // null => fresh repository
    refs.add(myVcsObjectsFactory.createRef(HashImpl.build(currentRevision), "HEAD", GitRefManager.HEAD, root));
  }
  sw.report();
  return refs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GitLogProvider.java

示例5: perform

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@Override
public boolean perform(@NotNull final Project project, GitVcs vcs, @NotNull final List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) {
  final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  if (changeListManager.isFreezedWithNotification("Can not revert now")) return true;
  final List<Change> changes = new ArrayList<Change>(affectedFiles.length);
  for (VirtualFile f : affectedFiles) {
    Change ch = changeListManager.getChange(f);
    if (ch != null) {
      changes.add(ch);
    }
  }
  RollbackChangesDialog.rollbackChanges(project, changes);
  for (GitRepository repository : GitUtil.getRepositoriesForFiles(project, Arrays.asList(affectedFiles))) {
    repository.update();
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GitRevert.java

示例6: cherryPick

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
public void cherryPick(@NotNull List<VcsFullCommitDetails> commits) {
  Map<GitRepository, List<VcsFullCommitDetails>> commitsInRoots =
    DvcsUtil.<GitRepository>groupCommitsByRoots(myPlatformFacade.getRepositoryManager(myProject), commits);
  List<GitCommitWrapper> successfulCommits = ContainerUtil.newArrayList();
  List<GitCommitWrapper> alreadyPicked = ContainerUtil.newArrayList();
  AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
  try {
    for (Map.Entry<GitRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) {
      GitRepository repository = entry.getKey();
      boolean result = cherryPick(repository, entry.getValue(), successfulCommits, alreadyPicked);
      repository.update();
      if (!result) {
        return;
      }
    }
    notifyResult(successfulCommits, alreadyPicked);
  }
  finally {
    DvcsUtil.workingTreeChangeFinished(myProject, token);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GitCherryPicker.java

示例7: fetch

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
protected void fetch() throws ServerRuntimeException {
  final VirtualFile contentRoot = getRepositoryRoot();
  GitRepository repository = getRepository();
  final GitLineHandler fetchHandler = new GitLineHandler(getProject(), contentRoot, GitCommand.FETCH);
  fetchHandler.setUrl(getApplication().getGitUrl());
  fetchHandler.setSilent(false);
  fetchHandler.addParameters(getRemoteName());
  fetchHandler.addLineListener(createGitLineHandlerListener());
  performRemoteGitTask(fetchHandler, CloudBundle.getText("fetching.application", getCloudName()));

  repository.update();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CloudGitDeploymentRuntime.java

示例8: execute

import git4idea.repo.GitRepository; //导入方法依赖的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

示例9: GitPushOperation

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
public GitPushOperation(@NotNull Project project,
                        @NotNull GitPushSupport pushSupport,
                        @NotNull Map<GitRepository, PushSpec<GitPushSource, GitPushTarget>> pushSpecs,
                        @Nullable GitPushTagMode tagMode,
                        boolean force) {
  myProject = project;
  myPushSupport = pushSupport;
  myPushSpecs = pushSpecs;
  myTagMode = tagMode;
  myForce = force;
  myGit = ServiceManager.getService(Git.class);
  myProgressIndicator = ObjectUtils.notNull(ProgressManager.getInstance().getProgressIndicator(), new EmptyProgressIndicator());
  mySettings = GitVcsSettings.getInstance(myProject);
  myPlatformFacade = ServiceManager.getService(project, GitPlatformFacade.class);
  myRepositoryManager = ServiceManager.getService(myProject, GitRepositoryManager.class);

  Map<GitRepository, GitRevisionNumber> currentHeads = ContainerUtil.newHashMap();
  for (GitRepository repository : pushSpecs.keySet()) {
    repository.update();
    String head = repository.getCurrentRevision();
    if (head == null) {
      LOG.error("This repository has no commits");
    }
    else {
      currentHeads.put(repository, new GitRevisionNumber(head));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GitPushOperation.java

示例10: update

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@NotNull
protected GitUpdateResult update(@NotNull Collection<GitRepository> rootsToUpdate,
                                 @NotNull UpdateMethod updateMethod,
                                 boolean checkForRebaseOverMergeProblem) {
  GitUpdateResult updateResult = new GitUpdateProcess(myProject, myPlatformFacade, myProgressIndicator,
                                                      new HashSet<GitRepository>(rootsToUpdate), UpdatedFiles.create(),
                                                      checkForRebaseOverMergeProblem).update(updateMethod);
  for (GitRepository repository : rootsToUpdate) {
    repository.getRoot().refresh(true, true);
    repository.update();
  }
  return updateResult;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GitPushOperation.java

示例11: update

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
/**
 * Checks if update is possible, saves local changes and updates all roots.
 * In case of error shows notification and returns false. If update completes without errors, returns true.
 *
 * Perform update on all roots.
 * 0. Blocks reloading project on external change, saving/syncing on frame deactivation.
 * 1. Checks if update is possible (rebase/merge in progress, no tracked branches...) and provides merge dialog to solve problems.
 * 2. Finds updaters to use (merge or rebase).
 * 3. Preserves local changes if needed (not needed for merge sometimes).
 * 4. Updates via 'git pull' or equivalent.
 * 5. Restores local changes if update completed or failed with error. If update is incomplete, i.e. some unmerged files remain,
 * local changes are not restored.
 *
 */
@NotNull
public GitUpdateResult update(final UpdateMethod updateMethod) {
  LOG.info("update started|" + updateMethod);
  String oldText = myProgressIndicator.getText();
  myProgressIndicator.setText("Updating...");

  for (GitRepository repository : myRepositories) {
    repository.update();
  }

  // check if update is possible
  if (checkRebaseInProgress() || isMergeInProgress() || areUnmergedFiles() || !checkTrackedBranchesConfigured()) {
    return GitUpdateResult.NOT_READY;
  }

  if (!fetchAndNotify()) {
    return GitUpdateResult.NOT_READY;
  }

  AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
  GitUpdateResult result;
  try {
    result = updateImpl(updateMethod);
  }
  finally {
    DvcsUtil.workingTreeChangeFinished(myProject, token);
  }
  myProgressIndicator.setText(oldText);
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:GitUpdateProcess.java

示例12: doDeleteRemote

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private boolean doDeleteRemote(@NotNull String branchName, @NotNull Collection<GitRepository> repositories) {
  Couple<String> pair = splitNameOfRemoteBranch(branchName);
  String remoteName = pair.getFirst();
  String branch = pair.getSecond();

  GitCompoundResult result = new GitCompoundResult(myProject);
  for (GitRepository repository : repositories) {
    GitCommandResult res;
    GitRemote remote = getRemoteByName(repository, remoteName);
    if (remote == null) {
      String error = "Couldn't find remote by name: " + remoteName;
      LOG.error(error);
      res = GitCommandResult.error(error);
    }
    else {
      res = pushDeletion(repository, remote, branch);
      if (!res.success() && isAlreadyDeletedError(res.getErrorOutputAsJoinedString())) {
        res = myGit.remotePrune(repository, remote);
      }
    }
    result.append(repository, res);
    repository.update();
  }
  if (!result.totalSuccess()) {
    VcsNotifier.getInstance(myProject).notifyError("Failed to delete remote branch " + branchName,
                                                     result.getErrorOutputWithReposIndication());
  }
  return result.totalSuccess();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitDeleteRemoteBranchOperation.java

示例13: refresh

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private void refresh(GitRepository... repositories) {
  for (GitRepository repository : repositories) {
    refreshRoot(repository);
    // repository state will be auto-updated with this VFS refresh => in general there is no need to call GitRepository#update()
    // but to avoid problems of the asynchronous refresh, let's force update the repository info.
    repository.update();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GitCheckoutOperation.java

示例14: updateRepositoriesInfo

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private static void updateRepositoriesInfo(@NotNull Collection<GitRepository> repositories) {
  for (GitRepository repository : repositories) {
    repository.update();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:GitRebaseProcess.java

示例15: refresh

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private static void refresh(@NotNull List<GitRepository> toRefresh) {
  for (GitRepository repository : toRefresh) {
    repository.update();
  }
  markDirtyAndRefresh(false, true, false, toVirtualFileArray(getRootsFromRepositories(toRefresh)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:GitAbortRebaseProcess.java


注:本文中的git4idea.repo.GitRepository.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。