Codota Logo
org.eclipse.jgit.revwalk
Code IndexAdd Codota to your IDE (free)

How to use org.eclipse.jgit.revwalk

Best Java code snippets using org.eclipse.jgit.revwalk (Showing top 20 results out of 1,233)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: checkstyle/checkstyle

private static boolean isMergeCommit(RevCommit currentCommit) {
  return currentCommit.getParentCount() > 1;
}
origin: gocd/gocd

private GoConfigRevision getGoConfigRevision(final RevCommit revision) {
  return new GoConfigRevision(contentFromTree(revision.getTree()), revision.getFullMessage());
}
origin: gocd/gocd

RevCommit getRevCommitForCommitSHA(String commitSHA) throws GitAPIException {
  for (RevCommit revision : revisions()) {
    if (revision.getName().equals(commitSHA)) {
      return revision;
    }
  }
  throw new IllegalArgumentException(String.format("There is no commit corresponding to SHA: '%s'", commitSHA));
}
origin: jphp-group/jphp

public static ArrayMemory valueOf(RevCommit value) {
  ArrayMemory memory = valueOf((RevObject) value);
  memory.refOfIndex("commitTime").assign(value.getCommitTime());
  memory.refOfIndex("encoding").assign(value.getEncodingName());
  memory.refOfIndex("shortMessage").assign(value.getShortMessage());
  memory.refOfIndex("fullMessage").assign(value.getFullMessage());
  
  ArrayMemory parents = new ArrayMemory();
  for (RevCommit revCommit : value.getParents()) {
    parents.add(valueOf((RevObject)revCommit));
  }
  memory.refOfIndex("parents").assign(parents);
  PersonIdent authorIdent = value.getAuthorIdent();
  memory.refOfIndex("author").assign(authorIdent == null ? Memory.NULL : valueOf(authorIdent));
  PersonIdent committerIdent = value.getCommitterIdent();
  memory.refOfIndex("committer").assign(committerIdent == null ? Memory.NULL : valueOf(committerIdent));
  return memory;
}
origin: apache/usergrid

/**
 * @param gitConfigFolder e.g. /your/project/root/.git
 *
 * @return Returns last commit's UUID, "nocommit" if there are no commits and returns null if an exception occured
 */
public static String getLastCommitUuid( String gitConfigFolder ) throws MojoExecutionException {
  try {
    Repository repo =
        new RepositoryBuilder().setGitDir( new File( gitConfigFolder ) ).readEnvironment().findGitDir()
                    .build();
    RevWalk walk = new RevWalk( repo );
    ObjectId head = repo.resolve( "HEAD" );
    if ( head != null ) {
      RevCommit lastCommit = walk.parseCommit( head );
      return lastCommit.getId().getName();
    }
    else {
      return "nocommit";
    }
  }
  catch ( Exception e ) {
    throw new MojoExecutionException( "Error trying to get the last git commit uuid", e );
  }
}
origin: checkstyle/checkstyle

private static RevCommitsPair resolveRevCommitsPair(Repository repo) {
  RevCommitsPair revCommitIteratorPair;
  try (RevWalk revWalk = new RevWalk(repo); Git git = new Git(repo)) {
    final Iterator<RevCommit> first;
    final Iterator<RevCommit> second;
    final ObjectId headId = repo.resolve(Constants.HEAD);
    final RevCommit headCommit = revWalk.parseCommit(headId);
    if (isMergeCommit(headCommit)) {
      final RevCommit firstParent = headCommit.getParent(0);
      final RevCommit secondParent = headCommit.getParent(1);
      first = git.log().add(firstParent).call().iterator();
      second = git.log().add(secondParent).call().iterator();
    }
    else {
      first = git.log().call().iterator();
      second = Collections.emptyIterator();
    }
    revCommitIteratorPair =
        new RevCommitsPair(new OmitMergeCommitsIterator(first),
            new OmitMergeCommitsIterator(second));
  }
  catch (GitAPIException | IOException ignored) {
    revCommitIteratorPair = new RevCommitsPair();
  }
  return revCommitIteratorPair;
}
origin: checkstyle/checkstyle

