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


Java DiffEntry.getChangeType方法代码示例

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


在下文中一共展示了DiffEntry.getChangeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: notifyWatchers

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private void notifyWatchers(Revision newRevision, ObjectId prevTreeId, ObjectId nextTreeId) {
    final List<DiffEntry> diff = compareTrees(prevTreeId, nextTreeId, TreeFilter.ALL);
    for (DiffEntry e: diff) {
        switch (e.getChangeType()) {
        case ADD:
            commitWatchers.notify(newRevision, e.getNewPath());
            break;
        case MODIFY:
        case DELETE:
            commitWatchers.notify(newRevision, e.getOldPath());
            break;
        default:
            throw new Error();
        }
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:GitRepository.java

示例3: ofDiff

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
public static DiffInfo ofDiff(DiffEntry diffEntry, FileContent oldContent, FileContent newContent, List<DiffBlock> diffBlocks) {
  DiffInfo diffInfo = new DiffInfo();
  diffInfo.diffEntry = diffEntry;
  diffInfo.changeType = diffEntry.getChangeType();
  diffInfo.diffBlocks = diffBlocks;
  diffInfo.binary = (oldContent != null && oldContent.isBinary()) || (newContent != null && newContent.isBinary());
  if (oldContent != null) {
    diffInfo.oldPath = oldContent.getPath();
    // diffInfo.oldText = oldContent.getText();
  }
  if (newContent != null) {
    diffInfo.newPath = newContent.getPath();
    // diffInfo.newText = newContent.getText();
  }
  return diffInfo;
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:17,代码来源:DiffInfo.java

示例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;
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:10,代码来源:GitUtils.java

示例5: 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

示例6: BlobChange

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
public BlobChange(String oldRev, String newRev, DiffEntry diffEntry, 
		WhitespaceOption whitespaceOption) {
	if (diffEntry.getChangeType() == ChangeType.RENAME 
			&& diffEntry.getOldPath().equals(diffEntry.getNewPath())) {
		// for some unknown reason, jgit detects rename even if path 
		// is the same
		type = ChangeType.MODIFY;
	} else {
		type = diffEntry.getChangeType();
	}
	this.whitespaceOption = whitespaceOption;
	oldBlobIdent = GitUtils.getOldBlobIdent(diffEntry, oldRev);
	newBlobIdent = GitUtils.getNewBlobIdent(diffEntry, newRev);
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:15,代码来源:BlobChange.java

示例7: adaptDiffEntry

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private ScmItem adaptDiffEntry(DiffEntry diff) {
    ScmItemAttribute attr = new ScmItemAttribute();
    if (diff.getChangeType() == DiffEntry.ChangeType.DELETE) {
        attr.setName(diff.getOldPath());
    } else if (diff.getChangeType() == DiffEntry.ChangeType.COPY || diff.getChangeType() == DiffEntry.ChangeType.RENAME) {
        attr.setName(diff.getNewPath());
        attr.setOldName(diff.getOldPath());
    } else {
        attr.setName(diff.getNewPath());
    }
    return new ScmItem(diff.getChangeType().name(), attr);
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:13,代码来源:GitRepositoryService.java

示例8: 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

示例9: 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

示例10: processGitConfigChanges

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
/**
 * Fetch the list of changes since the last refresh of the repository and apply the changes to the {@link FlowCatalog}
 * @throws GitAPIException
 * @throws IOException
 */
@VisibleForTesting
void processGitConfigChanges() throws GitAPIException, IOException {
  // if not active or if the flow catalog is not up yet then can't process config changes
  if (!isActive || !this.flowCatalog.isRunning()) {
    log.info("GitConfigMonitor: skip poll since the JobCatalog is not yet running.");
    return;
  }

  List<DiffEntry> changes = this.gitRepo.getChanges();

  for (DiffEntry change : changes) {
    switch (change.getChangeType()) {
      case ADD:
      case MODIFY:
        addSpec(change);
        break;
      case DELETE:
        removeSpec(change);
        break;
      case RENAME:
        removeSpec(change);
        addSpec(change);
        break;
      default:
        throw new RuntimeException("Unsupported change type " + change.getChangeType());
    }
  }

  // Done processing changes, so checkpoint
  this.gitRepo.moveCheckpointAndHashesForward();
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:37,代码来源:GitConfigMonitor.java

示例11: 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

示例12: 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;
}
 
开发者ID:hurik,项目名称:JGeagle,代码行数:43,代码来源:JGit.java

示例13: statusOf

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private String statusOf(DiffEntry d) {
    switch (d.getChangeType()) {
    case ADD:       return "A";
    case MODIFY:    return "M";
    case DELETE:    return "D";
    case RENAME:    return "R"+d.getScore();
    case COPY:      return "C"+d.getScore();
    default:
        throw new AssertionError("Unexpected change type: "+d.getChangeType());
    }
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:12,代码来源:JGitAPIImpl.java

示例14: isRename

import org.eclipse.jgit.diff.DiffEntry; //导入方法依赖的package包/类
private static boolean isRename(DiffEntry ent) {
	return ent.getChangeType() == ChangeType.RENAME
			|| ent.getChangeType() == ChangeType.COPY;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:5,代码来源:TreeRevFilter.java

示例15: 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


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