List of usage examples for org.eclipse.jgit.lib ObjectReader has
public boolean has(AnyObjectId objectId) throws IOException
From source file:com.microsoft.gittf.core.config.ChangesetCommitMap.java
License:Open Source License
/** * Gets the commit id that this changeset id refers to. If the caller * specified the validate flag as true, the method also ensures that the * commit id refers to a valid commit. If not NULL is returned. * /*www .ja v a2 s . c om*/ * @param changesetID * the changeset id * @param validate * whether or not to validate the object id found * @return */ public ObjectId getCommitID(int changesetID, boolean validate) { Check.isTrue(changesetID >= 0, "changesetID >= 0"); //$NON-NLS-1$ ensureConfigUptoDate(); String commitHash = configFile.getString(ConfigurationConstants.CONFIGURATION_SECTION, ConfigurationConstants.COMMIT_SUBSECTION, MessageFormat .format(ConfigurationConstants.COMMIT_CHANGESET_FORMAT, Integer.toString(changesetID))); if (commitHash == null) { return null; } ObjectId changesetCommitId = ObjectId.fromString(commitHash); if (!validate) { return changesetCommitId; } ObjectReader objectReader = null; try { objectReader = repository.newObjectReader(); if (changesetCommitId != null && !ObjectId.zeroId().equals(changesetCommitId)) { try { if (objectReader.has(changesetCommitId)) { return changesetCommitId; } } catch (IOException exception) { return null; } } return null; } finally { if (objectReader != null) { objectReader.release(); } } }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.GitServerUtil.java
License:Apache License
public static boolean isCloned(@NotNull Repository db) throws VcsException, IOException { if (!db.getObjectDatabase().exists()) return false; ObjectReader reader = db.getObjectDatabase().newReader(); try {//from www . j a v a 2 s. c o m for (Ref ref : db.getRefDatabase().getRefs(RefDatabase.ALL).values()) { if (reader.has(ref.getObjectId())) return true; } } finally { reader.release(); } return false; }