Get list of repositories using gitweb for external use

471 views Asked by At

To be used in another external script, we need the list of repositories hosted in a git repository server. We have GitWeb also enabled on the server.

Any one know if GitWeb exposes some API through which we can get the list of repositories ? Like GitBlit RPC (http://gitblit.com/rpc.html like https://your.glitblit.url/rpc?req=LIST_REPOSITORIES) ?

Thanks.

2

There are 2 answers

0
VonC On

No, from what I can see of the gitweb.cgi (from gitweb/gitweb.perl) implementation, there is no RPC API with JSON return messages.

This is only visible through the web page.

0
tuxillo On

In the bottom right corner there is a small button that reads: TXT You can get the list of projects there, for example:

For sourceware, the gitweb page: https://sourceware.org/git/

The TXT button links here: https://sourceware.org/git/?a=project_index

It should return a list of projects which are basically

<name of the git repository> <owner>

in plain text, perfectly parseable by script.

But if you want JSON, you'd have to convert it with something like this:

$ wget -q -O- "https://sourceware.org/git/?a=project_index" \
    | jq -R -n '[ inputs | split(" ")[0:2] | {"project": .[0], "owner": .[1]} ]'