Le mardi 13 février 2018 à 09:45:43+0100, Guido Günther a écrit : > Hi, > On Mon, Feb 12, 2018 at 06:10:09PM +0100, Pierre-Elliott Bécue wrote: > > Speaking to the gitlab API is actually quite simple. > > > > The user has to create his own private token with API access. Then gbp > > would require a new config parameter to fetch such a token from the > > .gitconfig of the user, or a new option to the create-remote-repo command to > > provide it. > > > > Then, if the user wants to create the repo in a specific namespace (group, > > subgroup, whatever), he has to fetch the appropriate namespace_id. I didn't > > find a basic method so far, but some urls contain it, so I found 2781 for > > DPMT subgroup. > > > > Then, it's only about designing a POST request: > > > > I made a simple json file: temp/test.json > > { > > "name": "apiproject", > > "namespace_id": 2781 > > } > > > > Then, I ran > > > > # curl -X "POST" -H 'Private-Token: {{priv_token}}' -H "Content-Type: > > application/json; charset=utf-8" https://salsa.debian.org/api/v4/projects > > -d "$(cat temp/test.json)" > > > > { > > "id":12590, > > "description":null, > > "name":"apiproject", > > "name_with_namespace":"Debian Python Team / DPMT / apiproject", > > "path":"apiproject", > > "path_with_namespace":"python-team/modules/apiproject", > > "created_at":"2018-02-12T16:54:58.691Z", > > "default_branch":null, > > "tag_list":[], > > > > "ssh_url_to_repo":"g...@salsa.debian.org:python-team/modules/apiproject.git", > > > > "http_url_to_repo":"https://salsa.debian.org/python-team/modules/apiproject.git", > > "web_url":"https://salsa.debian.org/python-team/modules/apiproject", > > "avatar_url":null, > > "star_count":0, > > "forks_count":0, > > "last_activity_at":"2018-02-12T16:54:58.691Z", > > "_links":{ > > "self":"http://salsa.debian.org/api/v4/projects/12590", > > > > "merge_requests":"http://salsa.debian.org/api/v4/projects/12590/merge_requests", > > > > "repo_branches":"http://salsa.debian.org/api/v4/projects/12590/repository/branches", > > "labels":"http://salsa.debian.org/api/v4/projects/12590/labels", > > "events":"http://salsa.debian.org/api/v4/projects/12590/events", > > "members":"http://salsa.debian.org/api/v4/projects/12590/members" > > }, > > "archived":false, > > "visibility":"private", > > "resolve_outdated_diff_discussions":false, > > "container_registry_enabled":true, > > "issues_enabled":false, > > "merge_requests_enabled":true, > > "wiki_enabled":true, > > "jobs_enabled":true, > > "snippets_enabled":true, > > "shared_runners_enabled":true, > > "lfs_enabled":true, > > "creator_id":1983, > > "namespace":{ > > "id":2781, > > "name":"DPMT", > > "path":"modules", > > "kind":"group", > > "full_path":"python-team/modules", > > "parent_id":2779 > > }, > > "import_status":"none", > > "import_error":null, > > "runners_token":"such_token_much_wow", > > "public_jobs":true, > > "ci_config_path":null, > > "shared_with_groups":[], > > "only_allow_merge_if_pipeline_succeeds":false, > > "request_access_enabled":false, > > "only_allow_merge_if_all_discussions_are_resolved":false, > > "printing_merge_request_link_enabled":true > > } > > > > So, there are some parameters that'd require a default: > > > > I suggest this template json for creating a remote repo: > > > > { > > "name": "%(name)s", > > "namespace_id": %(namespace_id)d (if provided), > > "issues_enabled": true, > > "visibility": "public", > > "only_allow_merge_if_all_discussions_are_resolved": true > > } > > we can leave most of these out since they're not required: > > https://docs.gitlab.com/ce/api/projects.html#create-project
Yes, but the defaults seem awkward to me for Debian git repositories, hence the suggestion to set them. The only required intel is actually the project's name. > > Python has plenty json api packages to send such json, so it's a matter of > > implementation. > > We already use requests for http so this can be used to simplify things > furhter. There's also python3-gitlab. Should we try to rely on p3-gitlab or to stick with requests? > > I could take some time to code that, but I'd rather we agree on the "how" > > and the "what" before spending any time in such work. > > Would be great. Especially since we'd need some logic to figure out if > the remote end is using gitlab. For the moment we could just do: > > --remote-type=git+ssh (old behaviour) > --remote-type=gitlab (what you just describe) > --remote-type=auto > > The last option could just look into a fixed list within create_repo > > gitlab_hosts = ['salsa.debian.org'] > > to figure out what to do. Could you help me confirming what are the different steps supposed to be handled by create-remote-repo? I assume it's roughly these: 1. Find the url and determine the configurations, in particular, check if such a remote doesn't alreaty exist in the .git/config file. 2. Create the actual remote repo 3. Update the local git config with this remote. 4. Push to this new remote. Am I right? -- Pierre-Elliott Bécue GPG: 9AE0 4D98 6400 E3B6 7528 F493 0D44 2664 1949 74E2