本文整理匯總了Java中org.eclipse.jgit.diff.DiffEntry.getOldPath方法的典型用法代碼示例。如果您正苦於以下問題:Java DiffEntry.getOldPath方法的具體用法?Java DiffEntry.getOldPath怎麽用?Java DiffEntry.getOldPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.diff.DiffEntry
的用法示例。
在下文中一共展示了DiffEntry.getOldPath方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: removeSpec
import org.eclipse.jgit.diff.DiffEntry; //導入方法依賴的package包/類
/**
* remove a {@link FlowSpec} for a deleted or renamed flow config
* @param change
*/
private void removeSpec(DiffEntry change) {
if (checkConfigFilePath(change.getOldPath())) {
Path configFilePath = new Path(this.repositoryDir, change.getOldPath());
String flowName = FSSpecStore.getSpecName(configFilePath);
String flowGroup = FSSpecStore.getSpecGroup(configFilePath);
// build a dummy config to get the proper URI for delete
Config dummyConfig = ConfigBuilder.create()
.addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY, flowGroup)
.addPrimitive(ConfigurationKeys.FLOW_NAME_KEY, flowName)
.build();
FlowSpec spec = FlowSpec.builder()
.withConfig(dummyConfig)
.withVersion(SPEC_VERSION)
.withDescription(SPEC_DESCRIPTION)
.build();
this.flowCatalog.remove(spec.getUri());
}
}
示例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: getOldBlobIdent
import org.eclipse.jgit.diff.DiffEntry; //導入方法依賴的package包/類
public static BlobIdent getOldBlobIdent(DiffEntry diffEntry, String oldRev) {
BlobIdent blobIdent;
if (diffEntry.getChangeType() != ChangeType.ADD) {
blobIdent = new BlobIdent(oldRev, diffEntry.getOldPath(), diffEntry.getOldMode().getBits());
} else {
blobIdent = new BlobIdent(oldRev, 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: getRenamedPath
import org.eclipse.jgit.diff.DiffEntry; //導入方法依賴的package包/類
/**
*
* Based on http://stackoverflow.com/a/11504177/2246865 by OneWorld
*
* @param follow
* @param start
* @param path
* @return
* @throws IOException
* @throws GitAPIException
*/
private String getRenamedPath(
boolean follow,
RevCommit start,
String path)
throws IOException, GitAPIException {
if (!follow) {
return null;
}
Iterable<RevCommit> allCommitsLater = git.log().add(start).call();
for (RevCommit commit : allCommitsLater) {
TreeWalk tw = new TreeWalk(repository);
tw.addTree(commit.getTree());
tw.addTree(start.getTree());
tw.setRecursive(true);
RenameDetector rd = new RenameDetector(repository);
rd.addAll(DiffEntry.scan(tw));
List<DiffEntry> files = rd.compute();
for (DiffEntry deffE : files) {
if ((deffE.getChangeType() == DiffEntry.ChangeType.RENAME
|| deffE.getChangeType() == DiffEntry.ChangeType.COPY)
&& deffE.getNewPath().contains(path)) {
return deffE.getOldPath();
}
}
}
return null;
}
示例10: 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);
}
示例11: 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());
}
}
示例12: getOldPath
import org.eclipse.jgit.diff.DiffEntry; //導入方法依賴的package包/類
@JavascriptInterface
public String getOldPath(int index) {
DiffEntry diff = mDiffEntries.get(index);
String op = diff.getOldPath();
return op;
}