[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Question about Salsa API: How to get all projects (including in subgroups) of a team



Am Samstag, den 10.02.2018, 18:56 +0100 schrieb Andreas Tille:
> Hi,
> 
> I think I have seen the answer to my question here before but I
> failed
> finding it:  I want to read the certain files of the debian/ dir of
> all
> projects of a team (including subgroups).  So how can I get the names
> (and subdirs!) of all packaging projects of Debian Science?

https://salsa.debian.org/help/api/groups.md

curl --request GET \
     --header "PRIVATE-TOKEN: <token>" \
     --data "simple=true" -s \
     https://salsa.debian.org/api/v4/groups/science-team/projects | \
     jq -r '.[].name'

For a sub-group you probably need the url-encoded group/subgroup path
(untested):

https://salsa.debian.org/api/v4/groups/<group>%2F<subgroup>/projects

I don't know, how to include all packages of all sub-groups too. But
you could use the API and retrieve all sub-groups of a group

curl --request GET --header "PRIVATE-TOKEN: <token>" -s \
     https://salsa.debian.orgpi/v4/groups/science-team/subgroups

and repeat the above request. Then merge all results. 

> Bonus question:  How can I get debian/changelog, debian/control and
> debian/upstream/metadata without cloning the whole repository?

You can use the API too:
https://salsa.debian.org/help/api/repository_files.md

Given, that you received the list of projects as shown above, you can
loop over this list and use this (example uses the togl project in
science-team group and debian/changelog from master - token is not
necessary for publicly available files):

curl --request GET --header "PRIVATE-TOKEN: <token>" \
     https://salsa.debian.org/api/v4/projects/science-team%2Ftogl/repository/files/debian%2Fchangelog/raw?ref=master

Note, that both project (usually 'team/project') and file (here
'debian/changelog') need to be URL-encoded.

You can use the same API and method 'PUT' to update the file on the
repository. You maybe have to encode the file content via base64. I
haven't tested it yet. The call probably looks like this:

curl --request PUT --header "PRIVATE-TOKEN: <token>" \
     --data
'...content=<base64 encoded>...author=...'
     https://salsa.debian.org/api/v4/projects/science-team%2Ftogl/repository/files/debian%2Fchangelog/raw?ref=master

This should be simple in bash. In Perl I found, that it is easier to
use HTTP::Request and the JSON interface instead of URL-encoded forms.

HTH and regards, Daniel

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: