本文整理汇总了Java中org.eclipse.jgit.dircache.DirCacheEntry.getObjectId方法的典型用法代码示例。如果您正苦于以下问题:Java DirCacheEntry.getObjectId方法的具体用法?Java DirCacheEntry.getObjectId怎么用?Java DirCacheEntry.getObjectId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.dircache.DirCacheEntry
的用法示例。
在下文中一共展示了DirCacheEntry.getObjectId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryConflictFile
import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
@Override
public ConflictFile queryConflictFile(Workspace ws, String path, boolean base64) throws Exception {
GitStatus status = status(ws, ws.getRelativePath(path));
String relativePath = ws.getRelativePath(path).toString();
if (!status.equals(GitStatus.CONFLICTION)) {
throw new GitOperationException(format("status of %s is not confliction", path));
}
String basePath = path + CONFLIX_FILE_BASE_SUFFIX;
String localPath = path + CONFLIX_FILE_LOCAL_SUFFIX;
String remotePath = path + CONFLIX_FILE_REMOTE_SUFFIX;
if (!ws.exists(basePath)
|| !ws.exists(localPath)
|| !ws.exists(remotePath)) {
Repository repository = getRepository(ws.getSpaceKey());
DirCacheEntry[] entries = findEntrys(repository, relativePath);
ObjectId local = null, remote = null, base = null;
for (DirCacheEntry entry : entries) {
if (entry.getStage() == DirCacheEntry.STAGE_1) base = entry.getObjectId();
else if (entry.getStage() == DirCacheEntry.STAGE_2) local = entry.getObjectId();
else if (entry.getStage() == DirCacheEntry.STAGE_3) remote = entry.getObjectId();
}
generate_conflict_files(ws, base, local, remote, path);
}
ConflictFile response = new ConflictFile();
response.setBase(ws.read(basePath, ws.getEncoding(), base64));
response.setLocal(ws.read(localPath, ws.getEncoding(), base64));
response.setRemote(ws.read(remotePath, ws.getEncoding(), base64));
return response;
}
示例2: testAddSymlink
import org.eclipse.jgit.dircache.DirCacheEntry; //导入方法依赖的package包/类
public void testAddSymlink () throws Exception {
if (isWindows()) {
return;
}
String path = "folder/file";
File f = new File(workDir, path);
f.getParentFile().mkdir();
write(f, "file");
add(f);
commit(f);
Thread.sleep(1100);
// try with commandline client
File link = new File(workDir, "link");
runExternally(workDir, Arrays.asList("ln", "-s", path, link.getName()));
long ts = Files.readAttributes(Paths.get(link.getAbsolutePath()), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).lastModifiedTime().toMillis();
runExternally(workDir, Arrays.asList("git", "add", link.getName()));
DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
assertEquals(FileMode.SYMLINK, e.getFileMode());
ObjectId id = e.getObjectId();
assertEquals(ts, e.getLastModified() / 1000 * 1000);
ObjectReader reader = repository.getObjectDatabase().newReader();
assertTrue(reader.has(e.getObjectId()));
byte[] bytes = reader.open(e.getObjectId()).getBytes();
assertEquals(path, RawParseUtils.decode(bytes));
// now with internal
File link2 = new File(workDir, "link2");
Files.createSymbolicLink(Paths.get(link2.getAbsolutePath()), Paths.get(path));
ts = Files.readAttributes(Paths.get(link2.getAbsolutePath()), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).lastModifiedTime().toMillis();
getClient(workDir).add(new File[] { link2 }, NULL_PROGRESS_MONITOR);
DirCacheEntry e2 = repository.readDirCache().getEntry(link2.getName());
assertEquals(FileMode.SYMLINK, e2.getFileMode());
assertEquals(id, e2.getObjectId());
assertEquals(0, e2.getLength());
assertEquals(ts, e2.getLastModified() / 1000 * 1000);
assertTrue(reader.has(e2.getObjectId()));
bytes = reader.open(e2.getObjectId()).getBytes();
assertEquals(path, RawParseUtils.decode(bytes));
reader.release();
}