当前位置: 首页>>代码示例>>Java>>正文


Java DiffEntry.getNewPath方法代码示例

本文整理汇总了Java中org.eclipse.jgit.diff.DiffEntry.getNewPath方法的典型用法代码示例。如果您正苦于以下问题:Java DiffEntry.getNewPath方法的具体用法?Java DiffEntry.getNewPath怎么用?Java DiffEntry.getNewPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.diff.DiffEntry的用法示例。


在下文中一共展示了DiffEntry.getNewPath方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasMatchingChanges

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private boolean hasMatchingChanges(Revision from, Revision to, PathPatternFilter filter) {
    try (RevWalk revWalk = new RevWalk(jGitRepository)) {
        final List<DiffEntry> diff =
                compareTrees(toTreeId(revWalk, from), toTreeId(revWalk, to), TreeFilter.ALL);
        for (DiffEntry e : diff) {
            final String path;
            switch (e.getChangeType()) {
            case ADD:
                path = e.getNewPath();
                break;
            case MODIFY:
            case DELETE:
                path = e.getOldPath();
                break;
            default:
                throw new Error();
            }

            if (filter.matches(path)) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:27,代码来源:GitRepository.java

示例2: addSpec

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
/**
 * Add a {@link FlowSpec} for an added, updated, or modified flow config
 * @param change
 */
private void addSpec(DiffEntry change) {
  if (checkConfigFilePath(change.getNewPath())) {
    Path configFilePath = new Path(this.repositoryDir, change.getNewPath());

    try {
      Config flowConfig = loadConfigFileWithFlowNameOverrides(configFilePath);

      this.flowCatalog.put(FlowSpec.builder()
          .withConfig(flowConfig)
          .withVersion(SPEC_VERSION)
          .withDescription(SPEC_DESCRIPTION)
          .build());
    } catch (IOException e) {
      log.warn("Could not load config file: " + configFilePath);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:22,代码来源:GitConfigMonitor.java

示例3: addCommitParents

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private void addCommitParents(final RevWalk rw, final DiffFormatter df, final RevCommit revCommit, final GitCommit gitCommit) throws IOException {
    for (int i = 0; i < revCommit.getParentCount(); i++) {
        ObjectId parentId = revCommit.getParent(i).getId();
        RevCommit parent = rw.parseCommit(parentId);

        List<DiffEntry> diffs = df.scan(parent.getTree(), revCommit.getTree());
        for (DiffEntry diff : diffs) {
            final GitChange gitChange = new GitChange(
                    diff.getChangeType().name(),
                    diff.getOldPath(),
                    diff.getNewPath()
            );
            logger.debug(gitChange.toString());
            gitCommit.getGitChanges().add(gitChange);
        }

        String parentSha = ObjectId.toString(parentId);
        final GitCommit parentCommit = retrieveCommit(parentSha);
        gitCommit.getParents().add(parentCommit);
    }
}
 
开发者ID:kontext-e,项目名称:jqassistant-plugins,代码行数:22,代码来源:JGitScanner.java

示例4: getNewBlobIdent

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
public static BlobIdent getNewBlobIdent(DiffEntry diffEntry, String newRev) {
  	BlobIdent blobIdent;
if (diffEntry.getChangeType() != ChangeType.DELETE) {
	blobIdent = new BlobIdent(newRev, diffEntry.getNewPath(), diffEntry.getNewMode().getBits());
} else {
	blobIdent = new BlobIdent(newRev, null, null);
}
return blobIdent;
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:GitUtils.java

示例5: isTouched

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private static boolean isTouched(Set<String> touchedFilePaths, DiffEntry diffEntry) {
  String oldFilePath = diffEntry.getOldPath();
  String newFilePath = diffEntry.getNewPath();
  // One of the above file paths could be /dev/null but we need not explicitly check for this
  // value as the set of file paths shouldn't contain it.
  return touchedFilePaths.contains(oldFilePath) || touchedFilePaths.contains(newFilePath);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:PatchListLoader.java

示例6: getEditsDueToRebase

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private static Set<ContextAwareEdit> getEditsDueToRebase(
    Multimap<String, ContextAwareEdit> editsDueToRebasePerFilePath, DiffEntry diffEntry) {
  if (editsDueToRebasePerFilePath.isEmpty()) {
    return ImmutableSet.of();
  }

  String filePath = diffEntry.getNewPath();
  if (diffEntry.getChangeType() == ChangeType.DELETE) {
    filePath = diffEntry.getOldPath();
  }
  return ImmutableSet.copyOf(editsDueToRebasePerFilePath.get(filePath));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:13,代码来源:PatchListLoader.java

示例7: updateViewFor

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
public void updateViewFor(FileDiff fileDiff) {
    DiffEntry diffEntry = fileDiff.getDiffEntry();
    int changeTypeIcon = diff_changetype_modify;
    String filename = diffEntry.getNewPath();
    switch (diffEntry.getChangeType()) {
        case ADD:
            changeTypeIcon = diff_changetype_add;
            break;
        case DELETE:
            changeTypeIcon = diff_changetype_delete;
            filename = diffEntry.getOldPath();
            break;
        case MODIFY:
            changeTypeIcon = diff_changetype_modify;
            break;
        case RENAME:
            changeTypeIcon = diff_changetype_rename;
            filename = filePathDiffer.diff(diffEntry.getOldPath(), diffEntry.getNewPath());
            break;
        case COPY:
            changeTypeIcon = diff_changetype_add;
            break;
    }

    filePathTextView.setText(filename);
    changeTypeImageView.setImageResource(changeTypeIcon);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:28,代码来源:FileHeaderViewHolder.java

示例8: getChangesForCommitedFiles

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的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

示例9: createParentRelation

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private void createParentRelation(RepositoryModelFactory factory, Rev childModel, Rev parentModel, List<DiffEntry> diffs) {
	ParentRelation parentRelationModel = factory.createParentRelation();
	childModel.getParentRelations().add(parentRelationModel);
	parentRelationModel.setParent(parentModel);		
	for (DiffEntry diffEntry : diffs) {
		int linesAdded = 0;
		int linesRemoved = 0;
		try {
			FileHeader fileHeader = df.toFileHeader(diffEntry);
			for(HunkHeader hunk: fileHeader.getHunks()) {
				for(Edit edit: hunk.toEditList()) {
					linesAdded += edit.getEndB() - edit.getBeginB();
					linesRemoved += edit.getEndA() - edit.getBeginA();
				}					
			}
		} catch (Exception e) {
			linesAdded = -1;
			linesRemoved = -1;
			SrcRepoActivator.INSTANCE.warning("Could not determine added/removed lines for " + diffEntry, e);
		}
		
		Diff diffModel = null;
		String path = diffEntry.getNewPath();			
		diffModel = factory.createDiff();
		diffModel.setNewPath(path);
		diffModel.setOldPath(diffEntry.getOldPath());
		diffModel.setType(diffEntry.getChangeType());
		diffModel.setLinesAdded(linesAdded);
		diffModel.setLinesRemoved(linesRemoved);
		parentRelationModel.getDiffs().add(diffModel);
	}
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:33,代码来源:GitSourceControlSystem.java

示例10: convert

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的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

示例11: createDiffInfo

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
protected DiffInfo createDiffInfo(DiffEntry diffEntry, String diff) {
    return new DiffInfo(diffEntry.getChangeType(), diffEntry.getNewPath(), toInt(diffEntry.getNewMode()), diffEntry.getOldPath(), toInt(diffEntry.getOldMode()), diff);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:4,代码来源:RepositoryResource.java

示例12: visitDiffEntry

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
@Override
public void visitDiffEntry(final DiffEntry entry, final EditList editList,
		final RevCommit commit) throws IOException {
	final String sha = commit.name();
	if (entry.getNewPath().equals("/dev/null")) {
		currentStateOfIdentifiers.removeAll(entry.getOldPath()).forEach(
				i -> {
					if (!i.isDeleted()) {
						i.setIdentifierDeleted();
					}
				});
		return;
	}
	final String repositoryFolder = repository.getRepository()
			.getWorkTree() + "/";

	final File targetFile = new File(repositoryFolder + entry.getNewPath());
	final Set<IdentifierInformation> newIdentifierInfo = infoScanner
			.scanFile(targetFile, commit.name());
	if (currentStateOfIdentifiers.containsKey(entry.getOldPath())) {
		final Collection<IdentifierInformationThroughTime> state = currentStateOfIdentifiers
				.get(entry.getOldPath());
		final List<IdentifierInformationThroughTime> allIitts = Lists
				.newArrayList(state);
		final Set<IdentifierInformationThroughTime> setIitts = Sets
				.newIdentityHashSet();
		setIitts.addAll(state);
		checkArgument(setIitts.size() == allIitts.size(),
				"Before adding, state was inconsistent for ", targetFile);
		updateIdentifierInfoState(state, newIdentifierInfo, editList,
				entry.getNewPath());

		if (!entry.getOldPath().equals(entry.getNewPath())) {
			currentStateOfIdentifiers.putAll(entry.getNewPath(), state);
			currentStateOfIdentifiers.removeAll(entry.getOldPath());
		}
	} else {
		// This is a new file or a file we failed to index before, add
		// happily...
		// checkArgument(entry.getOldPath().equals("/dev/null"));
		final List<IdentifierInformationThroughTime> infosThroughTime = Lists
				.newArrayList();
		newIdentifierInfo
				.forEach(info -> {
					final IdentifierInformationThroughTime inf = new IdentifierInformationThroughTime();
					inf.addInformation(info);
					infosThroughTime.add(inf);
				});
		currentStateOfIdentifiers.putAll(entry.getNewPath(),
				infosThroughTime);
	}

}
 
开发者ID:mast-group,项目名称:naturalize,代码行数:54,代码来源:ChangingIdentifiersRepositoryWalker.java

示例13: format

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
@Override
public void format(DiffEntry ent) throws IOException {
	currentPath = diffStat.addPath(ent);
	nofLinesCurrent = 0;
	isOff = false;
	entry = ent;
	if (!truncated) {
		totalNofLinesPrevious = totalNofLinesCurrent;
		if (globalDiffLimit > 0 && totalNofLinesPrevious > globalDiffLimit) {
			truncated = true;
			isOff = true;
		}
		truncateTo = os.size();
	} else {
		isOff = true;
	}
	if (truncated) {
		skipped.add(ent);
	} else {
		// Produce a header here and now
		String path;
		String id;
		if (ChangeType.DELETE.equals(ent.getChangeType())) {
			path = ent.getOldPath();
			id = ent.getOldId().name();
		} else {
			path = ent.getNewPath();
			id = ent.getNewId().name();
		}
		StringBuilder sb = new StringBuilder(MessageFormat.format(
				"<div class='header'><div class=\"diffHeader\" id=\"n{0}\"><i class=\"icon-file\"></i> ", id));
		sb.append(StringUtils.escapeForHtml(path, false)).append("</div></div>");
		sb.append("<div class=\"diff\"><table cellpadding='0'><tbody>\n");
		os.write(sb.toString().getBytes());
	}
	// Keep formatting, but if off, don't produce anything anymore. We just keep on counting.
	super.format(ent);
	if (!truncated) {
		// Close the table
		os.write("</tbody></table></div>\n".getBytes());
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:43,代码来源:GitBlitDiffFormatter.java

示例14: getNewPath

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
@JavascriptInterface
public String getNewPath(int index) {
    DiffEntry diff = mDiffEntries.get(index);
    String np = diff.getNewPath();
    return np;
}
 
开发者ID:sheimi,项目名称:SGit,代码行数:7,代码来源:CommitDiffActivity.java


注:本文中的org.eclipse.jgit.diff.DiffEntry.getNewPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。