我一直在尝试使用JGIT和JIMFS使用类似的东西将一个小型 git 配置存储库克隆到内存中
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path gitPath = Files.createDirectories(fs.getPath("/git"));
Git.cloneRepository().setURI(...).setBranch(...).setDirectory(gitPath.toFile())
.setCredentialsProvider(...).call()
但是由于 JIMFS 使用路径Path API(因为它不使用默认文件系统),而 JGIT 使用File API,JIMFS 没有实现 toFile() 调用:
@Override
public File toFile() {
// documented as unsupported for anything but the default file system
throw new UnsupportedOperationException();
}
所以我得到的是这个UnsupportedOperationException
。有没有一种简单的方法可以让这个(或类似的)设置工作而不求助于磁盘上的临时目录?