As an alternative to the proposed patch by Daniel (or maybe in addition to it), we at Planio have already rolled out a read-only API for repositories related to #11977 which we provide in the attached patch. Unfortunately, we haven't managed to provide the patch earlier :(
You can call the API as http://redmine.example.com/repositories.json. It supports the following optional parameters:
scm: The type of repositories that should be shown. We support any of the registered repository types here. If no scm is given or the type is unknown, we show all repositories visible to the current user.
include: fetch associated data (optional, use comma to fetch multiple associations). Possible values:
branches: Include known branches of the repository. This is only useful if the repository type knows the concept of branches like git or mercurial.
In the API response, we deliberately do not include the repository URL that is configured in Redmine. The reason for that is that most of the time, this URL won't be the one visible to clients. Instead, this is often a file system path (mandatory for at least git and mercurial) or an internal URL in the case of SVN. Instead, we offer an extension point for repository hosting plugins to easily add information they deem useful. This data can be fetched from the respective configuration of the plugin. Alternatively, an administrator setting up their internal Redmine with tools like Redmine.pm can easily write a very simple plugin which hooks into the API to provide this information. This could look like this:
Redmine::Plugin.register:redmine_my_repositoriesdoname'My Repositories'author'John Doe'description'Add custom repository information to the API'version'1.0.0'endmoduleMyRepositoriesclassApiHooks<Redmine::Hook::Listenerdefapi_repositories_index(context)render_repository_urls(context[:api],context[:repository])endprivatedefrender_repository_urls(api,repository)ifrepository.is_a?Repository::Subversionapi.svn_url"https://#{Setting.hostname}/svn/#{[repository.project.identifier,repository.identifier].compact.join('/')}
elsif repository.is_a? Repository::Git
api.git_url "git@#{Setting.hostname}:#{[repository.project.identifier, repository.identifier].compact.join('/')}endendendend
If you intend to use both patches, the supplied data should be adapted so that both APIs provide similar data.
As an alternative to the proposed patch by Daniel (or maybe in addition to it), we at Planio have already rolled out a read-only API for repositories related to #11977 which we provide in the attached patch. Unfortunately, we haven't managed to provide the patch earlier :(
Thanks, that's part of what I wanted to do, I'll include your patch in a branch of my Git and extend it to be a simple CRUD.
In the API response, we deliberately do not include the repository URL that is configured in Redmine. The reason for that is that most of the time, this URL won't be the one visible to clients. Instead, this is often a file system path (mandatory for at least git and mercurial) or an internal URL in the case of SVN. Instead, we offer an extension point for repository hosting plugins to easily add information they deem useful. This data can be fetched from the respective configuration of the plugin. Alternatively, an administrator setting up their internal Redmine with tools like Redmine.pm can easily write a very simple plugin which hooks into the API to provide this information. This could look like this:
[...]
If you intend to use both patches, the supplied data should be adapted so that both APIs provide similar data.
I agree, the :url is not very useful, I'm wondering about using it for a list of clone URLs but not all SCM support it.
Given that you meant to write #35769: that's another feature not (directly) related to this one. This one is about adding repository information to the projects endpoint and to a proposed repositories endpoint, where yours is about adding related issues information to a newly proposed revision endpoint.
Setting this as a candidate for the next major version.
Could you update the patch for the latest trunk?
Go, I think it would be good to discuss first what actually needs to be integrated before we go any further. I.e. do you also think about adding what's proposed/patched/posted in note-1 by Daniel Dehennin, or not? Besides that, we should make sure that any API addition is documented with some basic test coverage at least.