當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。