@Test
public void testCommitMessageHasProperStructure() {
  for (RevCommit commit : filterValidCommits(lastCommits)) {
    final String commitMessage = commit.getFullMessage();
    final int error = validateCommitMessage(commitMessage);
    if (error != 0) {
      final String commitId = commit.getId().getName();
      fail(getInvalidCommitMessageFormattingError(commitId, commitMessage) + error);
    }
  }
}
origin: gocd/gocd

String getMergedConfig(String branchName, RevCommit newCommit) throws GitAPIException, IOException {
  MergeResult result = null;
  try {
    checkout(branchName);
    result = git.merge().include(newCommit).call();
  } catch (GitAPIException e) {
    LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName());
    throw e;
  }
  if (!result.getMergeStatus().isSuccessful()) {
    LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed as config file has changed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName,
        getCurrentRevCommit().getId().getName());
    throw new ConfigFileHasChangedException();
  }
  LOGGER.info("[CONFIG_MERGE] Successfully merged commit {} by user {} to branch {}. Merge commit revision is {}", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName());
  return FileUtils.readFileToString(new File(workingDir, CRUISE_CONFIG_XML), UTF_8);
}
origin: org.eclipse.jgit/org.eclipse.jgit

private void parseReachable(ObjectId id) {
  try {
    RevCommit o = walk.parseCommit(id);
    if (!o.has(REACHABLE)) {
      o.add(REACHABLE);
      reachableCommits.add(o);
    }
  } catch (IOException readError) {
    // If we cannot read the value of the ref skip it.
  }
}
origin: gocd/gocd

String findDiffBetweenTwoRevisions(RevCommit laterCommit, RevCommit earlierCommit) {
  if (laterCommit == null || earlierCommit == null) {
    return null;
  }
  String output = null;
  try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
    DiffFormatter diffFormatter = new DiffFormatter(out);
    diffFormatter.setRepository(gitRepo);
    diffFormatter.format(earlierCommit.getId(), laterCommit.getId());
    output = out.toString();
    output = StringUtil.stripTillLastOccurrenceOf(output, "+++ b/cruise-config.xml");
  } catch (IOException e) {
    throw new RuntimeException("Error occurred during diff computation. Message: " + e.getMessage());
  }
  return output;
}
origin: gocd/gocd

public GoConfigRevisions getCommits(final int pageSize, final int offset) {
  return doLocked(() -> {
    GoConfigRevisions goConfigRevisions = new GoConfigRevisions();
    try {
      LogCommand command = git.log().setMaxCount(pageSize).setSkip(offset);
      Iterable<RevCommit> revisions = command.call();
      for (RevCommit revision : revisions) {
        GoConfigRevision goConfigRevision = new GoConfigRevision((byte[]) null, revision.getFullMessage());
        goConfigRevision.setCommitSHA(revision.name());
        goConfigRevisions.add(goConfigRevision);
      }
    } catch (Exception e) {
      // ignore
    }
    return goConfigRevisions;
  });
}
origin: gocd/gocd

public RevCommit getRevCommitForMd5(String md5) throws GitAPIException {
  Assert.notNull(md5, "md5 is required");
  final String expectedPart = GoConfigRevision.Fragment.md5.represent(GoConfigRevision.esc(md5));
  for (RevCommit revision : revisions()) {
    String message = revision.getFullMessage();
    if (message.endsWith(expectedPart)) {
      return revision;
    }
  }
  throw new IllegalArgumentException(String.format("There is no config version corresponding to md5: '%s'", md5));
}
origin: checkstyle/checkstyle

