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


Java PathChangeModel类代码示例

本文整理汇总了Java中com.gitblit.models.PathModel.PathChangeModel的典型用法代码示例。如果您正苦于以下问题:Java PathChangeModel类的具体用法?Java PathChangeModel怎么用?Java PathChangeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PathChangeModel类属于com.gitblit.models.PathModel包,在下文中一共展示了PathChangeModel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, String startCommit, String endCommit) {
	List<PathChangeModel> list = new ArrayList<PathChangeModel>();
	if (!hasCommits(repository)) {
		return list;
	}
	try {
		ObjectId startRange = repository.resolve(startCommit);
		ObjectId endRange = repository.resolve(endCommit);
		try (RevWalk rw = new RevWalk(repository)) {
			RevCommit start = rw.parseCommit(startRange);
			RevCommit end = rw.parseCommit(endRange);
			list.addAll(getFilesInRange(repository, start, end));
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
	}
	return list;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:29,代码来源:JGitUtils.java

示例2: getInsertions

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public int getInsertions() {
	int val = 0;
	for (PathChangeModel entry : paths) {
		val += entry.insertions;
	}
	return val;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:8,代码来源:DiffUtils.java

示例3: getDeletions

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public int getDeletions() {
	int val = 0;
	for (PathChangeModel entry : paths) {
		val += entry.deletions;
	}
	return val;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:8,代码来源:DiffUtils.java

示例4: getPath

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public PathChangeModel getPath(String path) {
	PathChangeModel stat = null;
	for (PathChangeModel p : paths) {
		if (p.path.equals(path)) {
			stat = p;
			break;
		}
	}
	return stat;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:11,代码来源:DiffUtils.java

示例5: toString

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
@Override
public String toString() {
	StringBuilder sb = new StringBuilder();
	for (PathChangeModel entry : paths) {
		sb.append(entry.toString()).append('\n');
	}
	sb.setLength(sb.length() - 1);
	return sb.toString();
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:10,代码来源:DiffUtils.java

示例6: 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) {
			
			if (diff.getChangeType().equals(ChangeType.DELETE)) {
				list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff
						.getNewMode().getBits(), diff.getOldId().name(), null, diff
						.getChangeType()));
			} else if (diff.getChangeType().equals(ChangeType.RENAME)) {
				list.add(new PathChangeModel(diff.getOldPath(), diff.getNewPath(), 0, diff
						.getNewMode().getBits(), diff.getNewId().name(), null, diff
						.getChangeType()));
			} else {
				list.add(new PathChangeModel(diff.getNewPath(), diff.getNewPath(), 0, diff
						.getNewMode().getBits(), diff.getNewId().name(), null, diff
						.getChangeType()));
			}
		}			
		Collections.sort(list);
	} catch (Throwable t) {
		error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
	}
	return list;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:46,代码来源:JGitUtils.java

示例7: CommitLegendPanel

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public CommitLegendPanel(String id, List<PathChangeModel> paths) {
	super(id);
	final Map<ChangeType, AtomicInteger> stats = getChangedPathsStats(paths);
	ListDataProvider<ChangeType> legendDp = new ListDataProvider<ChangeType>(
			new ArrayList<ChangeType>(stats.keySet()));
	DataView<ChangeType> legendsView = new DataView<ChangeType>("legend", legendDp) {
		private static final long serialVersionUID = 1L;

		public void populateItem(final Item<ChangeType> item) {
			ChangeType entry = item.getModelObject();

			Label changeType = new Label("changeType", "");
			WicketUtils.setChangeTypeCssClass(changeType, entry);
			item.add(changeType);
			int count = stats.get(entry).intValue();
			String description = "";
			switch (entry) {
			case ADD:
				description = MessageFormat.format(getString("gb.filesAdded"), count);
				break;
			case MODIFY:
				description = MessageFormat.format(getString("gb.filesModified"), count);
				break;
			case DELETE:
				description = MessageFormat.format(getString("gb.filesDeleted"), count);
				break;
			case COPY:
				description = MessageFormat.format(getString("gb.filesCopied"), count);
				break;
			case RENAME:
				description = MessageFormat.format(getString("gb.filesRenamed"), count);
				break;
			}
			item.add(new Label("description", description));
		}
	};
	add(legendsView);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:39,代码来源:CommitLegendPanel.java

示例8: getChangedPathsStats

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
protected Map<ChangeType, AtomicInteger> getChangedPathsStats(List<PathChangeModel> paths) {
	Map<ChangeType, AtomicInteger> stats = new HashMap<ChangeType, AtomicInteger>();
	for (PathChangeModel path : paths) {
		if (!stats.containsKey(path.changeType)) {
			stats.put(path.changeType, new AtomicInteger(0));
		}
		stats.get(path.changeType).incrementAndGet();
	}
	return stats;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:11,代码来源:CommitLegendPanel.java

示例9: testFilesInCommit

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
@Test
public void testFilesInCommit() throws Exception {
	Repository repository = GitBlitSuite.getHelloworldRepository();
	RevCommit commit = JGitUtils.getCommit(repository,
			"1d0c2933a4ae69c362f76797d42d6bd182d05176");
	List<PathChangeModel> paths = JGitUtils.getFilesInCommit(repository, commit);

	commit = JGitUtils.getCommit(repository, "af0e9b2891fda85afc119f04a69acf7348922830");
	List<PathChangeModel> deletions = JGitUtils.getFilesInCommit(repository, commit);

	commit = JGitUtils.getFirstCommit(repository, null);
	List<PathChangeModel> additions = JGitUtils.getFilesInCommit(repository, commit);

	List<PathChangeModel> latestChanges = JGitUtils.getFilesInCommit(repository, null);

	repository.close();
	assertTrue("No changed paths found!", paths.size() == 1);
	for (PathChangeModel path : paths) {
		assertTrue("PathChangeModel hashcode incorrect!",
				path.hashCode() == (path.commitId.hashCode() + path.path.hashCode()));
		assertTrue("PathChangeModel equals itself failed!", path.equals(path));
		assertFalse("PathChangeModel equals string failed!", path.equals(""));
	}
	assertEquals(ChangeType.DELETE, deletions.get(0).changeType);
	assertEquals(ChangeType.ADD, additions.get(0).changeType);
	assertTrue(latestChanges.size() > 0);
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:28,代码来源:JGitUtilsTest.java

示例10: 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;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:65,代码来源:JGitUtils.java

示例11: addPath

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public PathChangeModel addPath(DiffEntry entry) {
	PathChangeModel pcm = PathChangeModel.from(entry, commitId);
	paths.add(pcm);
	return pcm;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:6,代码来源:DiffUtils.java

示例12: 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.
 * @return list of files changed in a commit
 */
public static List<PathChangeModel> getFilesInCommit(Repository repository, RevCommit commit) {
	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) {
			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));
			}
			tw.release();
		} else {
			RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
			DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
			df.setRepository(repository);
			df.setDiffComparator(RawTextComparator.DEFAULT);
			df.setDetectRenames(true);
			List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree());
			for (DiffEntry diff : diffs) {
				String objectId = diff.getNewId().name();
				if (diff.getChangeType().equals(ChangeType.DELETE)) {
					list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff
							.getNewMode().getBits(), objectId, commit.getId().getName(), diff
							.getChangeType()));
				} else if (diff.getChangeType().equals(ChangeType.RENAME)) {
					list.add(new PathChangeModel(diff.getOldPath(), diff.getNewPath(), 0, diff
							.getNewMode().getBits(), objectId, commit.getId().getName(), diff
							.getChangeType()));
				} else {
					list.add(new PathChangeModel(diff.getNewPath(), diff.getNewPath(), 0, diff
							.getNewMode().getBits(), objectId, commit.getId().getName(), diff
							.getChangeType()));
				}
			}
		}
	} catch (Throwable t) {
		error(t, repository, "{0} failed to determine files in commit!");
	} finally {
		rw.dispose();
	}
	return list;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:64,代码来源:JGitUtils.java

