本文整理汇总了Java中com.gitblit.models.PathModel.PathChangeModel.from方法的典型用法代码示例。如果您正苦于以下问题:Java PathChangeModel.from方法的具体用法?Java PathChangeModel.from怎么用?Java PathChangeModel.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gitblit.models.PathModel.PathChangeModel
的用法示例。
在下文中一共展示了PathChangeModel.from方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilesInRange
import com.gitblit.models.PathModel.PathChangeModel; //导入方法依赖的package包/类
/**
* Returns the list of files changed in a specified commit. If the repository does not exist or is empty, an empty list is returned.
*
* @param repository
* @param startCommit
* earliest commit
* @param endCommit
* most recent commit. if null, HEAD is assumed.
* @return list of files changed in a commit range
*/
public static List<PathChangeModel> getFilesInRange(Repository repository, RevCommit startCommit, RevCommit endCommit) {
List<PathChangeModel> list = new ArrayList<PathChangeModel>();
if (!hasCommits(repository)) {
return list;
}
try (DiffFormatter df = new DiffFormatter(null)) {
df.setRepository(repository);
df.setDiffComparator(RawTextComparator.DEFAULT);
df.setDetectRenames(true);
List<DiffEntry> diffEntries = df.scan(startCommit.getTree(), endCommit.getTree());
for (DiffEntry diff : diffEntries) {
PathChangeModel pcm = PathChangeModel.from(diff, endCommit.getName());
list.add(pcm);
}
Collections.sort(list);
} catch (Throwable t) {
error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
}
return list;
}
示例2: getFilesInCommit
import com.gitblit.models.PathModel.PathChangeModel; //导入方法依赖的package包/类
/**
* Returns the list of files changed in a specified commit. If the repository does not exist or is empty, an empty list is returned.
*
* @param repository
* @param commit
* if null, HEAD is assumed.
* @param calculateDiffStat
* if true, each PathChangeModel will have insertions/deletions
* @return list of files changed in a commit
*/
public static List<PathChangeModel> getFilesInCommit(Repository repository, RevCommit commit, boolean calculateDiffStat) {
List<PathChangeModel> list = new ArrayList<PathChangeModel>();
if (!hasCommits(repository)) {
return list;
}
RevWalk rw = new RevWalk(repository);
try {
if (commit == null) {
ObjectId object = getDefaultBranch(repository);
commit = rw.parseCommit(object);
}
if (commit.getParentCount() == 0) {
try (TreeWalk tw = new TreeWalk(repository)) {
tw.reset();
tw.setRecursive(true);
tw.addTree(commit.getTree());
while (tw.next()) {
list.add(new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw.getRawMode(0), tw.getObjectId(0).getName(), commit
.getId().getName(), ChangeType.ADD));
}
}
} else {
RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
try (DiffStatFormatter df = new DiffStatFormatter(commit.getName())) {
df.setRepository(repository);
df.setDiffComparator(RawTextComparator.DEFAULT);
df.setDetectRenames(true);
List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree());
for (DiffEntry diff : diffs) {
// create the path change model
PathChangeModel pcm = PathChangeModel.from(diff, commit.getName());
if (calculateDiffStat) {
// update file diffstats
df.format(diff);
PathChangeModel pathStat = df.getDiffStat().getPath(pcm.path);
if (pathStat != null) {
pcm.insertions = pathStat.insertions;
pcm.deletions = pathStat.deletions;
}
}
list.add(pcm);
}
}
}
} catch (Throwable t) {
error(t, repository, "{0} failed to determine files in commit!");
} finally {
rw.close();
rw.dispose();
}
return list;
}
示例3: addPath
import com.gitblit.models.PathModel.PathChangeModel; //导入方法依赖的package包/类
public PathChangeModel addPath(DiffEntry entry) {
PathChangeModel pcm = PathChangeModel.from(entry, commitId);
paths.add(pcm);
return pcm;
}