Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api 如何使用kohsuke github复制文件_Api_File_Github_Add - Fatal编程技术网

Api 如何使用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)

我正在使用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) 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;
        }