當前位置: 首頁>>代碼示例>>Java>>正文


Java DiffFormatter.setDiffComparator方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.diff.DiffFormatter.setDiffComparator方法的典型用法代碼示例。如果您正苦於以下問題:Java DiffFormatter.setDiffComparator方法的具體用法?Java DiffFormatter.setDiffComparator怎麽用?Java DiffFormatter.setDiffComparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.diff.DiffFormatter的用法示例。


在下文中一共展示了DiffFormatter.setDiffComparator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPaths

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private List<DiffEntry> getPaths(Repository repository, RevCommit rev)
		throws MissingObjectException, IncorrectObjectTypeException,
		IOException {
	RevCommit parent = null;
	List<DiffEntry> diffs = null;
	RevWalk rw = new RevWalk(repository);
	DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);

	df.setRepository(repository);
	df.setDiffComparator(RawTextComparator.DEFAULT);
	df.setDetectRenames(true);

	if (rev.getParentCount() > 0 && rev.getParent(0) != null) {
		parent = rw.parseCommit(rev.getParent(0).getId());
		diffs = df.scan(parent.getTree(), rev.getTree());
	} else {
		diffs = df.scan(new EmptyTreeIterator(), new CanonicalTreeParser(
				null, rw.getObjectReader(), rev.getTree()));
	}

	return diffs;
}
 
開發者ID:aserg-ufmg,項目名稱:ModularityCheck,代碼行數:23,代碼來源:GITLogHandler.java

示例2: listFilesChangedInCommit

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private HashSet<String> listFilesChangedInCommit(Repository repository, AnyObjectId beforeID, AnyObjectId afterID) throws MissingObjectException, IncorrectObjectTypeException, IOException
{
	log.info("calculating files changed in commit");
	HashSet<String> result = new HashSet<>();
	RevWalk rw = new RevWalk(repository);
	RevCommit commitBefore = rw.parseCommit(beforeID);
	RevCommit commitAfter = rw.parseCommit(afterID);
	DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
	df.setRepository(repository);
	df.setDiffComparator(RawTextComparator.DEFAULT);
	df.setDetectRenames(true);
	List<DiffEntry> diffs = df.scan(commitBefore.getTree(), commitAfter.getTree());
	for (DiffEntry diff : diffs)
	{
		result.add(diff.getNewPath());
	}
	log.debug("Files changed between commits commit: {} and {} - {}", beforeID.getName(), afterID, result);
	return result;
}
 
開發者ID:Apelon-VA,項目名稱:ISAAC,代碼行數:20,代碼來源:SyncServiceGIT.java

示例3: getAllHistories

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
@Override
public Map<String, List<Revision>> getAllHistories() throws StoreException {
    final TestMatrixDefinition testMatrixDefinition = getCurrentTestMatrix().getTestMatrixDefinition();
    if (testMatrixDefinition == null) {
        return Collections.emptyMap();
    }
    final Set<String> activeTests = testMatrixDefinition.getTests().keySet();

    final Repository repository = git.getRepository();
    try {
        final ObjectId head = repository.resolve(Constants.HEAD);
        final RevWalk revWalk = new RevWalk(repository);
        final DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
        df.setRepository(git.getRepository());
        df.setDiffComparator(RawTextComparator.DEFAULT);

        final HistoryParser historyParser = new HistoryParser(revWalk, df, getTestDefinitionsDirectory(), activeTests);
        return historyParser.parseFromHead(head);

    } catch (final IOException e) {
        throw new StoreException("Could not get history " + getGitCore().getRefName(), e);
    }
}
 
開發者ID:indeedeng,項目名稱:proctor,代碼行數:24,代碼來源:GitProctor.java

