簡體   English   中英

如何從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);

    }

}

如果我理解正確,您想要請求的是存儲庫樹。 為此,您應該使用此端點https://docs.gitlab.com/ee/api/repositories.html

我無法正確測試它,但根據文檔,它看起來像RepositoryApi.getTree()是您正在尋找的getTree()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM