Retrieve directory structure in Gerrit using REST API

686 views
Skip to first unread message

Asish kumar

unread,
Feb 1, 2018, 2:31:03 AM2/1/18
to Repo and Gerrit Discussion
How do i retrieve directory structure for a particular project in Gerrit using REST API or 
Is there any way to retrieve folders and files in a particular branch of a project in  gerrit.

According to gerrit documentation https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html this query "/projects/{project-name}/branches/{branch-id}/files" should retrieve all the files and folders in a particular branch but it is throwing site can’t be reached error. 

Can any gerrit expert help me out with this.

Thanks in advance

Matthew Webber

unread,
Feb 1, 2018, 5:32:43 AM2/1/18
to Repo and Gerrit Discussion
Can I suggest that for questions like this, you let us know what Gerrit version you are running, and also show us the exact command you are issuing, and the exact error message.

If I understand the documentation correctly, you can retrieve the contents of a specific file (if you know the path to it), but there is no facility to get a list of files.

This worked for me:
  • The project name (gda/gda-core) has a slash in it, which needs to be encoded as %2F
  • Ditto for the file path
  • This project can be read anonymously - otherwise, the URL needs to reference the authenticated endpoint (https://gerrit.server/a/).
  • The result returned is base64 encoded.
Is there a reason not to just clone the repo and inspect the local copy?


Asish kumar

unread,
Feb 1, 2018, 2:18:00 PM2/1/18
to Repo and Gerrit Discussion
Thanks for the reply
IAM actually trying to make a report of all the files that exist in all the projects.so I just need the names of folders and files in each project and cloning all the projects is not feasible.

Koushik Ghosh

unread,
Mar 2, 2019, 12:01:41 AM3/2/19
to Repo and Gerrit Discussion
Asish, did you find a way? I have same requirement to list files in a directory via gerrit REST.

Dinesh Prakash

unread,
May 31, 2022, 6:12:23 AM5/31/22
to Repo and Gerrit Discussion
Did anyone got resolution for the above query?
Reply all
Reply to author
Forward
0 new messages