private static List<RevCommit> filterValidCommits(List<RevCommit> revCommits) {
  final List<RevCommit> filteredCommits = new LinkedList<>();
  for (RevCommit commit : revCommits) {
    final String commitAuthor = commit.getAuthorIdent().getName();
    if (!USERS_EXCLUDED_FROM_VALIDATION.contains(commitAuthor)) {
      filteredCommits.add(commit);
    }
  }
  return filteredCommits;
}
origin: org.eclipse.jgit/org.eclipse.jgit

private void pushLocalCommit(RevCommit p)
    throws MissingObjectException, IOException {
  if (p.has(LOCALLY_SEEN))
    return;
  revWalk.parseHeaders(p);
  p.add(LOCALLY_SEEN);
  p.add(COMPLETE);
  p.carry(COMPLETE);
  localCommitQueue.add(p);
}
origin: jphp-group/jphp

public static ArrayMemory valueOf(RevObject value) {
  ArrayMemory memory = new ArrayMemory();
  memory.refOfIndex("id").assign(valueOf(value.getId()));
  memory.refOfIndex("type").assign(value.getType());
  return memory;
}
origin: org.eclipse.jgit/org.eclipse.jgit

BlockRevQueue(Generator s) throws MissingObjectException,
    IncorrectObjectTypeException, IOException {
  free = new BlockFreeList();
  outputType = s.outputType();
  s.shareFreeList(this);
  for (;;) {
    final RevCommit c = s.next();
    if (c == null)
      break;
    add(c);
  }
}
origin: gocd/gocd

void createBranch(String branchName, RevCommit revCommit) throws GitAPIException {
  try {
    git.branchCreate().setName(branchName).setStartPoint(revCommit).call();
  } catch (GitAPIException e) {
    LOGGER.error("[CONFIG_MERGE] Failed to create branch {} at revision {}", branchName, revCommit.getId(), e);
    throw e;
  }
}
origin: apache/incubator-gobblin

this.lastProcessedGitHash = lastLog.getName();
origin: checkstyle/checkstyle

private static List<RevCommit> getCommitsByLastCommitAuthor(
    Iterator<RevCommit> previousCommitsIterator) {
  final List<RevCommit> commits = new LinkedList<>();
  if (previousCommitsIterator.hasNext()) {
    final RevCommit lastCommit = previousCommitsIterator.next();
    final String lastCommitAuthor = lastCommit.getAuthorIdent().getName();
    commits.add(lastCommit);
    boolean wasLastCheckedCommitAuthorSameAsLastCommit = true;
    while (wasLastCheckedCommitAuthorSameAsLastCommit
        && previousCommitsIterator.hasNext()) {
      final RevCommit currentCommit = previousCommitsIterator.next();
      final String currentCommitAuthor = currentCommit.getAuthorIdent().getName();
      if (currentCommitAuthor.equals(lastCommitAuthor)) {
        commits.add(currentCommit);
      }
      else {
        wasLastCheckedCommitAuthorSameAsLastCommit = false;
      }
    }
  }
  return commits;
}
origin: gocd/gocd

@Test
public void shouldCreateBranchForARevCommit() throws Exception {
  configRepo.checkin(goConfigRevision("something", "md5-1"));
  RevCommit revCommit = configRepo.getCurrentRevCommit();
  configRepo.createBranch("branch1", revCommit);
  Ref branch = getBranch("branch1");
  assertThat(branch, is(notNullValue()));
  assertThat(branch.getObjectId(), is(revCommit.getId()));
}
org.eclipse.jgit.revwalk

Most used classes

  • RevCommit
  • RevWalk
  • RevTree
  • RevTag
  • RevObject
    Base object type accessed during revision walking.
  • FollowFilter,
  • ObjectWalk,
  • MaxCountRevFilter,
  • RevFlagSet,
  • AndRevFilter,
  • CommitTimeRevFilter,
  • DepthWalk$Commit,
  • DepthWalk$RevWalk,
  • TreeRevFilter,
  • AuthorRevFilter,
  • CommitterRevFilter,
  • MessageRevFilter,
  • RevFilter,
  • AbstractRevQueue$AlwaysEmptyQueue
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now