Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 43,125
    • Issues 43,125
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,422
    • Merge requests 1,422
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #28827
Closed
Open
Created May 20, 2019 by Daniel Possenriede@dpprdan

Download a (sub-)folder from a repository via the Repositories API

Problem to solve

Via the Repositories API it's currently only possible to download the entire repository as a zip file. In some situations, however, it may be desirable to download just a portion (folder) of the repository as a zip file.

gitlab-ce#24704 raised a similar feature request for the Gitlab UI, which was inplemented with MRs gitlab-ce!26532 and gitlab-ce!27275.

Intended users

Developers and other API users (e.g. installing a package from source).

Further details

At the very least, it keeps the functionality of the UI and the API in sync.

Proposal

If I understand the logic behind the Repositories API correctly, GET /projects/:id/repository/archive[.format] would have to support a path parameter for this. If the path parameter is empty or not given, archive[.format] contains the whole repo.

Permissions and Security

Permissions should be the same as with the Repositories API, (or the Repository files API, which has the read_repository scope, which the Repositories API has not, see #28324).

Documentation

Add path parameter to Get file archive.

Update: @porsager suggested to support multiple paths (repo sub-folders) below. I would leave it to the one implementing this feature to decide whether this is desirable/doable. Maybe it is best to start out with a single path/folder?

Testing

I don't know, but I would expect similar tests as for the existing Get file archive functionality.

What does success look like, and how can we measure that?

It is possible to get a file archive with only the contents of a (sub-)folder of the repository via the API.

Links / references

Following up on @patrickbajao's suggestion, /cc-ing @DouweM @jramsay like he did.

Edited Jan 05, 2021 by Daniel Possenriede
Assignee
Assign to
Time tracking