本文整理匯總了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;
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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());
}
}
示例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;
}