Check for file in repository

Hello,

i’m trying to develop a feature for Gitlab. So far i followed the guide and it worked well.
I created my route and controller. I can retrieve projects and list them in the view. Great! :slight_smile:

But now i want to check if a certain file exists in each of these projects
I have this here, but it seems to check for file contents:
Gitlab::Git::Blob.new(project, 'master').find('/composer.json')

How do i check if a file exists within a repository?

Thanks,

Cheers,
ochorocho

project.repository.ls _files('master').include? "composer.json"

Does the job. :slight_smile:

1 Like