List of usage examples for org.eclipse.jgit.lib BlobBasedConfig BlobBasedConfig
public BlobBasedConfig(Config base, Repository db, AnyObjectId objectId) throws IOException, ConfigInvalidException
From source file:com.google.gerrit.server.project.DashboardsCollection.java
License:Apache License
private DashboardResource parse(ProjectControl ctl, String ref, String path, ProjectControl myCtl) throws ResourceNotFoundException, IOException, AmbiguousObjectException, IncorrectObjectTypeException, ConfigInvalidException {/*from ww w.j av a 2 s .co m*/ String id = ref + ":" + path; if (!ref.startsWith(REFS_DASHBOARDS)) { ref = REFS_DASHBOARDS + ref; } if (!Repository.isValidRefName(ref) || !ctl.controlForRef(ref).canRead()) { throw new ResourceNotFoundException(id); } try (Repository git = gitManager.openRepository(ctl.getProject().getNameKey())) { ObjectId objId = git.resolve(ref + ":" + path); if (objId == null) { throw new ResourceNotFoundException(id); } BlobBasedConfig cfg = new BlobBasedConfig(null, git, objId); return new DashboardResource(myCtl, ref, path, cfg, false); } catch (RepositoryNotFoundException e) { throw new ResourceNotFoundException(id); } }
From source file:com.google.gerrit.server.project.ListDashboards.java
License:Apache License
private List<DashboardInfo> scanDashboards(Project definingProject, Repository git, RevWalk rw, Ref ref, String project, boolean setDefault) throws IOException { List<DashboardInfo> list = Lists.newArrayList(); try (TreeWalk tw = new TreeWalk(rw.getObjectReader())) { tw.addTree(rw.parseTree(ref.getObjectId())); tw.setRecursive(true);// w w w. j a v a2 s . c o m while (tw.next()) { if (tw.getFileMode(0) == FileMode.REGULAR_FILE) { try { list.add(DashboardsCollection.parse(definingProject, ref.getName().substring(REFS_DASHBOARDS.length()), tw.getPathString(), new BlobBasedConfig(null, git, tw.getObjectId(0)), project, setDefault)); } catch (ConfigInvalidException e) { log.warn(String.format("Cannot parse dashboard %s:%s:%s: %s", definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage())); } } } } return list; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.commitInfo.DotGitModulesResolverImpl.java
License:Apache License
@Nullable public SubmodulesConfig forBlob(@NotNull final AnyObjectId blob) throws IOException { try {/*from ww w .j a va 2 s . c om*/ return new SubmodulesConfig(myDb.getConfig(), new BlobBasedConfig(null, myDb, blob)); } catch (ConfigInvalidException e) { LOG.info("Invalid submodule config: " + e.getMessage(), e); return null; } }