本文整理汇总了Java中org.eclipse.jgit.dircache.DirCache.newInCore方法的典型用法代码示例。如果您正苦于以下问题:Java DirCache.newInCore方法的具体用法?Java DirCache.newInCore怎么用?Java DirCache.newInCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.dircache.DirCache
的用法示例。
在下文中一共展示了DirCache.newInCore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blockingPreviewDiff
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private Map<String, Change<?>> blockingPreviewDiff(Revision baseRevision, Iterable<Change<?>> changes) {
requireNonNull(baseRevision, "baseRevision");
requireNonNull(changes, "changes");
baseRevision = blockingNormalize(baseRevision);
try (ObjectReader reader = jGitRepository.newObjectReader();
RevWalk revWalk = new RevWalk(reader);
DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE)) {
final ObjectId baseTreeId = toTreeId(revWalk, baseRevision);
final DirCache dirCache = DirCache.newInCore();
final int numEdits = applyChanges(baseRevision, baseTreeId, dirCache, changes);
if (numEdits == 0) {
return Collections.emptyMap();
}
CanonicalTreeParser p = new CanonicalTreeParser();
p.reset(reader, baseTreeId);
diffFormatter.setRepository(jGitRepository);
List<DiffEntry> result = diffFormatter.scan(p, new DirCacheIterator(dirCache));
return toChangeMap(result);
} catch (IOException e) {
throw new StorageException("failed to perform a dry-run diff", e);
}
}
示例2: checkoutCacheWithIgnoringSomeFile_theIgnoredFileShouldNotBeCheckedOut
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Test
public void checkoutCacheWithIgnoringSomeFile_theIgnoredFileShouldNotBeCheckedOut() throws IOException {
initGitFileSystem("/some_existing_file.txt");
DirCache cache = DirCache.newInCore();
DirCacheBuilder builder = cache.builder();
builder.add(someEntry("/test_file1.txt"));
builder.add(someEntry("/test_file2.txt"));
builder.add(someEntry("/test_file3.txt"));
builder.finish();
new GfsDefaultCheckout(gfs).ignoredFiles(singleton("/test_file2.txt")).checkout(cache);
assertTrue(Files.exists(gfs.getPath("/test_file1.txt")));
assertFalse(Files.exists(gfs.getPath("/test_file2.txt")));
assertTrue(Files.exists(gfs.getPath("/test_file3.txt")));
}
示例3: getDirCache
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public DirCache getDirCache() {
if (dirCache == null) {
dirCache = DirCache.newInCore();
}
return dirCache;
}
示例4: checkoutCacheWithMultiStagesFile_shouldThrowIllegalStateException
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Test(expected = IllegalStateException.class)
public void checkoutCacheWithMultiStagesFile_shouldThrowIllegalStateException() throws IOException {
initGitFileSystem("/some_existing_file.txt");
DirCache cache = DirCache.newInCore();
DirCacheBuilder builder = cache.builder();
builder.add(someEntry("/test_file.txt", STAGE_1));
builder.add(someEntry("/test_file.txt", STAGE_2));
builder.add(someEntry("/test_file.txt", STAGE_3));
builder.finish();
new GfsDefaultCheckout(gfs).checkout(cache);
}
示例5: checkoutCacheWithIgnoringMultiStagesFile_theIgnoredFileShouldNotBeCheckedOut
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Test
public void checkoutCacheWithIgnoringMultiStagesFile_theIgnoredFileShouldNotBeCheckedOut() throws IOException {
initGitFileSystem("/some_existing_file.txt");
DirCache cache = DirCache.newInCore();
DirCacheBuilder builder = cache.builder();
builder.add(someEntry("/test_file.txt", STAGE_1));
builder.add(someEntry("/test_file.txt", STAGE_2));
builder.add(someEntry("/test_file.txt", STAGE_3));
builder.finish();
new GfsDefaultCheckout(gfs).ignoredFiles(singleton("/test_file.txt")).checkout(cache);
assertFalse(Files.exists(gfs.getPath("/test_file.txt")));
}
示例6: setupCache
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Nonnull
private static DirCache setupCache(String... files) {
DirCache cache = DirCache.newInCore();
DirCacheBuilder builder = cache.builder();
for(String file : files)
CacheUtils.addFile(file, REGULAR_FILE, zeroId(), builder);
builder.finish();
return cache;
}
示例7: addFilesWithDirCacheBuilderTest
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Test
public void addFilesWithDirCacheBuilderTest() {
DirCache cache = DirCache.newInCore();
DirCacheBuilder builder = cache.builder();
String[] files = new String[] {"a/b/c1.txt",
"a/c2.txt",
"a/c3.txt",
"a/b/c4.txt"};
for(String file : files)
CacheUtils.addFile(file, REGULAR_FILE, zeroId(), builder);builder.finish();
int entryCount = cache.getEntryCount();
assertEquals(4, entryCount);
}
示例8: readBaseTree
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private DirCache readBaseTree(Repository repository) throws IOException {
try (ObjectReader objectReader = repository.newObjectReader()) {
DirCache dirCache = DirCache.newInCore();
DirCacheBuilder dirCacheBuilder = dirCache.builder();
dirCacheBuilder.addTree(
new byte[0], DirCacheEntry.STAGE_0, objectReader, baseCommit.getTree());
dirCacheBuilder.finish();
return dirCache;
}
}
示例9: readTree
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private static DirCache readTree(RevWalk rw, ObjectId base) throws IOException {
final DirCache dc = DirCache.newInCore();
final DirCacheBuilder b = dc.builder();
b.addTree(
new byte[0], // no prefix path
DirCacheEntry.STAGE_0, // standard stage
rw.getObjectReader(),
rw.parseTree(base));
b.finish();
return dc;
}
示例10: readTree
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
protected DirCache readTree(RevTree tree)
throws IOException, MissingObjectException, IncorrectObjectTypeException {
DirCache dc = DirCache.newInCore();
if (tree != null) {
DirCacheBuilder b = dc.builder();
b.addTree(new byte[0], DirCacheEntry.STAGE_0, reader, tree);
b.finish();
}
return dc;
}
示例11: createTreeWithFile
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Nonnull
private ObjectId createTreeWithFile(String path, byte[] bytes) throws IOException {
DirCache cache = DirCache.newInCore();
CacheUtils.addFile(path, REGULAR_FILE, BlobUtils.insertBlob(bytes, repo), cache);
return CacheUtils.writeTree(cache, repo);
}
示例12: createCacheWithFile
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Nonnull
private DirCache createCacheWithFile(String path) throws IOException {
DirCache cache = DirCache.newInCore();
CacheUtils.addFile(path, REGULAR_FILE, someObjectId(), cache);
return cache;
}
示例13: setUpCache
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Before
public void setUpCache() {
cache = DirCache.newInCore();
}
示例14: clearCache
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
protected void clearCache() {
cache = DirCache.newInCore();
}
示例15: insert
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public void insert(Account account) throws IOException {
File path = getPath();
if (path != null) {
try (Repository repo = new FileRepository(path);
ObjectInserter oi = repo.newObjectInserter()) {
PersonIdent ident =
new PersonIdent(
new GerritPersonIdentProvider(flags.cfg).get(), account.getRegisteredOn());
Config accountConfig = new Config();
AccountConfig.writeToConfig(account, accountConfig);
DirCache newTree = DirCache.newInCore();
DirCacheEditor editor = newTree.editor();
final ObjectId blobId =
oi.insert(Constants.OBJ_BLOB, accountConfig.toText().getBytes(UTF_8));
editor.add(
new PathEdit(AccountConfig.ACCOUNT_CONFIG) {
@Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.REGULAR_FILE);
ent.setObjectId(blobId);
}
});
editor.finish();
ObjectId treeId = newTree.writeTree(oi);
CommitBuilder cb = new CommitBuilder();
cb.setTreeId(treeId);
cb.setCommitter(ident);
cb.setAuthor(ident);
cb.setMessage("Create Account");
ObjectId id = oi.insert(cb);
oi.flush();
String refName = RefNames.refsUsers(account.getId());
RefUpdate ru = repo.updateRef(refName);
ru.setExpectedOldObjectId(ObjectId.zeroId());
ru.setNewObjectId(id);
ru.setRefLogIdent(ident);
ru.setRefLogMessage("Create Account", false);
Result result = ru.update();
if (result != Result.NEW) {
throw new IOException(
String.format("Failed to update ref %s: %s", refName, result.name()));
}
account.setMetaId(id.name());
}
}
}