• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ArchiveCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jgit.api.ArchiveCommand的典型用法代码示例。如果您正苦于以下问题:Java ArchiveCommand类的具体用法?Java ArchiveCommand怎么用?Java ArchiveCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArchiveCommand类属于org.eclipse.jgit.api包,在下文中一共展示了ArchiveCommand类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRepositoryZip

import org.eclipse.jgit.api.ArchiveCommand; //导入依赖的package包/类
/** 커밋을 입력받으면 당시 파일들을 압축하여 사용자에게 보내줌.
 * @param commitName
 * @param format
 * @param response
 */
public void getRepositoryZip(String commitName,String format, HttpServletResponse response) {

	try {
		ArchiveCommand.registerFormat("zip", new ZipFormat());
		ArchiveCommand.registerFormat("tar", new TarFormat());
		ObjectId revId = this.localRepo.resolve(commitName);
		git.archive().setOutputStream(response.getOutputStream())
		.setFormat(format)
		.setTree(revId)
		.call();

		ArchiveCommand.unregisterFormat("zip");
		ArchiveCommand.unregisterFormat("tar");
		response.flushBuffer();
	} catch (Exception e) {
		System.err.println(e.getMessage());
	}

}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:25,代码来源:GitUtil.java


示例2: getProjectZip

import org.eclipse.jgit.api.ArchiveCommand; //导入依赖的package包/类
/** 커밋을 입력받으면 당시 파일들을 압축하여 사용자에게 보내줌.
 * @param commitName
 * @param format
 * @param response
 */
public void getProjectZip(String commitName,String format, HttpServletResponse response) {

	try {
		ArchiveCommand.registerFormat("zip", new ZipFormat());
		ArchiveCommand.registerFormat("tar", new TarFormat());
		ObjectId revId = this.localRepo.resolve(commitName);
		git.archive().setOutputStream(response.getOutputStream())
		.setFormat(format)
		.setTree(revId)
		.call();

		ArchiveCommand.unregisterFormat("zip");
		ArchiveCommand.unregisterFormat("tar");
		response.flushBuffer();
	} catch (Exception e) {
		System.err.println(e.getMessage());
	}

}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:25,代码来源:GitUtils.java


示例3: getConfiguration

import org.eclipse.jgit.api.ArchiveCommand; //导入依赖的package包/类
/**
 * Export the git tag identified by the entry id
 * 
 * @param config
 * @param e
 * @param exportDirectory
 * @throws Exception
 */
public void getConfiguration(Configuration config, Entry e, File exportDirectory) throws Exception {
	Preconditions.checkNotNull(config, "Configuration must be supplied.");
	Preconditions.checkNotNull(e, "Entry must be supplied.");
	Preconditions.checkNotNull(exportDirectory, "Directory must be supplied.");
	File zip = new File(exportDirectory, e.getUUID().toString()+".zip");
	ArchiveCommand.registerFormat("zip", new ZipFormat());
	try (FileOutputStream out = new FileOutputStream(zip);){
		LOG.debug("Exporting tag {} to {}", e.getUUID(), zip);
		git.archive().setTree(git.getRepository().resolve(e.getUUID().toString()))
			.setFormat("zip")
			.setOutputStream(out)
			.call();
	    unzip(zip);
	} catch (IOException | RevisionSyntaxException | GitAPIException ioe) {
		zip.delete();
		LOG.error("Error creating archive from tag: " + e.getUUID().toString(), ioe);
		throw ioe;
	} finally {
		ArchiveCommand.unregisterFormat("zip");
	}
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:30,代码来源:AccumuloConfigurations.java


示例4: main

import org.eclipse.jgit.api.ArchiveCommand; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        File file = File.createTempFile("test", ".mzip");
        // 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);
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:25,代码来源:CreateCustomFormatArchive.java


示例5: apply

import org.eclipse.jgit.api.ArchiveCommand; //导入依赖的package包/类
@Override
public BinaryResult apply(RevisionResource rsrc)
    throws BadRequestException, IOException, MethodNotAllowedException {
  if (Strings.isNullOrEmpty(format)) {
    throw new BadRequestException("format is not specified");
  }
  final ArchiveFormat f = allowedFormats.extensions.get("." + format);
  if (f == null) {
    throw new BadRequestException("unknown archive format");
  }
  if (f == ArchiveFormat.ZIP) {
    throw new MethodNotAllowedException("zip format is disabled");
  }
  boolean close = true;
  final Repository repo = repoManager.openRepository(rsrc.getProject());
  try {
    final RevCommit commit;
    String name;
    try (RevWalk rw = new RevWalk(repo)) {
      commit = rw.parseCommit(ObjectId.fromString(rsrc.getPatchSet().getRevision().get()));
      name = name(f, rw, commit);
    }

    BinaryResult bin =
        new BinaryResult() {
          @Override
          public void writeTo(OutputStream out) throws IOException {
            try {
              new ArchiveCommand(repo)
                  .setFormat(f.name())
                  .setTree(commit.getTree())
                  .setOutputStream(out)
                  .call();
            } catch (GitAPIException e) {
              throw new IOException(e);
            }
          }

          @Override
          public void close() throws IOException {
            repo.close();
          }
        };

    bin.disableGzip().setContentType(f.getMimeType()).setAttachmentName(name);

    close = false;
    return bin;
  } finally {
    if (close) {
      repo.close();
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:55,代码来源:GetArchive.java



注:本文中的org.eclipse.jgit.api.ArchiveCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectorRecordSetProvider类代码示例发布时间:2022-05-22
下一篇:
Java CommandTime类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap