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

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

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

Repository.hasObject介绍

[英]Whether the specified object is stored in this repo or any of the known shared repositories.
[中]指定的对象是否存储在此repo或任何已知的共享存储库中。

代码示例

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

private Collection<Ref> expandAutoFollowTags() throws TransportException {
  final Collection<Ref> additionalTags = new ArrayList<>();
  final Map<String, Ref> haveRefs = localRefs();
  for (Ref r : conn.getRefs()) {
    if (!isTag(r))
      continue;
    Ref local = haveRefs.get(r.getName());
    if (local != null)
      // We already have a tag with this name, don't fetch it (even if
      // the local is different).
      continue;
    ObjectId obj = r.getPeeledObjectId();
    if (obj == null)
      obj = r.getObjectId();
    if (askFor.containsKey(obj) || transport.local.hasObject(obj))
      wantTag(r);
    else
      additionalTags.add(r);
  }
  return additionalTags;
}

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

if (local.hasObject(oid))
  remoteObjects.add(oid);

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

if (id == null)
  id = r.getObjectId();
if (transport.local.hasObject(id))
  wantTag(r);

代码示例来源:origin: bozaro/git-lfs-migrate

@NotNull
 @Override
 public ObjectId convert(@NotNull Repository dstRepo, @NotNull ObjectInserter inserter, @NotNull ConvertResolver resolver, @Nullable Uploader uploader) throws IOException {
  if (dstRepo.hasObject(id)) return id;
  return copy(inserter, reader.open(id));
 }
};

代码示例来源:origin: jenkinsci/git-client-plugin

/** {@inheritDoc} */
@Override
public boolean isCommitInRepo(ObjectId commit) throws GitException {
  if (commit == null) {
    return false;
  }
  final boolean found;
  try (Repository repo = getRepository()) {
    found = repo.hasObject(commit);
  }
  return found;
}

代码示例来源:origin: airlift/airship

public static ByteSource getBlob(final Repository repository, final ObjectId objectId)
{
  Preconditions.checkArgument(repository.hasObject(objectId), "object id '%s' not found in git repository", objectId.getName());
  return new ByteSource()
  {
    @Override
    public InputStream openStream()
        throws IOException
    {
      return repository.open(objectId).openStream();
    }
  };
}

代码示例来源:origin: bozaro/git-lfs-migrate

@NotNull
 @Override
 public ObjectId convert(@NotNull Repository dstRepo, @NotNull ObjectInserter inserter, @NotNull ConvertResolver resolver, @Nullable Uploader uploader) throws IOException {
  final ObjectLoader loader = reader.open(id, Constants.OBJ_BLOB);
  // Is empty blob (see #21)?
  if (loader.getSize() == 0) {
   if (dstRepo.hasObject(id)) return id;
   return copy(inserter, loader);
  }
  // Is object already converted?
  if (isLfsPointer(loader)) {
   if (dstRepo.hasObject(id)) return id;
   return copy(inserter, loader);
  }
  final String hash = (uploader == null) ? createLocalFile(id, loader) : createRemoteFile(id, loader, uploader);
  // Create pointer.
  StringWriter pointer = new StringWriter();
  pointer.write("version https://git-lfs.github.com/spec/v1\n");
  pointer.write("oid sha256:" + hash + "\n");
  pointer.write("size " + loader.getSize() + "\n");
  return inserter.insert(Constants.OBJ_BLOB, pointer.toString().getBytes(StandardCharsets.UTF_8));
 }
};

代码示例来源:origin: bozaro/git-as-svn

@Nullable GitObject<RevCommit> findCommit(@NotNull ObjectId objectId) throws IOException {
 for (Repository repo : repositories) {
  if (repo.hasObject(objectId)) {
   return new GitObject<>(repo, new RevWalk(repo).parseCommit(objectId));
  }
 }
 return null;
}

代码示例来源:origin: theonedev/onedev

public boolean isValid() {
  if (valid == null) {
    Repository repository = targetProject.getRepository();
    if (!repository.hasObject(ObjectId.fromString(baseCommitHash))
        || !repository.hasObject(ObjectId.fromString(headCommitHash))) {
      valid = false;
    } else {
      for (PullRequestUpdate update: updates) {
        if (!repository.hasObject(ObjectId.fromString(update.getMergeBaseCommitHash()))
            || !repository.hasObject(ObjectId.fromString(update.getHeadCommitHash()))) {
          valid = false;
          break;
        }
      }
      if (valid == null)
        valid = true;
    }
  } 
  return valid;
}

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

