libgit2 / rugged

ruby bindings to libgit2
MIT License
2.25k stars 277 forks source link

Read files from remote repository without cloning #940

Closed abitrolly closed 2 years ago

abitrolly commented 2 years ago

Is it possible to list remote repository files without cloning the whole repo?

I am trying to add support to checking license of remote GitLab repos to https://github.com/licensee/licensee And I can't see how to replace Rugged::Repository.new(path) with something that looks up remote files.

https://github.com/licensee/licensee/blob/16b2bf8e2fab709bec87d3ea84650e6b8c4410d0/lib/licensee/projects/git_project.rb#L33

I found this StackOverflow question https://stackoverflow.com/questions/1178389/browse-and-display-files-in-a-git-repo-without-cloning Maybe it is possible to emulate this technique https://stackoverflow.com/a/65464092 without creating files on disk?

carlosmn commented 2 years ago

Git works on local data. The one exception is fetching data from a remote or pushing data to a remote. If you want to access a Git repository remotely then you'll need to consult your hoster's API reference.

abitrolly commented 2 years ago

The one exception is fetching data from a remote

That's fine with me. Fetch list of files and then some contents. Just don't save anything to disk.

carlosmn commented 2 years ago

That's not how Git works. A fetching data means the equivalent of git fetch. There is no network-based arbitrary data access like what you are describing. For that you'd need the API of whoever is hosting the repositories.