The Github API docs for teams are nicely complete, with good teaching examples, but lack really explicit, cut & paste examples: a little too "pseudo code" for something I use only sporadically. Recently I needed to add a bunch of repositories to a team in an organization. The web interface only allows one-at-a-time. What a pain for adding more than 40 repos. (We can talk about repo organization at another time. Trust me on that.) So, enough perusing of the docs eventually leads to: From which we see we need a team id, an owner (of what? The repo) and the repo itself.We get the team id from here: curl -s -i -u $GITCREDS https://api.github.com/orgs/Rhaptos/teams The repos are owned by the organization, so we can use that name directly. Putting that together, (after one round of errors from the nginx proxy server, complaining about 'Length Required') we get: curl -s -i -u $GITCREDS -X PUT -H 'Content-Length:0' https://api.github.com/teams/12345/Rhaptos/Products.CatalogMemberDataTool Check the github Organization homepage, and lo and behold, there it is! So, since we have a convenient checkout of all the required repos in src: for r in *; do curl -s -i -u $GITCREDS -X PUT -H 'Content-Length:0' https://api.github.com/teams/12345/repos/Rhaptos/$r ; done Bam! 41 Repos in one team. Easy enough for this bash jockey. |
Ross's Musings >