org.eclipse.jgit.lib.RefDatabase Java Examples
The following examples show how to use
org.eclipse.jgit.lib.RefDatabase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JGitAPIImpl.java From git-client-plugin with MIT License | 6 votes |
/** {@inheritDoc} */ @Override public Set<String> getRefNames(String refPrefix) throws GitException, InterruptedException { if (refPrefix.isEmpty()) { refPrefix = RefDatabase.ALL; } else { refPrefix = refPrefix.replace(' ', '_'); } try (Repository repo = getRepository()) { List<Ref> refList = repo.getRefDatabase().getRefsByPrefix(refPrefix); Set<String> refs = new HashSet<>(refList.size()); for (Ref ref : refList) { refs.add(ref.getName()); } return refs; } catch (IOException e) { throw new GitException("Error retrieving refs with prefix " + refPrefix, e); } }
Example #2
Source File: RepoMerger.java From git-merge-repos with Apache License 2.0 | 5 votes |
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); } } }
Example #3
Source File: JGitEnvironmentRepositoryTests.java From spring-cloud-config with Apache License 2.0 | 4 votes |
private Repository stubbedRepo() { return spy(new Repository(new BaseRepositoryBuilder()) { @Override public void create(boolean bare) throws IOException { } @Override public ObjectDatabase getObjectDatabase() { return null; } @Override public RefDatabase getRefDatabase() { return JGitEnvironmentRepositoryTests.this.database; } @Override public StoredConfig getConfig() { return null; } @Override public AttributesNodeProvider createAttributesNodeProvider() { return null; } @Override public void scanForRepoChanges() throws IOException { } @Override public void notifyIndexChanged(boolean internal) { } @Override public ReflogReader getReflogReader(String refName) throws IOException { return null; } }); }