示例4: generatePatches

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
public void generatePatches() throws Exception {
    git.add().addFilepattern(".").call();
    git.commit().setMessage("generate patches").call();
    DiffFormatter formatter = new DiffFormatter(null);
    formatter.setRepository(git.getRepository());
    formatter.setDiffComparator(RawTextComparator.DEFAULT);
    formatter.setDetectRenames(true);
    List<DiffEntry> entries = formatter.scan(getSrcCommit().getTree(), getHead());
    getChangedFiles().forEach((path) -> {
        for (DiffEntry entry : entries) {
            Path diffPath = Paths.get(entry.getPath(DiffEntry.Side.NEW));
            if (diffPath.equals(path)) {
                File patchFile = new File(this.patchDirectory, diffPath.getFileName() + ".patch");
                try {
                    DiffFormatter diffFormatter = new DiffFormatter(new FileOutputStream
                            (patchFile));
                    diffFormatter.setRepository(git.getRepository());
                    diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
                    diffFormatter.setContext(3);
                    diffFormatter.format(entry);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
開發者ID:PizzaCrust,項目名稱:IodineToolkit,代碼行數:28,代碼來源:PatchService.java

示例5: getChangedFiles

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
public List<Path> getChangedFiles() throws IOException {
    List<Path> changedFiles = new ArrayList<>();
    RevWalk revWalk = new RevWalk(git.getRepository());
    AnyObjectId headId = git.getRepository().resolve(Constants.HEAD);
    RevCommit head = revWalk.parseCommit(headId);
    DiffFormatter formatter = new DiffFormatter(null);
    formatter.setRepository(git.getRepository());
    formatter.setDiffComparator(RawTextComparator.DEFAULT);
    formatter.setDetectRenames(true);
    List<DiffEntry> entries = formatter.scan(getSrcCommit().getTree(), head);
    entries.forEach((diffEntry -> changedFiles.add(Paths.get(diffEntry.getPath(DiffEntry.Side.NEW)))));
    return changedFiles;
}
 
開發者ID:PizzaCrust,項目名稱:IodineToolkit,代碼行數:14,代碼來源:PatchService.java

示例6: createDiffFormatter

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
protected static DiffFormatter createDiffFormatter(Repository r, OutputStream buffer) {
    DiffFormatter formatter = new DiffFormatter(buffer);
    formatter.setRepository(r);
    formatter.setDiffComparator(RawTextComparator.DEFAULT);
    formatter.setDetectRenames(true);
    return formatter;
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:8,代碼來源:RepositoryResource.java

示例7: getDiffFormatter

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
/**
 * Get diff formatter.
 *
 * @param filePath optional filter for diff
 * @return diff formater
 */
private DiffFormatter getDiffFormatter(String filePath) {
    final DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
    df.setRepository(repository);
    df.setDiffComparator(RawTextComparator.DEFAULT);
    df.setDetectRenames(true);
    if (filePath != null) {
        df.setPathFilter(PathFilter.create(filePath));
    }
    return df;
}
 
開發者ID:iazarny,項目名稱:gitember,代碼行數:17,代碼來源:GitRepositoryService.java

示例8: walkFilesInCommit

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private void walkFilesInCommit(
    Git gitClient,
    RevCommit commit,
    List<SourceCodeFileAnalyzerPlugin> analyzers,
    MetricsProcessor metricsProcessor)
    throws IOException {
  commit = CommitUtils.getCommit(gitClient.getRepository(), commit.getId());
  logger.info("starting analysis of commit {}", commit.getName());
  DiffFormatter diffFormatter = new DiffFormatter(DisabledOutputStream.INSTANCE);
  diffFormatter.setRepository(gitClient.getRepository());
  diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
  diffFormatter.setDetectRenames(true);

  ObjectId parentId = null;
  if (commit.getParentCount() > 0) {
    // TODO: support multiple parents
    parentId = commit.getParent(0).getId();
  }

  List<DiffEntry> diffs = diffFormatter.scan(parentId, commit);
  for (DiffEntry diff : diffs) {
    String filePath = diff.getPath(DiffEntry.Side.NEW);
    byte[] fileContent =
        BlobUtils.getRawContent(gitClient.getRepository(), commit.getId(), filePath);
    FileMetrics metrics = fileAnalyzer.analyzeFile(analyzers, filePath, fileContent);
    FileMetricsWithChangeType metricsWithChangeType =
        new FileMetricsWithChangeType(
            metrics, changeTypeMapper.jgitToCoderadar(diff.getChangeType()));
    metricsProcessor.processMetrics(metricsWithChangeType, gitClient, commit.getId(), filePath);
  }
  metricsProcessor.onCommitFinished(gitClient, commit.getId());
}
 
開發者ID:reflectoring,項目名稱:coderadar,代碼行數:33,代碼來源:AnalyzingCommitProcessor.java

示例9: getShortMessage

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
public ArrayList<String> getShortMessage() {
        for (RevCommit revision : walk) {
            shortMessage.add(revision.getShortMessage());
//[LOG]            logger.debug(revision.getShortMessage());
            DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
            df.setRepository(repository);
            df.setDiffComparator(RawTextComparator.DEFAULT);
            df.setDetectRenames(true);
            RevCommit parent = null;
            if(revision.getParentCount()!=0) {
                try {
                    parent = walk.parseCommit(revision.getParent(0).getId());
                    RevTree tree = revision.getTree();
                    List<DiffEntry> diffs = df.scan(parent.getTree(), revision.getTree());
                    for (DiffEntry diff : diffs) {
                        String changeType = diff.getChangeType().name();
                        if(changeType.equals(ADD)|| changeType.equals(MODIFY))
                        {
//[LOG]                            logger.debug(diff.getChangeType().name());
//[LOG]                            logger.debug(diff.getNewPath());
                            tempCommitHistory.add(diff.getNewPath());
                        }
                    }
                }catch (IOException ex) {
//[LOG]                    logger.debug("IOException", ex);
                }
            }
            commitSHA.add(commitCount,revision.name());
            commitHistory.add(commitCount++,new ArrayList<String>(tempCommitHistory));
            tempCommitHistory.clear();
        }
        walk.reset();
        return shortMessage;
    }
 
開發者ID:jughyd,項目名稱:GitFx,代碼行數:35,代碼來源:GitRepoMetaData.java

示例10: getChangesForCommitedFiles

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private List<Change> getChangesForCommitedFiles(String hash) throws IOException {
	RevWalk revWalk = new RevWalk(git.getRepository());
	RevCommit commit = revWalk.parseCommit(ObjectId.fromString(hash));

	if (commit.getParentCount() > 1) {
		revWalk.close();
		return new ArrayList<Change>();
	}

	RevCommit parentCommit = commit.getParentCount() > 0
			? revWalk.parseCommit(ObjectId.fromString(commit.getParent(0).getName()))
					: null;

			DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
			df.setBinaryFileThreshold(2048);
			df.setRepository(git.getRepository());
			df.setDiffComparator(RawTextComparator.DEFAULT);
			df.setDetectRenames(true);

			List<DiffEntry> diffEntries = df.scan(parentCommit, commit);
			df.close();
			revWalk.close();

			List<Change> changes = new ArrayList<Change>();
			for (DiffEntry entry : diffEntries) {
				Change change = new Change(entry.getNewPath(), entry.getOldPath(), 0, 0,
						ChangeType.valueOf(entry.getChangeType().name()));
				analyzeDiff(change, entry);
				changes.add(change);
			}

			return changes;
}
 
開發者ID:visminer,項目名稱:repositoryminer,代碼行數:34,代碼來源:GitSCM.java

示例11: getRevisionObj

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private Revision getRevisionObj(Repository repository, RevCommit commit) throws IOException {
    String commitSHA = commit.getName();
    Date commitTime = commit.getAuthorIdent().getWhen();
    String comment = commit.getFullMessage().trim();
    String user = commit.getAuthorIdent().getName();
    String emailId = commit.getAuthorIdent().getEmailAddress();
    List<ModifiedFile> modifiedFiles = new ArrayList<ModifiedFile>();
    if (commit.getParentCount() == 0) {
        TreeWalk treeWalk = new TreeWalk(repository);
        treeWalk.addTree(commit.getTree());
        treeWalk.setRecursive(false);
        while (treeWalk.next()) {
            modifiedFiles.add(new ModifiedFile(treeWalk.getPathString(), "added"));
        }
    } else {
        RevWalk rw = new RevWalk(repository);
        RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
        DiffFormatter diffFormatter = new DiffFormatter(DisabledOutputStream.INSTANCE);
        diffFormatter.setRepository(repository);
        diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
        diffFormatter.setDetectRenames(true);
        List<DiffEntry> diffEntries = diffFormatter.scan(parent.getTree(), commit.getTree());
        for (DiffEntry diffEntry : diffEntries) {
            modifiedFiles.add(new ModifiedFile(diffEntry.getNewPath(), getAction(diffEntry.getChangeType().name())));
        }
    }

    return new Revision(commitSHA, commitTime, comment, user, emailId, modifiedFiles);
}
 
開發者ID:gocd,項目名稱:go-plugins,代碼行數:30,代碼來源:JGitHelper.java

示例12: getFilesInRange

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
/**
 * Returns the list of files changed in a specified commit. If the
 * repository does not exist or is empty, an empty list is returned.
 * 
 * @param repository
 * @param startCommit
 *            earliest commit
 * @param endCommit
 *            most recent commit. if null, HEAD is assumed.
 * @return list of files changed in a commit range
 */
public static List<PathChangeModel> getFilesInRange(Repository repository, RevCommit startCommit, RevCommit endCommit) {
	List<PathChangeModel> list = new ArrayList<PathChangeModel>();
	if (!hasCommits(repository)) {
		return list;
	}
	try {
		DiffFormatter df = new DiffFormatter(null);
		df.setRepository(repository);
		df.setDiffComparator(RawTextComparator.DEFAULT);
		df.setDetectRenames(true);

		List<DiffEntry> diffEntries = df.scan(startCommit.getTree(), endCommit.getTree());
		for (DiffEntry diff : diffEntries) {
			
			if (diff.getChangeType().equals(ChangeType.DELETE)) {
				list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff
						.getNewMode().getBits(), diff.getOldId().name(), null, diff
						.getChangeType()));
			} else if (diff.getChangeType().equals(ChangeType.RENAME)) {
				list.add(new PathChangeModel(diff.getOldPath(), diff.getNewPath(), 0, diff
						.getNewMode().getBits(), diff.getNewId().name(), null, diff
						.getChangeType()));
			} else {
				list.add(new PathChangeModel(diff.getNewPath(), diff.getNewPath(), 0, diff
						.getNewMode().getBits(), diff.getNewId().name(), null, diff
						.getChangeType()));
			}
		}			
		Collections.sort(list);
	} catch (Throwable t) {
		error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
	}
	return list;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:46,代碼來源:JGitUtils.java

示例13: parseDiff

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private String parseDiff(Context context, RevWalk walk, RevCommit revCommit) throws Exception {
    if (context.isIndexingDiff() && revCommit.getParentCount() > 0) {
        RevCommit parentCommit = walk.parseCommit(revCommit.getParent(0).getId());
        ByteArrayOutputStream diffOutputStream = new ByteArrayOutputStream();
        DiffFormatter diffFormatter = new DiffFormatter(diffOutputStream);
        diffFormatter.setRepository(context.getRepository());
        diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
        diffFormatter.setDetectRenames(true);
        diffFormatter.format(parentCommit.getTree(), revCommit.getTree());
        return new String(diffOutputStream.toByteArray());
    } else {
        return null;
    }
}
 
開發者ID:obazoud,項目名稱:elasticsearch-river-git,代碼行數:15,代碼來源:RevCommitToIndexCommit.java

示例14: convert

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
/**
 * Construct a generic file object from the attributes of a git DiffEntry.
 *
 * @param  diff    DiffEntry data object
 * @return CMnFile data object
 */
private CMnFile convert(DiffEntry diff) {
    String filename = diff.getNewPath();
    CMnFile.Operation op = null;
    DiffEntry.ChangeType changeType = diff.getChangeType();
    if (changeType == DiffEntry.ChangeType.ADD){
        op = CMnFile.Operation.ADD;
    } else if (changeType == DiffEntry.ChangeType.DELETE){
        op = CMnFile.Operation.DELETE;
    } else if (changeType == DiffEntry.ChangeType.RENAME){
        op = CMnFile.Operation.RENAME;
    } else {
        op = CMnFile.Operation.EDIT;
    }
    CMnFile file = new CMnFile(filename, op);

    // Convert the file diff to a string
    try {
        OutputStream out = new ByteArrayOutputStream();
        DiffFormatter df = new DiffFormatter(out);
        df.setRepository(repository.getRepository());
        df.setDiffComparator(diffComparator);
        df.setDetectRenames(true);
        df.format(diff);
        df.flush();
        file.setDiff(out.toString());
    } catch (IOException ioex) {
    }

    return file;
}
 
開發者ID:ModelN,項目名稱:build-management,代碼行數:37,代碼來源:CMnGitServer.java

示例15: getDiffFormatter

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
public DiffFormatter getDiffFormatter(OutputStream out) {
	DiffFormatter formatter = new DiffFormatter(out);
	formatter.setRepository(git.getRepository());
	formatter.setDiffComparator(RawTextComparator.DEFAULT);
	formatter.setDetectRenames(true);
	
	return formatter;
}
 
開發者ID:Calsign,項目名稱:APDE,代碼行數:9,代碼來源:GitRepository.java


注:本文中的org.eclipse.jgit.diff.DiffFormatter.setDiffComparator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。