gitlabgitlab-api

How do I get all files (paths) of a specific commit from gitlab api?


I want to load the file contents from the gitlab api using a specific tag.

This can be achieved by using the blob for each file (https://docs.gitlab.com/ee/api/repository_files.html).

The problem I am facing is that I do not see the way to find out what file paths are available for a given commit (a tag in my case).

I am looking for something similar to github's tree object.

How do I get all the files and their respective paths with a given commit hash from the gitlab api to load their contents?

Thanks :)


Solution

  • You can get a list of repository files and directories in a project by calling this API:

    GET /projects/:id/repository/tree
    

    'Ref' parameter can be used to specify a commit by hash.

    The documentation describes multiple parameters but does not explicitly mention that commit hash can be used.