&& !submoduleRepo.hasObject(walk.getObjectId()))
  || recurseMode == FetchRecurseSubmodulesMode.YES) {
FetchCommand f = new FetchCommand(submoduleRepo)

代码示例来源:origin: theonedev/onedev

public boolean isValid() {
  return project.getRepository().hasObject(ObjectId.fromString(markPos.getCommit()));
}

代码示例来源:origin: berlam/github-bucket

private Collection<Ref> expandAutoFollowTags() throws TransportException {
  final Collection<Ref> additionalTags = new ArrayList<>();
  final Map<String, Ref> haveRefs = localRefs();
  for (Ref r : conn.getRefs()) {
    if (!isTag(r))
      continue;
    Ref local = haveRefs.get(r.getName());
    if (local != null)
      // We already have a tag with this name, don't fetch it (even if
      // the local is different).
      continue;
    ObjectId obj = r.getPeeledObjectId();
    if (obj == null)
      obj = r.getObjectId();
    if (askFor.containsKey(obj) || transport.local.hasObject(obj))
      wantTag(r);
    else
      additionalTags.add(r);
  }
  return additionalTags;
}

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

private Collection<Ref> expandAutoFollowTags() throws TransportException {
  final Collection<Ref> additionalTags = new ArrayList<Ref>();
  final Map<String, Ref> haveRefs = localRefs();
  for (final Ref r : conn.getRefs()) {
    if (!isTag(r))
      continue;
    Ref local = haveRefs.get(r.getName());
    if (local != null)
      // We already have a tag with this name, don't fetch it (even if
      // the local is different).
      continue;
    ObjectId obj = r.getPeeledObjectId();
    if (obj == null)
      obj = r.getObjectId();
    if (askFor.containsKey(obj) || transport.local.hasObject(obj))
      wantTag(r);
    else
      additionalTags.add(r);
  }
  return additionalTags;
}

代码示例来源:origin: winstonli/writelatex-git-bridge

private Map<String, RawFile> walkGitObjectTree(Optional<Long> maxFileSize)
    throws IOException,
        SizeLimitExceededException,
        InvalidGitRepository {
  Map<String, RawFile> fileContentsTable = new HashMap<>();
  if (treeWalk == null) {
    return fileContentsTable;
  }
  while (treeWalk.next()) {
    String path = treeWalk.getPathString();
    ObjectId objectId = treeWalk.getObjectId(0);
    if (!repository.hasObject(objectId)) {
      throw new InvalidGitRepository();
    }
    ObjectLoader obj = repository.open(objectId);
    long size = obj.getSize();
    if (maxFileSize.isPresent() && size > maxFileSize.get()) {
      throw new SizeLimitExceededException(
          Optional.ofNullable(path), size, maxFileSize.get());
    }
    try (ByteArrayOutputStream o = new ByteArrayOutputStream(
        CastUtil.assumeInt(size))) {
      obj.copyTo(o);
      fileContentsTable.put(
          path, new RepositoryFile(path, o.toByteArray()));
    };
  }
  return fileContentsTable;
}

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

if (o instanceof RevBlob && !db.hasObject(o))
  throw new MissingObjectException(o, Constants.TYPE_BLOB);

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

if (local.hasObject(oid))
  remoteObjects.add(oid);

代码示例来源:origin: berlam/github-bucket

if (local.hasObject(oid))
  remoteObjects.add(oid);

代码示例来源:origin: theonedev/onedev

@Override
public void execute(Transaction txn) {
  associateCommentWithCommit(txn, comment.getMarkPos().getCommit());
  String compareCommit = comment.getCompareContext().getCompareCommit();
  if (!comment.getMarkPos().getCommit().equals(compareCommit)
      && project.getRepository().hasObject(ObjectId.fromString(compareCommit)))
    associateCommentWithCommit(txn, comment.getCompareContext().getCompareCommit());
  defaultStore.put(txn, LAST_CODE_COMMENT_KEY, new LongByteIterable(comment.getId()));
}

代码示例来源:origin: theonedev/onedev

private void openComment(CodeComment comment) {
  if (!comment.isValid()) {
    CodeCommentListPanel.this.replaceWith(new InvalidCodeCommentPanel(CodeCommentListPanel.this, 
        comment.getId()));
  } else {
    PullRequest request = getPullRequest();
    if (request != null) {
      PullRequestDetailPage page = (PullRequestDetailPage) getPage();
      setResponsePage(PullRequestChangesPage.class, PullRequestChangesPage.paramsOf(request, page.getPosition(), comment));
    } else {
      String compareCommit = comment.getCompareContext().getCompareCommit();
      if (!compareCommit.equals(comment.getMarkPos().getCommit())
          && getProject().getRepository().hasObject(ObjectId.fromString(compareCommit))) {
        setResponsePage(RevisionComparePage.class, RevisionComparePage.paramsOf(comment));
      } else {
        setResponsePage(ProjectBlobPage.class, ProjectBlobPage.paramsOf(comment));
      }
    }                
  }
}

代码示例来源:origin: berlam/github-bucket

&& !submoduleRepo.hasObject(walk.getObjectId()))
  || recurseMode == FetchRecurseSubmodulesMode.YES) {
FetchCommand f = new FetchCommand(submoduleRepo)

相关文章

Repository类方法