本文整理了Java中org.eclipse.jgit.api.Git.archive()
方法的一些代码示例,展示了Git.archive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.archive()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:archive
[英]Return a command to create an archive from a tree
[中]返回从树创建存档的命令
代码示例来源:origin: centic9/jgit-cookbook
private static void write(Repository repository, String suffix, String format) throws IOException, GitAPIException {
// this is the file that we write the archive to
File file = File.createTempFile("test", suffix);
try (OutputStream out = new FileOutputStream(file)) {
// finally call the ArchiveCommand to write out using the various supported formats
try (Git git = new Git(repository)) {
git.archive()
.setTree(repository.resolve("master"))
.setFormat(format)
.setOutputStream(out)
.call();
}
}
System.out.println("Wrote " + file.length() + " bytes to " + file);
// clean up here to not keep using more and more disk-space for these samples
FileUtils.forceDelete(file);
}
}
代码示例来源:origin: centic9/jgit-cookbook
private static void write(Repository repository, String suffix, String format) throws IOException, GitAPIException {
// this is the file that we write the archive to
File file = File.createTempFile("test", suffix);
try (OutputStream out = new FileOutputStream(file)) {
// finally call the ArchiveCommand to write out using the various supported formats
try (Git git = new Git(repository)) {
git.archive()
.setTree(repository.resolve("master"))
.setFormat(format)
.setOutputStream(out)
.call();
}
}
System.out.println("Wrote " + file.length() + " bytes to " + file);
// clean up here to not keep using more and more disk-space for these samples
FileUtils.forceDelete(file);
}
}
代码示例来源:origin: centic9/jgit-cookbook
public static void main(String[] args) throws IOException, GitAPIException {
File file = File.createTempFile("test", ".mzip");
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// make the archive format known
ArchiveCommand.registerFormat("myzip", new ZipArchiveFormat());
try {
// this is the file that we write the archive to
try (OutputStream out = new FileOutputStream(file)) {
// finally call the ArchiveCommand to write out using the given format
try (Git git = new Git(repository)) {
git.archive()
.setTree(repository.resolve("master"))
.setFormat("myzip")
.setOutputStream(out)
.call();
}
}
} finally {
ArchiveCommand.unregisterFormat("myzip");
}
System.out.println("Wrote " + file.length() + " bytes to " + file);
}
// clean up here to not keep using more and more disk-space for these samples
FileUtils.forceDelete(file);
}
}
代码示例来源:origin: centic9/jgit-cookbook
public static void main(String[] args) throws IOException, GitAPIException {
File file = File.createTempFile("test", ".mzip");
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// make the archive format known
ArchiveCommand.registerFormat("myzip", new ZipArchiveFormat());
try {
// this is the file that we write the archive to
try (OutputStream out = new FileOutputStream(file)) {
// finally call the ArchiveCommand to write out using the given format
try (Git git = new Git(repository)) {
git.archive()
.setTree(repository.resolve("master"))
.setFormat("myzip")
.setOutputStream(out)
.call();
}
}
} finally {
ArchiveCommand.unregisterFormat("myzip");
}
System.out.println("Wrote " + file.length() + " bytes to " + file);
}
// clean up here to not keep using more and more disk-space for these samples
FileUtils.forceDelete(file);
}
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
ArchiveCommand cmd = new Git(db).archive()
.setTree(tree)
.setFormat(format)
代码示例来源:origin: theonedev/onedev
@Override
public void writeData(Attributes attributes) throws IOException {
if (format.equals("zip"))
ArchiveCommand.registerFormat(format, new ZipFormat());
else
ArchiveCommand.registerFormat(format, new TgzFormat());
try {
ArchiveCommand archive = Git.wrap(project.getRepository()).archive();
archive.setFormat(format);
archive.setTree(project.getRevCommit(revision).getId());
archive.setOutputStream(attributes.getResponse().getOutputStream());
archive.call();
} catch (GitAPIException e) {
throw new RuntimeException(e);
} finally {
ArchiveCommand.unregisterFormat(format);
}
}
});
内容来源于网络,如有侵权,请联系作者删除!