BlameResult(BlameGenerator bg, String path, RawText text) { generator = bg; resultPath = path; resultContents = text; int cnt = text.size(); sourceCommits = new RevCommit[cnt]; sourceAuthors = new PersonIdent[cnt]; sourceCommitters = new PersonIdent[cnt]; sourceLines = new int[cnt]; sourcePaths = new String[cnt]; }
private static boolean isEndOfLineMissing(RawText text, int line) { return line + 1 == text.size() && text.isMissingNewlineAtEnd(); }
/** * Get the line delimiter for the first line. * * @since 2.0 * @return the line delimiter or <code>null</code> */ public String getLineDelimiter() { if (size() == 0) return null; int e = getEnd(0); if (content[e - 1] != '\n') return null; if (content.length > 1 && e > 1 && content[e - 2] == '\r') return "\r\n"; //$NON-NLS-1$ else return "\n"; //$NON-NLS-1$ }
private boolean isNoNewlineAtEndOfFile(FileHeader fh) { HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1); RawText lhrt = new RawText(lastHunk.getBuffer()); return lhrt.getString(lhrt.size() - 1).equals( "\\ No newline at end of file"); //$NON-NLS-1$ } }
/** * Push a candidate blob onto the generator's traversal stack. * <p> * Candidates should be pushed in history order from oldest-to-newest. * Applications should push the starting commit first, then the index * revision (if the index is interesting), and finally the working tree copy * (if the working tree is interesting). * * @param description * description of the blob revision, such as "Working Tree". * @param contents * contents of the file. * @return {@code this} * @throws java.io.IOException * the repository cannot be read. */ public BlameGenerator push(String description, RawText contents) throws IOException { if (description == null) description = JGitText.get().blameNotCommittedYet; BlobCandidate c = new BlobCandidate(getRepository(), description, resultPath); c.sourceText = contents; c.regionList = new Region(0, 0, contents.size()); remaining = contents.size(); push(c); return this; }
public static void main(String args[]) throws IOException, GitAPIException { try (Repository repo = CookbookHelper.openJGitCookbookRepository()) { final String[] list = new File(".").list(); if(list == null) { throw new IllegalStateException("Did not find any files at " + new File(".").getAbsolutePath()); } for(String file : list) { if(new File(file).isDirectory()) { continue; } System.out.println("Blaming " + file); final BlameResult result = new Git(repo).blame().setFilePath(file) .setTextComparator(RawTextComparator.WS_IGNORE_ALL).call(); final RawText rawText = result.getResultContents(); for (int i = 0; i < rawText.size(); i++) { final PersonIdent sourceAuthor = result.getSourceAuthor(i); final RevCommit sourceCommit = result.getSourceCommit(i); System.out.println(sourceAuthor.getName() + (sourceCommit != null ? "/" + sourceCommit.getCommitTime() + "/" + sourceCommit.getName() : "") + ": " + rawText.getString(i)); } } } } }
public static void main(String args[]) throws IOException, GitAPIException { try (Repository repo = CookbookHelper.openJGitCookbookRepository()) { final String[] list = new File(".").list(); if(list == null) { throw new IllegalStateException("Did not find any files at " + new File(".").getAbsolutePath()); } for(String file : list) { if(new File(file).isDirectory()) { continue; } System.out.println("Blaming " + file); final BlameResult result = new Git(repo).blame().setFilePath(file) .setTextComparator(RawTextComparator.WS_IGNORE_ALL).call(); final RawText rawText = result.getResultContents(); for (int i = 0; i < rawText.size(); i++) { final PersonIdent sourceAuthor = result.getSourceAuthor(i); final RevCommit sourceCommit = result.getSourceCommit(i); System.out.println(sourceAuthor.getName() + (sourceCommit != null ? "/" + sourceCommit.getCommitTime() + "/" + sourceCommit.getName() : "") + ": " + rawText.getString(i)); } } } } }
throws IOException, PatchApplyException { RawText rt = new RawText(f); List<String> oldLines = new ArrayList<>(rt.size()); for (int i = 0; i < rt.size(); i++) oldLines.add(rt.getString(i)); List<String> newLines = new ArrayList<>(oldLines); RawText hrt = new RawText(b); List<String> hunkLines = new ArrayList<>(hrt.size()); for (int i = 0; i < hrt.size(); i++) hunkLines.add(hrt.getString(i)); int pos = 0;
c.sourceBlob = id.toObjectId(); c.sourceText = new RawText(ldr.getCachedBytes(Integer.MAX_VALUE)); c.regionList = new Region(0, 0, c.sourceText.size()); remaining = c.sourceText.size(); push(c); return this; c.sourceBlob = idBuf.toObjectId(); c.loadText(reader); c.regionList = new Region(0, 0, c.sourceText.size()); remaining = c.sourceText.size(); push(c); return this;
BlameResult(BlameGenerator bg, String path, RawText text) { generator = bg; resultPath = path; resultContents = text; int cnt = text.size(); sourceCommits = new RevCommit[cnt]; sourceAuthors = new PersonIdent[cnt]; sourceCommitters = new PersonIdent[cnt]; sourceLines = new int[cnt]; sourcePaths = new String[cnt]; }
BlameResult(BlameGenerator bg, String path, RawText text) { generator = bg; resultPath = path; resultContents = text; int cnt = text.size(); sourceCommits = new RevCommit[cnt]; sourceAuthors = new PersonIdent[cnt]; sourceCommitters = new PersonIdent[cnt]; sourceLines = new int[cnt]; sourcePaths = new String[cnt]; }
if (gen == null) return; if (start == 0 && end == resultContents.size()) { computeAll(); return;
private static boolean isEndOfLineMissing(final RawText text, final int line) { return line + 1 == text.size() && text.isMissingNewlineAtEnd(); }
private static boolean isEndOfLineMissing(RawText text, int line) { return line + 1 == text.size() && text.isMissingNewlineAtEnd(); }
private int findLine(int b, String regex) { String re = regex.substring(1, regex.length() - 1); if (!re.startsWith("^")) //$NON-NLS-1$ re = ".*" + re; //$NON-NLS-1$ if (!re.endsWith("$")) //$NON-NLS-1$ re = re + ".*"; //$NON-NLS-1$ Pattern p = Pattern.compile(re); RawText text = blame.getResultContents(); for (int line = b; line < text.size(); line++) { if (p.matcher(text.getString(line)).matches()) return line; } return b; }
private boolean isNoNewlineAtEndOfFile(FileHeader fh) { HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1); RawText lhrt = new RawText(lastHunk.getBuffer()); return lhrt.getString(lhrt.size() - 1).equals( "\\ No newline at end of file"); //$NON-NLS-1$ } }
private static boolean isNoNewlineAtEndOfFile(FileHeader fh) { HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1); RawText lhrt = new RawText(lastHunk.getBuffer()); return lhrt.getString(lhrt.size() - 1).equals( "\\ No newline at end of file"); //$NON-NLS-1$ } }
private boolean isNoNewlineAtEndOfFile(FileHeader fh) { HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1); RawText lhrt = new RawText(lastHunk.getBuffer()); return lhrt.getString(lhrt.size() - 1).equals( "\\ No newline at end of file"); //$NON-NLS-1$ } }