• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RefDatabase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jgit.lib.RefDatabase的典型用法代码示例。如果您正苦于以下问题:Java RefDatabase类的具体用法?Java RefDatabase怎么用?Java RefDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RefDatabase类属于org.eclipse.jgit.lib包,在下文中一共展示了RefDatabase类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateRefs

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
public void updateRefs() throws IOException, GitAPIException {
	List<Ref> allRefs = gitRepository.getRefs(Ref.class);
	List<String> refsToBePacked = new ArrayList<String>(allRefs.size());
	for (Ref ref : allRefs) {
		if (ref.isUpdateable()) {
			if (nullSafeCommitUpdate(ref)) {
				refsToBePacked.add(ref.getName());
			}
		}
	}

	if (!refsToBePacked.isEmpty()) {
		Repository repo = gitRepository.getRepository();
		RefDatabase refDatabase = repo.getRefDatabase();
		((RefDirectory) refDatabase).pack(refsToBePacked);
		refDatabase.refresh();
	}
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:19,代码来源:HistoryUpdate.java


示例2: createAllCommitsRevWalk

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private RevWalk createAllCommitsRevWalk(CommitSelection commitSelection)
		throws IOException, MissingObjectException,
		IncorrectObjectTypeException {
	RevWalk revWalk = new RevWalk(repository);
	RefDatabase refDatabase = repository.getRefDatabase();
	Map<String, org.eclipse.jgit.lib.Ref> refs = refDatabase.getRefs("");
	for (Entry<String, Ref> entryRef : refs.entrySet()) {
		ObjectId refObject = entryRef.getValue().getObjectId();
		RevObject revObject = revWalk.parseAny(refObject);
		if (revObject instanceof RevCommit) {
			revWalk.markStart((RevCommit) revObject);
		}
	}
	revWalk.setRevFilter(new CommitSelectionRevFilter(commitSelection));
	revWalk.sort(RevSort.REVERSE);
	revWalk.sort(RevSort.TOPO, true);
	return revWalk;
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:19,代码来源:RepoAssertion.java


示例3: isReachableFromHeadsOrTags

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
boolean isReachableFromHeadsOrTags(Repository repo, RevCommit commit) {
  try {
    RefDatabase refdb = repo.getRefDatabase();
    Collection<Ref> heads = refdb.getRefs(Constants.R_HEADS).values();
    Collection<Ref> tags = refdb.getRefs(Constants.R_TAGS).values();
    Map<String, Ref> refs = Maps.newHashMapWithExpectedSize(heads.size() + tags.size());
    for (Ref r : Iterables.concat(heads, tags)) {
      refs.put(r.getName(), r);
    }
    return commits.isReachableFrom(state, repo, commit, refs);
  } catch (IOException e) {
    log.error(
        String.format(
            "Cannot verify permissions to commit object %s in repository %s",
            commit.name(), getProject().getNameKey()),
        e);
    return false;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ProjectControl.java


示例4: resolve

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private Result resolve() throws IOException {
  RefDatabase refDb = repo.getRefDatabase();
  Collection<Ref> tags = refDb.getRefs(Constants.R_TAGS).values();
  Collection<Ref> branches = refDb.getRefs(Constants.R_HEADS).values();
  List<Ref> allTagsAndBranches = Lists.newArrayListWithCapacity(tags.size() + branches.size());
  allTagsAndBranches.addAll(tags);
  allTagsAndBranches.addAll(branches);
  parseCommits(allTagsAndBranches);
  Set<String> allMatchingTagsAndBranches = includedIn(tipsByCommitTime, 0);

  Result detail = new Result();
  detail.setBranches(getMatchingRefNames(allMatchingTagsAndBranches, branches));
  detail.setTags(getMatchingRefNames(allMatchingTagsAndBranches, tags));

  return detail;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:IncludedInResolver.java


示例5: setAdvertisedRefs

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
@Override
public void setAdvertisedRefs(final Map<String, Ref> allRefs,
                              final Set<ObjectId> additionalHaves) {
    super.setAdvertisedRefs(allRefs,
                            additionalHaves);
    final Map<String, Ref> refs = getAdvertisedRefs();
    if (getRepository().getRefDatabase() instanceof RefTreeDatabase) {
        final RefDatabase bootstrap = ((RefTreeDatabase) getRepository().getRefDatabase()).getBootstrap();
        try {
            for (Map.Entry<String, Ref> entry : bootstrap.getRefs("").entrySet()) {
                refs.put(entry.getKey(),
                         entry.getValue());
            }
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:KetchCustomReceivePack.java


示例6: rebuild

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private RefTree rebuild(RefDatabase refdb) throws IOException {
    RefTree tree = RefTree.newEmptyTree();
    List<Command> cmds
            = new ArrayList<>();

    Ref head = refdb.exactRef(HEAD);
    if (head != null) {
        cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command(
                null,
                head));
    }

    for (Ref r : refdb.getRefs(RefDatabase.ALL).values()) {
        if (r.getName().equals(txnCommitted) || r.getName().equals(HEAD)
                || r.getName().startsWith(txnNamespace)) {
            continue;
        }
        cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command(
                null,
                git.getRepository().peel(r)));
    }
    tree.apply(cmds);
    return tree;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:ConvertRefTree.java


示例7: getRefsSoyData

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private static List<Map<String, Object>> getRefsSoyData(
    RefDatabase refdb,
    GitilesView view,
    String prefix,
    Ordering<Ref> ordering,
    @Nullable Ref headLeaf,
    int limit) throws IOException {
  Collection<Ref> refs = refdb.getRefs(prefix).values();
  refs = ordering.leastOf(refs, limit > 0 ? limit + 1 : refs.size());
  List<Map<String, Object>> result = Lists.newArrayListWithCapacity(refs.size());

  for (Ref ref : refs) {
    String name = ref.getName().substring(prefix.length());
    boolean needPrefix = !ref.getName().equals(refdb.getRef(name).getName());
    Map<String, Object> value = Maps.newHashMapWithExpectedSize(3);
    value.put("url", GitilesView.revision().copyFrom(view).setRevision(
      Revision.unpeeled(needPrefix ? ref.getName() : name, ref.getObjectId())).toUrl());
    value.put("name", name);
    if (headLeaf != null) {
      value.put("isHead", headLeaf.equals(ref));
    }
    result.add(value);
  }
  return result;
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:26,代码来源:RefServlet.java


示例8: getRefNames

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
/** {@inheritDoc} */
   public Set<String> getRefNames(String refPrefix) throws GitException, InterruptedException {
if (refPrefix.isEmpty()) {
    refPrefix = RefDatabase.ALL;
} else {
    refPrefix = refPrefix.replace(' ', '_');
}
try (Repository repo = getRepository()) {
    Map<String, Ref> refList = repo.getRefDatabase().getRefs(refPrefix);
    // The key set for refList will have refPrefix removed, so to recover it we just grab the full name.
    Set<String> refs = new HashSet<>(refList.size());
    for (Ref ref : refList.values()) {
	refs.add(ref.getName());
    }
    return refs;
} catch (IOException e) {
    throw new GitException("Error retrieving refs with prefix " + refPrefix, e);
}
   }
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:20,代码来源:JGitAPIImpl.java


示例9: getRefPrefixes

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
public List<String> getRefPrefixes(Class<? extends Ref> refType) {
	List<String> refPrefixes = new ArrayList<String>();
	if (Ref.class.equals(refType)) {
		refPrefixes.add(RefDatabase.ALL);
	} else if (Branch.class.equals(refType)) {
		refPrefixes.addAll(getLocalBranchRefs());
		refPrefixes.addAll(getRemoteBranchRefs());
	} else if (LocalBranch.class.equals(refType)) {
		refPrefixes.addAll(getLocalBranchRefs());
	} else if (RemoteBranch.class.equals(refType)) {
		refPrefixes.addAll(getRemoteBranchRefs());
	}
	return refPrefixes;
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:15,代码来源:RefFactory.java


示例10: getRefs

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends Ref> List<T> getRefs(Class<T> refType) {
	Repository repository = getRepository();
	RefDatabase refDatabase = repository.getRefDatabase();
	refDatabase.refresh();
	List<String> prefixes = refFactory.getRefPrefixes(refType);

	List<T> refList = new ArrayList<T>();
	for (String prefix : prefixes) {
		try {
			Map<String, org.eclipse.jgit.lib.Ref> refs = refDatabase
					.getRefs(prefix);
			for (Entry<String, org.eclipse.jgit.lib.Ref> refEntry : refs
					.entrySet()) {
				org.eclipse.jgit.lib.Ref jgitRef = refEntry.getValue();
				Ref ref = refFactory.create(jgitRef);
				if (ref != null) {
					refList.add((T) ref);
				}

			}
		} catch (IOException e) {
			throw new GitRepositoryException(e);
		}

	}

	Collections.sort(refList, DefaultRefSorter.INSTANCE);

	return refList;
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:32,代码来源:GitRepository.java


示例11: build

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
void build(Repository git, TagSet old, TagMatcher m) {
  if (old != null && m != null && refresh(old, m)) {
    return;
  }

  try (TagWalk rw = new TagWalk(git)) {
    rw.setRetainBody(false);
    for (Ref ref : git.getRefDatabase().getRefs(RefDatabase.ALL).values()) {
      if (skip(ref)) {
        continue;

      } else if (isTag(ref)) {
        // For a tag, remember where it points to.
        addTag(rw, git.peel(ref));

      } else {
        // New reference to include in the set.
        addRef(rw, ref);
      }
    }

    // Traverse the complete history. Copy any flags from a commit to
    // all of its ancestors. This automatically updates any Tag object
    // as the TagCommit and the stored Tag object share the same
    // underlying bit set.
    TagCommit c;
    while ((c = (TagCommit) rw.next()) != null) {
      BitSet mine = c.refFlags;
      int pCnt = c.getParentCount();
      for (int pIdx = 0; pIdx < pCnt; pIdx++) {
        ((TagCommit) c.getParent(pIdx)).refFlags.or(mine);
      }
    }
  } catch (IOException e) {
    log.warn("Error building tags for repository " + projectName, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:38,代码来源:TagSet.java


示例12: getAll

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
public List<BranchSummary> getAll() {
    RefDatabase refDatabase = repository.getRefDatabase();
    try {
        Map<String, Ref> branchRefs = localOrRemoteBranches(refDatabase);

        return summariesForRefs(branchRefs.values());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:11,代码来源:RDTBranch.java


示例13: localOrRemoteBranches

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private Map<String, Ref> localOrRemoteBranches(RefDatabase refDatabase) throws IOException {
    Map<String, Ref> branchRefs = refDatabase.getRefs(R_HEADS);
    if (branchRefs.isEmpty()) {
        branchRefs = refDatabase.getRefs(R_REMOTES);
    }
    return branchRefs;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:8,代码来源:RDTBranch.java


示例14: isVisible

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private boolean isVisible(Repository repo, RevWalk walk, ObjectId id,
    Collection<ObjectId> knownReachable) throws IOException {
  RevCommit commit;
  try {
    commit = walk.parseCommit(id);
  } catch (IncorrectObjectTypeException e) {
    return false;
  }

  // If any reference directly points at the requested object, permit display.
  // Common for displays of pending patch sets in Gerrit Code Review, or
  // bookmarks to the commit a tag points at.
  Collection<Ref> allRefs = repo.getRefDatabase().getRefs(RefDatabase.ALL).values();
  for (Ref ref : allRefs) {
    ref = repo.getRefDatabase().peel(ref);
    if (id.equals(ref.getObjectId()) || id.equals(ref.getPeeledObjectId())) {
      return true;
    }
  }

  // Check heads first under the assumption that most requests are for refs
  // close to a head. Tags tend to be much further back in history and just
  // clutter up the priority queue in the common case.
  return isReachableFrom(walk, commit, knownReachable)
      || isReachableFromRefs(walk, commit, filter(allRefs, refStartsWith(R_HEADS)))
      || isReachableFromRefs(walk, commit, filter(allRefs, refStartsWith(R_TAGS)))
      || isReachableFromRefs(walk, commit, filter(allRefs, otherRefs()));
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:29,代码来源:VisibilityCache.java


示例15: getBranchesSoyData

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
static List<Map<String, Object>> getBranchesSoyData(HttpServletRequest req, int limit)
    throws IOException {
  RefDatabase refdb = ServletUtils.getRepository(req).getRefDatabase();
  Ref head = refdb.getRef(Constants.HEAD);
  Ref headLeaf = head != null && head.isSymbolic() ? head.getLeaf() : null;
  return getRefsSoyData(
      refdb,
      ViewFilter.getView(req),
      Constants.R_HEADS,
      branchComparator(headLeaf),
      headLeaf,
      limit);
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:14,代码来源:RefServlet.java


示例16: getRefs

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private static Map<String, Ref> getRefs(RefDatabase refdb, String path) throws IOException {
  path = GitilesView.maybeTrimLeadingAndTrailingSlash(path);
  if (path.isEmpty()) {
    return refdb.getRefs(RefDatabase.ALL);
  }
  path = Constants.R_REFS + path;
  Ref singleRef = refdb.getRef(path);
  if (singleRef != null) {
    return ImmutableMap.of(singleRef.getName(), singleRef);
  }
  return refdb.getRefs(path + '/');
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:13,代码来源:RefServlet.java


示例17: deleteOriginalRefs

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private void deleteOriginalRefs() throws IOException {
	try (RevWalk revWalk = new RevWalk(repository)) {
		Collection<Ref> refs = new ArrayList<>();
		RefDatabase refDatabase = repository.getRefDatabase();
		Map<String, Ref> originalBranches = refDatabase.getRefs("refs/heads/original/");
		Map<String, Ref> originalTags = refDatabase.getRefs("refs/tags/original/");
		refs.addAll(originalBranches.values());
		refs.addAll(originalTags.values());
		for (Ref originalRef : refs) {
			RefUpdate refUpdate = repository.updateRef(originalRef.getName());
			refUpdate.setForceUpdate(true);
			refUpdate.delete(revWalk);
		}
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:16,代码来源:RepoMerger.java


示例18: getRefNames

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private static Set<String> getRefNames(Repository repo, String prefix) throws IOException {
  RefDatabase refDb = repo.getRefDatabase();
  return refDb.getRefs(prefix).keySet();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:StarredChangesUtil.java


示例19: commit

import org.eclipse.jgit.lib.RefDatabase; //导入依赖的package包/类
private void commit(final Repository repo,
                    final RevCommit original,
                    final BiFunction fun) throws IOException {
    try (final ObjectReader reader = repo.newObjectReader();
         final ObjectInserter inserter = repo.newObjectInserter();
         final RevWalk rw = new RevWalk(reader)) {

        final RefTreeDatabase refdb = (RefTreeDatabase) repo.getRefDatabase();
        final RefDatabase bootstrap = refdb.getBootstrap();
        final RefUpdate refUpdate = bootstrap.newUpdate(refdb.getTxnCommitted(),
                                                        false);

        final CommitBuilder cb = new CommitBuilder();
        final Ref ref = bootstrap.exactRef(refdb.getTxnCommitted());
        final RefTree tree;
        if (ref != null && ref.getObjectId() != null) {
            tree = RefTree.read(reader,
                                rw.parseTree(ref.getObjectId()));
            cb.setParentId(ref.getObjectId());
            refUpdate.setExpectedOldObjectId(ref.getObjectId());
        } else {
            tree = RefTree.newEmptyTree();
            refUpdate.setExpectedOldObjectId(ObjectId.zeroId());
        }

        if (fun.apply(reader,
                      tree)) {
            final Ref ref2 = bootstrap.exactRef(refdb.getTxnCommitted());
            if (ref2 == null || ref2.getObjectId().equals(ref != null ? ref.getObjectId() : null)) {
                cb.setTreeId(tree.writeTree(inserter));
                if (original != null) {
                    cb.setAuthor(original.getAuthorIdent());
                    cb.setCommitter(original.getAuthorIdent());
                } else {
                    final PersonIdent personIdent = new PersonIdent("user",
                                                                    "[email protected]");
                    cb.setAuthor(personIdent);
                    cb.setCommitter(personIdent);
                }
                refUpdate.setNewObjectId(inserter.insert(cb));
                inserter.flush();
                final RefUpdate.Result result = refUpdate.update(rw);
                switch (result) {
                    case NEW:
                    case FAST_FORWARD:
                        break;
                    default:
                        throw new RuntimeException(repo.getDirectory() + " -> " + result.toString() + " : " + refUpdate.getName());
                }
                final File commited = new File(repo.getDirectory(),
                                               refdb.getTxnCommitted());
                final File accepted = new File(repo.getDirectory(),
                                               refdb.getTxnNamespace() + "accepted");
                Files.copy(commited.toPath(),
                           accepted.toPath(),
                           StandardCopyOption.REPLACE_EXISTING);
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:61,代码来源:RefTreeUpdateCommand.java



注:本文中的org.eclipse.jgit.lib.RefDatabase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractTubeImpl类代码示例发布时间:2022-05-23
下一篇:
Java Button类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap