List of usage examples for org.eclipse.jgit.revwalk RevFlag UNINTERESTING
RevFlag UNINTERESTING
To view the source code for org.eclipse.jgit.revwalk RevFlag UNINTERESTING.
Click Source Link
From source file:com.github.koraktor.mavanagaiata.git.jgit.JGitRepositoryTest.java
License:Open Source License
@Test public void testDescribeExactTagged() throws Exception { RevCommit head = this.createCommit(); RevCommit head_1 = this.createCommit(); RevCommit head_2 = this.createCommit(); head.getParents()[0] = head_1;/*from w w w . j a va2 s . c o m*/ head_1.getParents()[0] = head_2; AbbreviatedObjectId abbrevId = head.abbreviate(7); this.repository.headObject = mock(ObjectId.class); this.repository.commitCache.put(this.repository.headObject, head); JGitRepository repo = spy(this.repository); Map<String, RevTag> rawTags = new HashMap<String, RevTag>(); RevTag rawTag = this.createTag("2.0.0", head.getName()); rawTags.put(head.getName(), rawTag); doReturn(rawTags).when(repo).getRawTags(); Map<String, GitTag> tags = new HashMap<String, GitTag>(); tags.put(head.getName(), new JGitTag(rawTag)); doReturn(tags).when(repo).getTags(); repo.revWalk = mock(RevWalk.class); RevFlag seenFlag = RevFlag.UNINTERESTING; when(repo.revWalk.newFlag("SEEN")).thenReturn(seenFlag); when(this.repo.getObjectDatabase().newReader().abbreviate(head)).thenReturn(abbrevId); GitTagDescription description = repo.describe(); assertThat(head.has(seenFlag), is(true)); assertThat(head_1.has(seenFlag), is(false)); assertThat(head_2.has(seenFlag), is(false)); assertThat(description.getNextTagName(), is(equalTo("2.0.0"))); assertThat(description.toString(), is(equalTo("2.0.0"))); }
From source file:com.github.koraktor.mavanagaiata.git.jgit.JGitRepositoryTest.java
License:Open Source License
@Test public void testDescribeTagged() throws Exception { RevCommit head = this.createCommit(); RevCommit head_1 = this.createCommit(); RevCommit head_2 = this.createCommit(); head.getParents()[0] = head_1;/*w ww . j a v a 2s. com*/ head_1.getParents()[0] = head_2; AbbreviatedObjectId abbrevId = head.abbreviate(7); this.repository.headObject = mock(ObjectId.class); this.repository.commitCache.put(this.repository.headObject, head); JGitRepository repo = spy(this.repository); Map<String, RevTag> rawTags = new HashMap<String, RevTag>(); RevTag rawTag = this.createTag("2.0.0", head_2.getName()); rawTags.put(head_2.getName(), rawTag); doReturn(rawTags).when(repo).getRawTags(); Map<String, GitTag> tags = new HashMap<String, GitTag>(); tags.put(head_2.getName(), new JGitTag(rawTag)); doReturn(tags).when(repo).getTags(); repo.revWalk = mock(RevWalk.class); RevFlag seenFlag = RevFlag.UNINTERESTING; when(repo.revWalk.newFlag("SEEN")).thenReturn(seenFlag); when(this.repo.getObjectDatabase().newReader().abbreviate(head)).thenReturn(abbrevId); GitTagDescription description = repo.describe(); assertThat(head.has(seenFlag), is(true)); assertThat(head_1.has(seenFlag), is(true)); assertThat(head_2.has(seenFlag), is(true)); assertThat(description.getNextTagName(), is(equalTo("2.0.0"))); assertThat(description.toString(), is(equalTo("2.0.0-2-g" + abbrevId.name()))); }
From source file:com.github.koraktor.mavanagaiata.git.jgit.JGitRepositoryTest.java
License:Open Source License
@Test public void testDescribeUntagged() throws Exception { RevCommit head = this.createCommit(); RevCommit head_1 = this.createCommit(); RevCommit head_2 = this.createCommit(); head.getParents()[0] = head_1;/* w ww. ja v a 2 s. c o m*/ head_1.getParents()[0] = head_2; AbbreviatedObjectId abbrevId = head.abbreviate(7); this.repository.headObject = mock(ObjectId.class); this.repository.commitCache.put(this.repository.headObject, head); this.repository.revWalk = mock(RevWalk.class); RevFlag seenFlag = RevFlag.UNINTERESTING; when(this.repository.revWalk.newFlag("SEEN")).thenReturn(seenFlag); when(this.repo.getObjectDatabase().newReader().abbreviate(head)).thenReturn(abbrevId); GitTagDescription description = this.repository.describe(); assertThat(head.has(seenFlag), is(true)); assertThat(head_1.has(seenFlag), is(true)); assertThat(head_2.has(seenFlag), is(true)); assertThat(description.getNextTagName(), is(equalTo(""))); assertThat(description.toString(), is(equalTo(abbrevId.name()))); }
From source file:com.google.gerrit.server.change.IncludedInResolver.java
License:Apache License
/** * Resolves which tip refs include the target commit. *///from w w w . ja va2s . c om private Set<String> includedIn(final Collection<RevCommit> tips, int limit) throws IOException, MissingObjectException, IncorrectObjectTypeException { Set<String> result = Sets.newHashSet(); for (RevCommit tip : tips) { boolean commitFound = false; rw.resetRetain(RevFlag.UNINTERESTING, containsTarget); rw.markStart(tip); for (RevCommit commit : rw) { if (commit.equals(target) || commit.has(containsTarget)) { commitFound = true; tip.add(containsTarget); result.addAll(commitToRef.get(tip)); break; } } if (!commitFound) { rw.markUninteresting(tip); } else if (0 < limit && limit < result.size()) { break; } } return result; }
From source file:kr.re.ec.grigit.graph.ui.RevWalker.java
License:Eclipse Distribution License
public void init() throws Exception { logger = LoggerFactory.getLogger(RevWalker.class); db = CurrentRepository.getInstance().getRepository(); walk = createWalk();//from w w w.j a v a 2 s. c o m for (final RevSort s : sorting) walk.sort(s, true); /* if (pathFilter == TreeFilter.ALL) { if (followPath != null) walk.setTreeFilter(FollowFilter.create(followPath, db .getConfig().get(DiffConfig.KEY))); } else if (pathFilter != TreeFilter.ALL) { walk.setTreeFilter(AndTreeFilter.create(pathFilter, TreeFilter.ANY_DIFF)); }*/ if (revLimiter.size() == 1) walk.setRevFilter(revLimiter.get(0)); else if (revLimiter.size() > 1) walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) { Map<String, Ref> refs = db.getRefDatabase().getRefs(RefDatabase.ALL); for (Ref a : refs.values()) { ObjectId oid = a.getPeeledObjectId(); if (oid == null) oid = a.getObjectId(); try { commits.add(walk.parseCommit(oid)); } catch (IncorrectObjectTypeException e) { // Ignore all refs which are not commits } } } if (commits.isEmpty()) { final ObjectId head = db.resolve(Constants.HEAD); if (head == null) //logger.info(MessageFormat.format(CLIText.get().cannotResolve, // Constants.HEAD)); commits.add(walk.parseCommit(head)); } for (final RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); else walk.markStart(real); } //final long start = System.currentTimeMillis(); //logger.info("i'm here1"); final int n = walkLoop(); //logger.info("i'm here2"); if (count) { //final long end = System.currentTimeMillis(); logger.info("" + n); logger.info(" "); // logger.info(MessageFormat.format(CLIText.get().timeInMilliSeconds, // Long.valueOf(end - start))); } }
From source file:org.apache.maven.scm.provider.git.jgit.command.JGitUtils.java
License:Apache License
/** * Get a list of commits between two revisions. * * @param repo the repository to work on * @param sortings sorting/* ww w . java 2 s . com*/ * @param fromRev start revision * @param toRev if null, falls back to head * @param fromDate from which date on * @param toDate until which date * @param maxLines max number of lines * @return a list of commits, might be empty, but never <code>null</code> * @throws IOException * @throws MissingObjectException * @throws IncorrectObjectTypeException */ public static List<RevCommit> getRevCommits(Repository repo, RevSort[] sortings, String fromRev, String toRev, final Date fromDate, final Date toDate, int maxLines) throws IOException, MissingObjectException, IncorrectObjectTypeException { List<RevCommit> revs = new ArrayList<RevCommit>(); RevWalk walk = new RevWalk(repo); ObjectId fromRevId = fromRev != null ? repo.resolve(fromRev) : null; ObjectId toRevId = toRev != null ? repo.resolve(toRev) : null; if (sortings == null || sortings.length == 0) { sortings = new RevSort[] { RevSort.TOPO, RevSort.COMMIT_TIME_DESC }; } for (final RevSort s : sortings) { walk.sort(s, true); } if (fromDate != null && toDate != null) { //walk.setRevFilter( CommitTimeRevFilter.between( fromDate, toDate ) ); walk.setRevFilter(new RevFilter() { @Override public boolean include(RevWalk walker, RevCommit cmit) throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException { int cmtTime = cmit.getCommitTime(); return (cmtTime >= (fromDate.getTime() / 1000)) && (cmtTime <= (toDate.getTime() / 1000)); } @Override public RevFilter clone() { return this; } }); } else { if (fromDate != null) { walk.setRevFilter(CommitTimeRevFilter.after(fromDate)); } if (toDate != null) { walk.setRevFilter(CommitTimeRevFilter.before(toDate)); } } if (fromRevId != null) { RevCommit c = walk.parseCommit(fromRevId); c.add(RevFlag.UNINTERESTING); RevCommit real = walk.parseCommit(c); walk.markUninteresting(real); } if (toRevId != null) { RevCommit c = walk.parseCommit(toRevId); c.remove(RevFlag.UNINTERESTING); RevCommit real = walk.parseCommit(c); walk.markStart(real); } else { final ObjectId head = repo.resolve(Constants.HEAD); if (head == null) { throw new RuntimeException("Cannot resolve " + Constants.HEAD); } RevCommit real = walk.parseCommit(head); walk.markStart(real); } int n = 0; for (final RevCommit c : walk) { n++; if (maxLines != -1 && n > maxLines) { break; } revs.add(c); } return revs; }