org.eclipse.jgit.lib.Repository.getConfig()方法的使用及代码示例

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

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

Repository.getConfig介绍

[英]Get the configuration of this repository.
[中]获取此存储库的配置。

代码示例

代码示例来源:origin: gocd/gocd

@Autowired
public ConfigRepository(SystemEnvironment systemEnvironment) throws IOException {
  this.systemEnvironment = systemEnvironment;
  workingDir = this.systemEnvironment.getConfigRepoDir();
  File configRepoDir = new File(workingDir, ".git");
  gitRepo = new FileRepositoryBuilder().setGitDir(configRepoDir).build();
  gitRepo.getConfig().setInt("gc", null, "auto", 0);
  git = new Git(gitRepo);
}

代码示例来源:origin: apache/usergrid

/**
 * @param gitConfigFolder e.g. /your/project/root/.git
 *
 * @return Returns git config remote.origin.url field of the repository located at gitConfigFolder
 */
public static String getGitRemoteUrl( String gitConfigFolder ) throws MojoExecutionException {
  try {
    Repository repo =
        new RepositoryBuilder().setGitDir( new File( gitConfigFolder ) ).readEnvironment().findGitDir()
                    .build();
    Config config = repo.getConfig();
    return config.getString( "remote", "origin", "url" );
  }
  catch ( Exception e ) {
    throw new MojoExecutionException( "Error trying to get remote origin url of git repository", e );
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-config

protected boolean shouldPull(Git git) throws GitAPIException {
  boolean shouldPull;
  if (this.refreshRate > 0 && System.currentTimeMillis() - this.lastRefresh < (this.refreshRate * 1000)) {
    return false;
  }
  Status gitStatus = git.status().call();
  boolean isWorkingTreeClean = gitStatus.isClean();
  String originUrl = git.getRepository().getConfig().getString("remote", "origin",
      "url");
  if (this.forcePull && !isWorkingTreeClean) {
    shouldPull = true;
    logDirty(gitStatus);
  }
  else {
    shouldPull = isWorkingTreeClean && originUrl != null;
  }
  if (!isWorkingTreeClean && !this.forcePull) {
    this.logger.info("Cannot pull from remote " + originUrl
        + ", the working tree is not clean.");
  }
  return shouldPull;
}

代码示例来源:origin: spring-cloud/spring-cloud-config

protected FetchResult fetch(Git git, String label) {
  FetchCommand fetch = git.fetch();
  fetch.setRemote("origin");
  fetch.setTagOpt(TagOpt.FETCH_TAGS);
  fetch.setRemoveDeletedRefs(deleteUntrackedBranches);
  if (this.refreshRate > 0) {
    this.setLastRefresh(System.currentTimeMillis());
  }
  configureCommand(fetch);
  try {
    FetchResult result = fetch.call();
    if (result.getTrackingRefUpdates() != null
        && result.getTrackingRefUpdates().size() > 0) {
      logger.info("Fetched for remote " + label + " and found "
          + result.getTrackingRefUpdates().size() + " updates");
    }
    return result;
  }
  catch (Exception ex) {
    String message = "Could not fetch remote for " + label + " remote: " + git
        .getRepository().getConfig().getString("remote", "origin", "url");
    warn(message, ex);
    return null;
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-config

private Ref resetHard(Git git, String label, String ref) {
  ResetCommand reset = git.reset();
  reset.setRef(ref);
  reset.setMode(ResetType.HARD);
  try {
    Ref resetRef = reset.call();
    if (resetRef != null) {
      this.logger.info(
          "Reset label " + label + " to version " + resetRef.getObjectId());
    }
    return resetRef;
  }
  catch (Exception ex) {
    String message = "Could not reset to remote for " + label + " (current ref="
        + ref + "), remote: " + git.getRepository().getConfig()
            .getString("remote", "origin", "url");
    warn(message, ex);
    return null;
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Create a configuration honoring the repository's settings.
 *
 * @param db
 *            the repository to read settings from. The repository is not
 *            retained by the new configuration, instead its settings are
 *            copied during the constructor.
 * @since 5.1.4
 */
public TransferConfig(Repository db) {
  this(db.getConfig());
}

代码示例来源:origin: spring-cloud/spring-cloud-config

private MergeResult merge(Git git, String label) {
  try {
    MergeCommand merge = git.merge();
    merge.include(git.getRepository().findRef("origin/" + label));
    MergeResult result = merge.call();
    if (!result.getMergeStatus().isSuccessful()) {
      this.logger.warn("Merged from remote " + label + " with result "
          + result.getMergeStatus());
    }
    return result;
  }
  catch (Exception ex) {
    String message = "Could not merge remote for " + label + " remote: " + git
        .getRepository().getConfig().getString("remote", "origin", "url");
    warn(message, ex);
    return null;
  }
}

代码示例来源:origin: apache/incubator-gobblin

this.git = Git.open(repoDirFile);
String uri = this.git.getRepository().getConfig().getString("remote", REMOTE_NAME, "url");

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public String getBuildAuthorName() throws GitCommitIdExecutionException {
 String userName = git.getConfig().getString("user", null, "name");
 return Optional.ofNullable(userName).orElse("");
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public String getBuildAuthorEmail() throws GitCommitIdExecutionException {
 String userEmail = git.getConfig().getString("user", null, "email");
 return Optional.ofNullable(userEmail).orElse("");
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Create a configuration honoring the repository's settings.
 *
 * @param db
 *            the repository to read settings from. The repository is not
 *            retained by the new configuration, instead its settings are
 *            copied during the constructor.
 */
public ReftableConfig(Repository db) {
  fromConfig(db.getConfig());
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Reset generator and start new submodule walk
 *
 * @return this generator
 */
public SubmoduleWalk reset() {
  repoConfig = repository.getConfig();
  modulesConfig = null;
  pathToName = null;
  walk.reset();
  return this;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Create a new rename detector for the given repository
 *
 * @param repo
 *            the repository to use for rename detection
 */
public RenameDetector(Repository repo) {
  this(repo.newObjectReader(), repo.getConfig().get(DiffConfig.KEY));
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Get the names of all known remotes
 *
 * @return the names of all known remotes
 * @since 3.4
 */
@NonNull
public Set<String> getRemoteNames() {
  return getConfig()
      .getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public String getRemoteOriginUrl() throws GitCommitIdExecutionException {
 String url = git.getConfig().getString("remote", "origin", "url");
 return stripCredentialsFromOriginUrl(url);
}

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      Config storedConfig = repository.getConfig();
      Set<String> remotes = storedConfig.getSubsections("remote");

      for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        System.out.println(remoteName + " " + url);
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      Config storedConfig = repository.getConfig();
      Set<String> remotes = storedConfig.getSubsections("remote");

      for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        System.out.println(remoteName + " " + url);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private boolean isEnabledFor(Repository db) {
  if (isOverridable())
    return db.getConfig().get(configKey).enabled;
  return isEnabled();
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private FastForwardMode getFastForwardMode() {
    if (fastForwardMode != null) {
      return fastForwardMode;
    }
    Config config = repo.getConfig();
    Merge ffMode = config.getEnum(Merge.values(),
        ConfigConstants.CONFIG_PULL_SECTION, null,
        ConfigConstants.CONFIG_KEY_FF, null);
    return ffMode != null ? FastForwardMode.valueOf(ffMode) : null;
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

TransportHttp(Repository local, URIish uri)
    throws NotSupportedException {
  super(local, uri);
  setURI(uri);
  http = new HttpConfig(local.getConfig(), uri);
  proxySelector = ProxySelector.getDefault();
  sslVerify = http.isSslVerify();
}

相关文章

Repository类方法