Java Code Examples for org.eclipse.jgit.revwalk.RevCommit#getFullMessage()
The following examples show how to use
org.eclipse.jgit.revwalk.RevCommit#getFullMessage() .
These examples are extracted from open source projects.
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 Project: onedev File: GitUtils.java License: MIT License | 6 votes |
@Nullable public static String getDetailMessage(RevCommit commit) { int start = 0; String fullMessage = commit.getFullMessage(); while (true) { int index = fullMessage.indexOf('\n', start); if (index == -1) return null; start = index+1; int nextIndex = fullMessage.indexOf('\n', start); if (nextIndex == -1) return null; start = nextIndex+1; if (fullMessage.substring(index, nextIndex).trim().length() == 0) { String detailMessage = fullMessage.substring(start).trim(); return detailMessage.length()!=0?detailMessage:null; } } }
Example 2
Source Project: yacy_grid_mcp File: GitTool.java License: GNU Lesser General Public License v2.1 | 6 votes |
public GitTool() { File gitWorkDir = new File("."); try { Git git = Git.open(gitWorkDir); Iterable<RevCommit> commits = git.log().all().call(); Repository repo = git.getRepository(); branch = repo.getBranch(); RevCommit latestCommit = commits.iterator().next(); name = latestCommit.getName(); message = latestCommit.getFullMessage(); } catch (Throwable e) { name = ""; message = ""; branch = ""; } }
Example 3
Source Project: WebIDE-Backend File: RewordActionHandler.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public RebaseResponse extractMessage(Repository repository) throws IOException { List<RebaseTodoLine> rebaseTodoLines = repository.readRebaseTodo(getRebasePath(repository, DONE), false); // the last rebase_todo_line RebaseTodoLine line = rebaseTodoLines.get(rebaseTodoLines.size() - 1); try (RevWalk walk = new RevWalk(repository)) { ObjectReader or = repository.newObjectReader(); RevCommit commitToPick = walk.parseCommit(or.resolve(line.getCommit()).iterator().next()); String oldMessage = commitToPick.getFullMessage(); RebaseResponse response = new RebaseResponse(false, RebaseResponse.Status.INTERACTIVE_EDIT); response.setMessage(oldMessage); return response; } }
Example 4
Source Project: verigreen File: EmailSender.java License: Apache License 2.0 | 6 votes |
public String getCommitMessage(String commitId){ String commitMessage = null; try { FileRepositoryBuilder builder = new FileRepositoryBuilder(); String repoPath = VerigreenNeededLogic.properties.getProperty("git.repositoryLocation"); Repository repo = builder.setGitDir(new File(repoPath)).setMustExist(true).build(); Git git = new Git(repo); Iterable<RevCommit> log = git.log().call(); Iterator<RevCommit> iterator = log.iterator(); while(commitMessage == null && iterator.hasNext()){ RevCommit rev = iterator.next(); String commit = rev.getName().substring(0,7); if(commit.equals(commitId)){ commitMessage = rev.getFullMessage(); } } } catch(Exception e){ e.printStackTrace(); } return commitMessage; }
Example 5
Source Project: naturalize File: SvnToGitMapper.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public BiMap<Integer, String> mapSvnToGit() throws IOException, NoWorkTreeException, NoHeadException, GitAPIException { final BiMap<Integer, String> mappings = HashBiMap.create(); final Git repository = GitCommitUtils .getGitRepository(repositoryDirectory); for (final RevCommit commit : GitCommitUtils .getAllCommitsTopological(repository)) { final String message = commit.getFullMessage(); if (!message.contains("git-svn-id")) { continue; } final Matcher matcher = svnIdMatcher.matcher(message); matcher.find(); mappings.put(Integer.parseInt(matcher.group(1)), commit.name()); } return mappings; }
Example 6
Source Project: hop File: UIGit.java License: Apache License 2.0 | 5 votes |
@Override public String getCommitMessage( String commitId ) { if ( commitId.equals( IVCS.WORKINGTREE ) ) { try { String merge_msg = git.getRepository().readMergeCommitMsg(); return merge_msg == null ? "" : merge_msg; } catch ( Exception e ) { return e.getMessage(); } } else { RevCommit commit = resolve( commitId ); return commit.getFullMessage(); } }
Example 7
Source Project: SZZUnleashed File: SimpleBugIntroducerFinder.java License: MIT License | 5 votes |
/** Check if a commit is a partial fix. */ private boolean isPartialFix(String commit) throws IOException, GitAPIException { RevCommit rCommit = this.repo.parseCommit(this.repo.resolve(commit)); String message = rCommit.getFullMessage(); Matcher fixMatch = this.partialFixPattern.matcher(commit); return fixMatch.find(); }
Example 8
Source Project: data7 File: Utils.java License: Apache License 2.0 | 5 votes |
/** * Function to generate a commit Object from a revcommit object * @param git git repository * @param commit to generate the commit object from * @param filter whether of not files should be filtered * @return a commit object * @see Commit */ public static Commit generateCommitOfInterest(GitActions git, RevCommit commit,boolean filter) { try { String hash = commit.getName(); String commitMessage = commit.getFullMessage(); int timestamp = commit.getCommitTime(); List<String> modifiedFiles = git.getListOfModifiedFile(commit.getName(), FILE_EXTENSION); List<FileFix> fixes = new ArrayList<>(); for (String modifiedFile : modifiedFiles) { if (!filter || !modifiedFile.toLowerCase().contains("test")) { String newName = modifiedFile; GitActions.NamedCommit previousCommit = git.previousCommitImpactingAFile(modifiedFile, hash); String oldname = previousCommit.getFilePath(); String oldHash = previousCommit.getRevCommit().getName(); String oldContent = git.retrievingFileFromSpecificCommit(oldHash, oldname); String newContent = git.retrievingFileFromSpecificCommit(hash, newName); FileInterest old = new FileInterest(oldContent, oldname); FileInterest newer = new FileInterest(newContent, newName); fixes.add(new FileFix(old, newer, oldHash, git.getTimeCommit(oldHash))); } } return new Commit(hash, commitMessage, timestamp, fixes); } catch (IOException e) { System.err.println(e.getMessage()); return null; } }
Example 9
Source Project: spring-cloud-release-tools File: SimpleCommit.java License: Apache License 2.0 | 5 votes |
SimpleCommit(RevCommit revCommit) { this(revCommit.abbreviate(8).name(), revCommit.name(), revCommit.getShortMessage(), revCommit.getFullMessage(), revCommit.getAuthorIdent().getName(), revCommit.getAuthorIdent().getEmailAddress(), revCommit.getCommitterIdent().getName(), revCommit.getCommitterIdent().getEmailAddress(), revCommit.getParentCount() > 1); }
Example 10
Source Project: APDE File: GitRepository.java License: GNU General Public License v2.0 | 5 votes |
public static String ellipsizeCommitMessage(RevCommit commit, int truncateAt) { String shortMessage = commit.getShortMessage(); return truncateAt > 0 ? (shortMessage.length() > truncateAt ? shortMessage.substring(0, Math.min(truncateAt, shortMessage.length())) + "…" : shortMessage) : commit.getFullMessage(); }
Example 11
Source Project: app-runner File: GitCommit.java License: MIT License | 5 votes |
public static GitCommit fromHEAD(Git git) throws Exception { ObjectId head = git.getRepository().resolve("HEAD"); if (head != null) { RevCommit mostRecentCommit; try (RevWalk walk = new RevWalk(git.getRepository())) { mostRecentCommit = walk.parseCommit(head); } Date commitDate = new Date(1000L * mostRecentCommit.getCommitTime()); String id = mostRecentCommit.getId().name(); PersonIdent author = mostRecentCommit.getAuthorIdent(); return new GitCommit(id, commitDate, author.getName(), mostRecentCommit.getFullMessage()); } else { return null; } }
Example 12
Source Project: contribution File: NotesBuilder.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns a set of ignored commits. * Ignored commits are 'revert' commits and commits which were reverted by the 'revert' commits * in current release. * * @param commitsForRelease commits for release. * @return a set of ignored commits. */ private static Set<RevCommit> getIgnoredCommits(Set<RevCommit> commitsForRelease) { final Set<RevCommit> ignoredCommits = new HashSet<>(); for (RevCommit commit : commitsForRelease) { final String commitMessage = commit.getFullMessage(); if (isRevertCommit(commitMessage)) { final int lastSpaceIndex = commitMessage.lastIndexOf(' '); final int lastPeriodIndex = commitMessage.lastIndexOf('.'); final String revertedCommitReference; if (lastSpaceIndex > lastPeriodIndex) { // smth is wrong with commit message, revert commit was changed manually revertedCommitReference = "nonexistingsha"; } else { revertedCommitReference = commitMessage.substring(lastSpaceIndex + 1, lastPeriodIndex); } final Optional<RevCommit> revertedCommit = commitsForRelease.stream() .filter(revCommit -> revertedCommitReference.equals(revCommit.getName())) .findFirst(); if (revertedCommit.isPresent()) { ignoredCommits.add(commit); ignoredCommits.add(revertedCommit.get()); } } else if (isIgnoredCommit(commitMessage)) { ignoredCommits.add(commit); } } return ignoredCommits; }
Example 13
Source Project: contribution File: NotesBuilder.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns a list of commits which are associated with the current issue. * * @param commits commits. * @param issueNo issue number. * @return a list of commits which are associated with the current issue. */ private static Set<RevCommit> getCommitsForIssue(Set<RevCommit> commits, int issueNo) { final Set<RevCommit> currentIssueCommits = new HashSet<>(); for (RevCommit commit : commits) { final String commitMessage = commit.getFullMessage(); if (isIssueOrPull(commitMessage)) { final int currentIssueNo = getIssueNumberFrom(commitMessage); if (issueNo == currentIssueNo) { currentIssueCommits.add(commit); } } } return currentIssueCommits; }
Example 14
Source Project: git-changelog-lib File: GitRepo.java License: Apache License 2.0 | 5 votes |
private GitCommit toGitCommit(final RevCommit revCommit) { final Boolean merge = revCommit.getParentCount() > 1; return new GitCommit( // revCommit.getAuthorIdent().getName(), // revCommit.getAuthorIdent().getEmailAddress(), // new Date(revCommit.getCommitTime() * 1000L), // revCommit.getFullMessage(), // revCommit.getId().getName(), // merge); }
Example 15
Source Project: gocd File: ConfigRepository.java License: Apache License 2.0 | 5 votes |
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)); }
Example 16
Source Project: proctor File: GitHistoryParser.java License: Apache License 2.0 | 5 votes |
static Revision createRevisionFromCommit(final RevCommit commit) { return new Revision( commit.getName(), determineAuthorId(commit), new Date((long) commit.getCommitTime() * 1000 /* convert seconds to milliseconds */), commit.getFullMessage() ); }
Example 17
Source Project: steady File: GitClient.java License: Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public Map<String, String> getCommitLogEntries( Set<String> _revs ) { final Map<String, String> hits = new HashMap<String, String>(); if (!_revs.isEmpty() ) { try { Repository repository = this.getRepositoryFromPath( null ); RevWalk walk = new RevWalk( repository ); //walk.setRevFilter(RevFilter); RevCommit commit = null; Git git = new Git( repository ); Iterable<RevCommit> logs = git.log().call(); Iterator<RevCommit> i = logs.iterator(); String commitId = null; String commitMsg = null; // iterate over all commits while ( i.hasNext() ) { commit = walk.parseCommit( i.next() ); commitId = commit.getName(); commitMsg = commit.getFullMessage(); // iterate over all revisions to search for for ( String sid : _revs ) { if(sid.contains(":")){ sid= sid.substring(0,sid.indexOf(":")-1); } if ( !sid.equals( "" ) && sid.equals( commitId ) ) { hits.put( commitId , commitMsg ); continue; } } } } catch ( UnknownHostException e ) { GitClient.log.error( "Proxy issues?" ); e.printStackTrace(); } catch ( IOException ioe ) { GitClient.log.error( "Something went wrong with the I/O" ); ioe.printStackTrace(); } catch ( GitAPIException ge ) { GitClient.log.error( "Something went wrong with the GIT API" ); ge.printStackTrace(); } } return hits; }
Example 18
Source Project: git-client-plugin File: JGitAPIImpl.java License: MIT License | 4 votes |
/** * Formats a commit into the raw format. * * @param commit * Commit to format. * @param parent * Optional parent commit to produce the diff against. This only matters * for merge commits, and git-log/git-whatchanged/etc behaves differently with respect to this. */ @SuppressFBWarnings(value = "VA_FORMAT_STRING_USES_NEWLINE", justification = "Windows git implementation requires specific line termination") void format(RevCommit commit, RevCommit parent, PrintWriter pw, Boolean useRawOutput) throws IOException { if (parent!=null) pw.printf("commit %s (from %s)\n", commit.name(), parent.name()); else pw.printf("commit %s\n", commit.name()); pw.printf("tree %s\n", commit.getTree().name()); for (RevCommit p : commit.getParents()) pw.printf("parent %s\n",p.name()); FastDateFormat iso = FastDateFormat.getInstance(ISO_8601); PersonIdent a = commit.getAuthorIdent(); pw.printf("author %s <%s> %s\n", a.getName(), a.getEmailAddress(), iso.format(a.getWhen())); PersonIdent c = commit.getCommitterIdent(); pw.printf("committer %s <%s> %s\n", c.getName(), c.getEmailAddress(), iso.format(c.getWhen())); // indent commit messages by 4 chars String msg = commit.getFullMessage(); if (msg.endsWith("\n")) msg=msg.substring(0,msg.length()-1); msg = msg.replace("\n","\n "); msg="\n "+msg+"\n"; pw.println(msg); // see man git-diff-tree for the format try (Repository repo = getRepository(); ObjectReader or = repo.newObjectReader(); TreeWalk tw = new TreeWalk(or)) { if (parent != null) { /* Caller provided a parent commit, use it */ tw.reset(parent.getTree(), commit.getTree()); } else { if (commit.getParentCount() > 0) { /* Caller failed to provide parent, but a parent * is available, so use the parent in the walk */ tw.reset(commit.getParent(0).getTree(), commit.getTree()); } else { /* First commit in repo has 0 parent count, but * the TreeWalk requires exactly two nodes for its * walk. Use the same node twice to satisfy * TreeWalk. See JENKINS-22343 for details. */ tw.reset(commit.getTree(), commit.getTree()); } } tw.setRecursive(true); tw.setFilter(TreeFilter.ANY_DIFF); final RenameDetector rd = new RenameDetector(repo); rd.reset(); rd.addAll(DiffEntry.scan(tw)); List<DiffEntry> diffs = rd.compute(or, null); if (useRawOutput) { for (DiffEntry diff : diffs) { pw.printf(":%06o %06o %s %s %s\t%s", diff.getOldMode().getBits(), diff.getNewMode().getBits(), diff.getOldId().name(), diff.getNewId().name(), statusOf(diff), diff.getChangeType()==ChangeType.ADD ? diff.getNewPath() : diff.getOldPath()); if (hasNewPath(diff)) { pw.printf(" %s",diff.getNewPath()); // copied to } pw.println(); pw.println(); } } } }
Example 19
Source Project: gocd File: ConfigRepository.java License: Apache License 2.0 | 4 votes |
private GoConfigRevision getGoConfigRevision(final RevCommit revision) { return new GoConfigRevision(contentFromTree(revision.getTree()), revision.getFullMessage()); }
Example 20
Source Project: proctor File: GitProctorCore.java License: Apache License 2.0 | 4 votes |
@Override public TestVersionResult determineVersions(final String fetchRevision) throws StoreException.ReadException { try { final RevWalk walk = new RevWalk(git.getRepository()); final ObjectId commitId = ObjectId.fromString(fetchRevision); final RevCommit headTree = walk.parseCommit(commitId); final RevTree tree = headTree.getTree(); // now use a TreeWalk to iterate over all files in the Tree recursively // you can set Filters to narrow down the results if needed final TreeWalk treeWalk = new TreeWalk(git.getRepository()); treeWalk.addTree(tree); treeWalk.setFilter(AndTreeFilter .create(PathFilter.create(testDefinitionsDirectory), PathSuffixFilter.create("definition.json"))); treeWalk.setRecursive(true); final List<TestVersionResult.Test> tests = Lists.newArrayList(); while (treeWalk.next()) { final ObjectId id = treeWalk.getObjectId(0); // final RevTree revTree = walk.lookupTree(id); final String path = treeWalk.getPathString(); final String[] pieces = path.split("/"); final String testname = pieces[pieces.length - 2]; // tree / parent directory name // testname, blobid pair // note this is the blobid hash - not a commit hash // RevTree.id and RevBlob.id tests.add(new TestVersionResult.Test(testname, id.name())); } walk.dispose(); return new TestVersionResult( tests, new Date(Long.valueOf(headTree.getCommitTime()) * 1000 /* convert seconds to milliseconds */), determineAuthorId(headTree), headTree.toObjectId().getName(), headTree.getFullMessage() ); } catch (final IOException e) { throw new StoreException.ReadException(e); } }