Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search filenames with GitLab API

Tags:

gitlab

I'm using the GitLab API (http://doc.gitlab.com/ce/api/) to try to search for a specific file. I can successfully access a specific repository, but I was hoping to provide some text and retrieve any files that match the filename. If not that, then to at least get the full file structure of everything within the repository and do the search myself. Is this possible?

like image 994
TJ Smith Avatar asked Oct 20 '22 03:10

TJ Smith


1 Answers

http://doc.gitlab.com/ce/api/repositories.html

I didnt skim through the full API docs, but a quick hack would be to list down the trees, you will get Gitlab ObjectifiedHash, run a loop and inside the loop put a condition saying if the type is a 'tree', then send its respective id again to fetch its tree and so on recursively and if its a blob, just save the name.

This way you get all the files/folder name. This is a bad way of doing it since you will do quite a few api calls. Read through the API docs fully.

I know this post is old, just answered anyway. Hope it helped

like image 106
druuu Avatar answered Dec 30 '22 20:12

druuu