如何从 git 存储库中读取所有具有不同扩展名的文件?
How to read all files with different extensions from git repository?
如何从 GitLab 存储库中读取所有具有不同扩展名(比如 .txt、.yml 等)的文件?
我正在使用 GitLabApi
,下面是我到目前为止完成的代码。这基本上是获取单个文件。
public class GitLabRepoService {
@Value("${gitlab.accessToken}")
private String strAccessToken;
@Value("${gitlab.perfScript.projectId}")
private String strProjectId;
public RepositoryFile readFilesFromGitLabRepo(String hostUrl,String fileName,String strBranch) throws Exception {
GitLabApi gitLabApi = new GitLabApi(hostUrl, strAccessToken);
gitLabApi.setIgnoreCertificateErrors(true);
gitLabApi.getRepositoryFileApi().
return gitLabApi.getRepositoryFileApi().getFile(strProjectId, fileName, strBranch);
}
}
如果我没理解错的话,你要的是repositories tree。为此,您应该使用此端点 https://docs.gitlab.com/ee/api/repositories.html
我无法正确测试它,但根据文档,它看起来像 RepositoryApi.getTree()
就是你要找的东西 getTree()
如何从 GitLab 存储库中读取所有具有不同扩展名(比如 .txt、.yml 等)的文件?
我正在使用 GitLabApi
,下面是我到目前为止完成的代码。这基本上是获取单个文件。
public class GitLabRepoService {
@Value("${gitlab.accessToken}")
private String strAccessToken;
@Value("${gitlab.perfScript.projectId}")
private String strProjectId;
public RepositoryFile readFilesFromGitLabRepo(String hostUrl,String fileName,String strBranch) throws Exception {
GitLabApi gitLabApi = new GitLabApi(hostUrl, strAccessToken);
gitLabApi.setIgnoreCertificateErrors(true);
gitLabApi.getRepositoryFileApi().
return gitLabApi.getRepositoryFileApi().getFile(strProjectId, fileName, strBranch);
}
}
如果我没理解错的话,你要的是repositories tree。为此,您应该使用此端点 https://docs.gitlab.com/ee/api/repositories.html
我无法正确测试它,但根据文档,它看起来像 RepositoryApi.getTree()
就是你要找的东西 getTree()