本文整理汇总了Java中org.eclipse.jgit.treewalk.WorkingTreeIterator类的典型用法代码示例。如果您正苦于以下问题:Java WorkingTreeIterator类的具体用法?Java WorkingTreeIterator怎么用?Java WorkingTreeIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkingTreeIterator类属于org.eclipse.jgit.treewalk包,在下文中一共展示了WorkingTreeIterator类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIfUnversioned
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
private void deleteIfUnversioned(DirCache cache, String path, WorkingTreeIterator f, Repository repository, TreeWalk treeWalk) throws IOException, NoWorkTreeException {
if (cache.getEntry(path) == null && // not in index
!f.isEntryIgnored() && // not ignored
!Utils.isFromNested(f.getEntryFileMode().getBits()))
{
File file = new File(repository.getWorkTree().getAbsolutePath() + File.separator + path);
if(file.isDirectory()) {
String[] s = file.list();
if(s != null && s.length > 0) { // XXX is there no better way to find out if empty?
// not empty
return;
}
}
file.delete();
listener.notifyFile(file, treeWalk.getPathString());
}
}
示例2: getObjectId
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
/**
* TODO: see if performance can be improved
*/
private ObjectId getObjectId(File file) throws IOException {
try (TreeWalk treeWalk = new TreeWalk(localRepo)) {
treeWalk.addTree(new FileTreeIterator(localRepo));
String path = getRepoPath(file);
treeWalk.setFilter(PathFilter.create(path));
while (treeWalk.next()) {
WorkingTreeIterator workingTreeIterator = treeWalk.getTree(0, WorkingTreeIterator.class);
if (treeWalk.getPathString().equals(path))
return workingTreeIterator.getEntryObjectId();
if (workingTreeIterator.getEntryFileMode().equals(FileMode.TREE))
treeWalk.enterSubtree();
}
return ObjectId.zeroId(); // not found
}
}
示例3: newMerger
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
@Override
public ThreeWayMerger newMerger (Repository db, boolean inCore) {
return new RecursiveMerger(db, inCore) {
protected boolean mergeTreeWalk (TreeWalk treeWalk, boolean ignoreConflicts)
throws IOException {
boolean ok = true;
boolean hasWorkingTreeIterator = tw.getTreeCount() > T_FILE;
while (treeWalk.next()) {
if (!processEntry(
treeWalk.getTree(T_BASE, CanonicalTreeParser.class),
treeWalk.getTree(T_OURS, CanonicalTreeParser.class),
treeWalk.getTree(T_THEIRS, CanonicalTreeParser.class),
treeWalk.getTree(T_INDEX, DirCacheBuildIterator.class),
hasWorkingTreeIterator ? treeWalk.getTree(T_FILE,
WorkingTreeIterator.class) : null, ignoreConflicts)) {
ok = false;
}
if (treeWalk.isSubtree() && enterSubtree) {
treeWalk.enterSubtree();
}
}
if (!ok) {
cleanUp();
}
return ok;
}
};
}
示例4: NoGitignoreIterator
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
protected NoGitignoreIterator(
WorkingTreeIterator p,
File root,
FS fs,
FileModeStrategy fileModeStrategy
) {
super(p, root, fs, fileModeStrategy);
}
示例5: run
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
@Override
protected void run() throws GitException {
Repository repository = getRepository();
DiffFormatter formatter = new DiffFormatter(out);
formatter.setRepository(repository);
ObjectReader or = null;
String workTreePath = repository.getWorkTree().getAbsolutePath();
try {
Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots);
if (!pathFilters.isEmpty()) {
formatter.setPathFilter(PathFilterGroup.create(pathFilters));
}
if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) {
// work-around for autocrlf
formatter.setDiffComparator(new AutoCRLFComparator());
}
or = repository.newObjectReader();
AbstractTreeIterator firstTree = getIterator(firstCommit, or);
AbstractTreeIterator secondTree = getIterator(secondCommit, or);
List<DiffEntry> diffEntries;
if (secondTree instanceof WorkingTreeIterator) {
// remote when fixed in JGit, see ExportDiffTest.testDiffRenameDetectionProblem
formatter.setDetectRenames(false);
diffEntries = formatter.scan(firstTree, secondTree);
formatter.setDetectRenames(true);
RenameDetector detector = formatter.getRenameDetector();
detector.reset();
detector.addAll(diffEntries);
diffEntries = detector.compute(new ContentSource.Pair(ContentSource.create(or), ContentSource.create((WorkingTreeIterator) secondTree)), NullProgressMonitor.INSTANCE);
} else {
formatter.setDetectRenames(true);
diffEntries = formatter.scan(firstTree, secondTree);
}
for (DiffEntry ent : diffEntries) {
if (monitor.isCanceled()) {
break;
}
listener.notifyFile(new File(workTreePath + File.separator + ent.getNewPath()), ent.getNewPath());
formatter.format(ent);
}
formatter.flush();
} catch (IOException ex) {
throw new GitException(ex);
} finally {
if (or != null) {
or.release();
}
formatter.release();
}
}
示例6: testAddMixedLineEndings
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
public void testAddMixedLineEndings () throws Exception {
File f = new File(workDir, "f");
String content = "";
for (int i = 0; i < 10000; ++i) {
content += i + "\r\n";
}
write(f, content);
File[] files = new File[] { f };
GitClient client = getClient(workDir);
client.add(files, NULL_PROGRESS_MONITOR);
client.commit(files, "commit", null, null, NULL_PROGRESS_MONITOR);
Map<File, GitStatus> statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertEquals(1, statuses.size());
assertStatus(statuses, workDir, f, true, Status.STATUS_NORMAL, Status.STATUS_NORMAL, Status.STATUS_NORMAL, false);
// lets turn autocrlf on
StoredConfig cfg = repository.getConfig();
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, "true");
cfg.save();
// when this starts failing, remove the work around
ObjectInserter inserter = repository.newObjectInserter();
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.setFilter(PathFilterGroup.createFromStrings("f"));
treeWalk.setRecursive(true);
treeWalk.reset();
treeWalk.addTree(new FileTreeIterator(repository));
while (treeWalk.next()) {
String path = treeWalk.getPathString();
assertEquals("f", path);
WorkingTreeIterator fit = treeWalk.getTree(0, WorkingTreeIterator.class);
InputStream in = fit.openEntryStream();
try {
inserter.insert(Constants.OBJ_BLOB, fit.getEntryLength(), in);
fail("this should fail, remove the work around");
} catch (EOFException ex) {
assertEquals("Input did not match supplied length. 10000 bytes are missing.", ex.getMessage());
} finally {
in.close();
inserter.release();
}
break;
}
// no err should occur
write(f, content + "hello");
statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertEquals(1, statuses.size());
assertStatus(statuses, workDir, f, true, Status.STATUS_NORMAL, Status.STATUS_MODIFIED, Status.STATUS_MODIFIED, false);
client.add(files, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertEquals(1, statuses.size());
assertStatus(statuses, workDir, f, true, Status.STATUS_MODIFIED, Status.STATUS_NORMAL, Status.STATUS_MODIFIED, false);
client.commit(files, "message", null, null, NULL_PROGRESS_MONITOR);
statuses = client.getStatus(files, NULL_PROGRESS_MONITOR);
assertEquals(1, statuses.size());
assertStatus(statuses, workDir, f, true, Status.STATUS_NORMAL, Status.STATUS_NORMAL, Status.STATUS_NORMAL, false);
}
示例7: setWorkingTreeIterator
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
/**
* Allow clients to provide their own implementation of a FileTreeIterator
*
* @param f f
* @return {@code this}
*/
@Nonnull
public CustomAddCommand setWorkingTreeIterator(@Nonnull WorkingTreeIterator f) {
workingTreeIterator = f;
return this;
}
示例8: setWorkingTreeIterator
import org.eclipse.jgit.treewalk.WorkingTreeIterator; //导入依赖的package包/类
public final void setWorkingTreeIterator(WorkingTreeIterator iterator) { workingTreeIterator = Optional.of(iterator); }