使用Gitlab API v4从分支下载目录

问题描述:

我正在尝试从Gitlab下载存储库的版本"分支内的目录.我正在使用API​​ v4.

I am trying to download a directory inside of a 'release' branch of a repository from Gitlab. I am using API v4.

分支包括以下结构:

- archive
  - outputs
    - history-2020-01-01T142535 
    - history-2020-01-15T142559
    - history-2020-02-01T142540

我想获得"history-2020-02-01T142540"目录.

I want to get the "history-2020-02-01T142540" directory.

我可以获得整个分支的ZIP存档...

I can get a ZIP archive of the entire branch...

https://<GITLAB_URL>/api/v4/projects/<PROJECT_ID>/repository/archive.zip?sha=<BRANCH_ID>

如何获取该分支内仅特定文件夹的ZIP存档?

How do I get a ZIP archive of only a specific folder within that branch?

您无法获取特定文件或文件夹的存档.

You can't get an archive for a specific file or folder.

但是您可以做一些类似的事情来帮助您:

But you can do something similar which might help you:

  • Get file from repository

列表存储库树

List repository tree