Api 如何使用kohsuke github复制文件
我正在使用org.kohsuke.github.*Api 如何使用kohsuke github复制文件,api,file,github,add,Api,File,Github,Add,我正在使用org.kohsuke.github.* 我有一个示例存储库,其中有一个commit(sha),其中包含一组用作模板的文件 当我在我的应用程序上收到一个名为xyz的请求时,我需要fork-repo-xyz,从#1抓取文件,将文件添加到fork-repo,然后从fork-repo向原始repo-xyz提交PR 这可以通过kohsuke github实现吗 查阅了kohsuke的文件 public static GHRepository createFork(String repo)
public static GHRepository createFork(String repo) throws IOException{
GHRepository mainRepo = github.getRepository(repo);
GHRepository forkedRepo = mainRepo.fork();
GHCommit commit = copyFiles();
/*QUESTION: Here is where I need help. Now that I have the
commit that has the files I need how to I add them to
forkedRepo?******** */
GHCommitBuilder builder = forkedRepo.createCommit();
return forkedRepo;
}
public static GHCommit copyFiles() throws IOException {
GHRepository mainRepo = github.getRepository("sandbox/xyz");
/* xxxxxxxxx is the sha of commit that has templated files.
GHCommit commit = mainRepo.getCommit("xxxxxxxxxxx");
GHContent content = new GHContent();
return commit;
}