示例13: getPushLog

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
/**
 * Returns the list of push log entries as they were recorded by Gitblit.
 * Each PushLogEntry may represent multiple ref updates.
 * 
 * @param repositoryName
 * @param repository
 * @param minimumDate
 * @param offset
 * @param maxCount
 * 			if < 0, all pushes are returned.
 * @return a list of push log entries
 */
public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository,
		Date minimumDate, int offset, int maxCount) {
	List<PushLogEntry> list = new ArrayList<PushLogEntry>();
	RefModel ref = getPushLogBranch(repository);
	if (ref == null) {
		return list;
	}
	if (maxCount == 0) {
		return list;
	}
	
	Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository);
	List<RevCommit> pushes;
	if (minimumDate == null) {
		pushes = JGitUtils.getRevLog(repository, GB_PUSHES, offset, maxCount);
	} else {
		pushes = JGitUtils.getRevLog(repository, GB_PUSHES, minimumDate);
	}
	for (RevCommit push : pushes) {
		if (push.getAuthorIdent().getName().equalsIgnoreCase("gitblit")) {
			// skip gitblit/internal commits
			continue;
		}

		UserModel user = newUserModelFrom(push.getAuthorIdent());
		Date date = push.getAuthorIdent().getWhen();
		
		PushLogEntry log = new PushLogEntry(repositoryName, date, user);
		list.add(log);
		List<PathChangeModel> changedRefs = JGitUtils.getFilesInCommit(repository, push);
		for (PathChangeModel change : changedRefs) {
			switch (change.changeType) {
			case DELETE:
				log.updateRef(change.path, ReceiveCommand.Type.DELETE);
				break;
			case ADD:
				log.updateRef(change.path, ReceiveCommand.Type.CREATE);
			default:
				String content = JGitUtils.getStringContent(repository, push.getTree(), change.path);
				String [] fields = content.split(" ");
				String oldId = fields[1];
				String newId = fields[2];
				log.updateRef(change.path, ReceiveCommand.Type.valueOf(fields[0]), oldId, newId);
				List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId);
				for (RevCommit pushedCommit : pushedCommits) {
					RepositoryCommit repoCommit = log.addCommit(change.path, pushedCommit);
					if (repoCommit != null) {
						repoCommit.setRefs(allRefs.get(pushedCommit.getId()));
					}
				}
			}
		}
	}
	Collections.sort(list);
	return list;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:69,代码来源:PushLogUtils.java

示例14: getPushLog

import com.gitblit.models.PathModel.PathChangeModel; //导入依赖的package包/类
public static List<PushLogEntry> getPushLog(String repositoryName, Repository repository, Date minimumDate, int maxCount) {
	List<PushLogEntry> list = new ArrayList<PushLogEntry>();
	RefModel ref = getPushLogBranch(repository);
	if (ref == null) {
		return list;
	}
	List<RevCommit> pushes;
	if (minimumDate == null) {
		pushes = JGitUtils.getRevLog(repository, GB_PUSHES, 0, maxCount);
	} else {
		pushes = JGitUtils.getRevLog(repository, GB_PUSHES, minimumDate);
	}
	for (RevCommit push : pushes) {
		if (push.getAuthorIdent().getName().equalsIgnoreCase("gitblit")) {
			// skip gitblit/internal commits
			continue;
		}
		Date date = push.getAuthorIdent().getWhen();
		UserModel user = new UserModel(push.getAuthorIdent().getEmailAddress());
		user.displayName = push.getAuthorIdent().getName();
		PushLogEntry log = new PushLogEntry(repositoryName, date, user);
		list.add(log);
		List<PathChangeModel> changedRefs = JGitUtils.getFilesInCommit(repository, push);
		for (PathChangeModel change : changedRefs) {
			switch (change.changeType) {
			case DELETE:
				log.updateRef(change.path, ReceiveCommand.Type.DELETE);
				break;
			case ADD:
				log.updateRef(change.path, ReceiveCommand.Type.CREATE);
			default:
				String content = JGitUtils.getStringContent(repository, push.getTree(), change.path);
				String [] fields = content.split(" ");
				log.updateRef(change.path, ReceiveCommand.Type.valueOf(fields[0]));
				String oldId = fields[1];
				String newId = fields[2];
				List<RevCommit> pushedCommits = JGitUtils.getRevLog(repository, oldId, newId);
				for (RevCommit pushedCommit : pushedCommits) {
					log.addCommit(change.path, pushedCommit);
				}
			}
		}
	}
	Collections.sort(list);
	return list;
}
 
开发者ID:BullShark,项目名称:IRCBlit,代码行数:47,代码来源:PushLogUtils.java


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