org.eclipse.jgit.api.ResetCommand.addPath()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.eclipse.jgit.api.ResetCommand.addPath方法的一些代码示例,展示了ResetCommand.addPath的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResetCommand.addPath方法的具体详情如下:
包路径:org.eclipse.jgit.api.ResetCommand
类名称:ResetCommand
方法名:addPath

ResetCommand.addPath介绍

[英]Repository relative path of file or directory to reset
[中]要重置的文件或目录的存储库相对路径

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory reset(Environment env, ArrayMemory settings) throws GitAPIException {
  ResetCommand reset = getWrappedObject().reset();
  Memory mode = settings.valueOfIndex("mode");
  if (mode.isNotNull()) {
    reset.setMode(ResetCommand.ResetType.valueOf(mode.toString()));
  }
  Memory ref = settings.valueOfIndex("ref");
  if (ref.isNotNull()) {
    reset.setRef(ref.toString());
  }
  reset.disableRefLog(settings.valueOfIndex("disableRefLog").toBoolean());
  Memory paths = settings.valueOfIndex("paths");
  if (paths.isNotNull()) {
    ForeachIterator iterator = paths.getNewIterator(env);
    if (iterator != null) {
      while (iterator.next()) {
        reset.addPath(iterator.getValue().toString());
      }
    } else {
      reset.addPath(paths.toString());
    }
  }
  Ref call = reset.call();
  return GitUtils.valueOf(call);
}

代码示例来源:origin: stackoverflow.com

ResetCommand reset = new Git(repository).reset();
reset.setRef(Constants.HEAD);
reset.addPath("foo.txt");
reset.call();

代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control

/**
 * Reset.
 *
 * @param path the path
 * @throws GitAPIException the exception
 */
public void reset(final String path) throws GitAPIException {
  if (!isUndefined()) {
    git.reset().addPath(path).call();
  }
}

代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control

private void resolveConflict(final String path) {
  try {
    git.reset().addPath(path).call();
    git.checkout().addPath(path).call();
  } catch (final Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: org.apache.stratos/org.apache.stratos.cartridge.agent

private void resetToRemoteHead(RepositoryContext gitRepoCtx, List<String> paths) {
  ResetCommand resetCmd = gitRepoCtx.getGit().reset();
  // reset type is HARD, to remote master branch
  resetCmd.setMode(ResetCommand.ResetType.HARD).
      setRef(GitDeploymentSynchronizerConstants.ORIGIN + "/" + GitDeploymentSynchronizerConstants.MASTER);
  // add paths
  for (String path : paths) {
    resetCmd.addPath(path);
    if (log.isDebugEnabled()) {
      log.debug("Added the file path " + path + " to reset");
    }
  }
  try {
    resetCmd.call();
    log.info("Reset the local branch to origin master successfully");
  } catch (GitAPIException e) {
    log.error("Reset to origin master failed", e);
  }
}

代码示例来源:origin: com.societegenerale.ci-droid.tasks-consumer/ci-droid-tasks-consumer-infrastructure

private void resetLocalRepoToProperState(Git git) throws GitAPIException {
  log.warn("conflicts in local repo - trying to fix them one by one...");
  Status status = git.status().call();
  log.info("cleaning up directory..");
  Set<String> removedFiles = gitWrapper.cleanDirectories(git);
  for (String removedFile : removedFiles) {
    log.info("\t removed {}", removedFile);
  }
  ResetCommand reset = gitWrapper.resetRepo(git);
  reset.setRef(Constants.HEAD);
  log.info("trying to remove conflicted files from workspace..");
  for (String conflictedFile : status.getConflicting()) {
    log.info("\t resetting {}", conflictedFile);
    reset.addPath(conflictedFile);
  }
  log.info("trying to remove uncommitted files from workspace..");
  for (String addedFile : status.getAdded()) {
    log.info("\t resetting {}", addedFile);
    reset.addPath(addedFile);
  }
  reset.call();
  log.info("reverting modified files to latest known state..");
  CheckoutCommand checkout = gitWrapper.checkOut(git);
  for (String modifiedFile : status.getModified()) {
    log.info("\t reverting {}", modifiedFile);
    checkout.addPath(modifiedFile);
  }
  checkout.call();
}

相关文章