{"id":18019143,"url":"https://github.com/floe/github-bulk-editor","last_synced_at":"2025-03-26T20:31:17.766Z","repository":{"id":45722131,"uuid":"169378213","full_name":"floe/github-bulk-editor","owner":"floe","description":"Allows bulk editing of Github repositories","archived":false,"fork":false,"pushed_at":"2022-06-17T08:11:47.000Z","size":78,"stargazers_count":38,"open_issues_count":0,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T10:24:26.657Z","etag":null,"topics":["github","github-api","github-api-v3","gtk","gtk3","json","python","python3","requests"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-06T08:59:55.000Z","updated_at":"2024-09-16T20:06:08.000Z","dependencies_parsed_at":"2022-09-11T15:30:16.975Z","dependency_job_id":null,"html_url":"https://github.com/floe/github-bulk-editor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floe%2Fgithub-bulk-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floe%2Fgithub-bulk-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floe%2Fgithub-bulk-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floe%2Fgithub-bulk-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floe","download_url":"https://codeload.github.com/floe/github-bulk-editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245731376,"owners_count":20663162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-api","github-api-v3","gtk","gtk3","json","python","python3","requests"],"created_at":"2024-10-30T05:09:15.585Z","updated_at":"2025-03-26T20:31:17.423Z","avatar_url":"https://github.com/floe.png","language":"Python","readme":"# github-bulk-editor\n\nI needed to transfer a large bunch of repositories from one organization to another one. I had already found https://github.com/ahmadnassri/github-bulk-transfer, but that looked quite brittle, and I am honestly not a big fan of node.js projects anyway (*cough* left-pad *cough*).\n\nSo I put this tool together over the course of a couple of evenings, which allows you to:\n\n  - fetch a list of items from the Github API - currently supported:\n    - all repos the current user has permission for\n    - all teams in an organization\n    - all members of an organization\n  - and execute an API command for a selected subset of the items - currently supported:\n    - transfer repos to another organization\n    - remove teams\n    - remove members\n\n![Screenshot](https://github.com/floe/github-bulk-editor/raw/master/github-bulk-editor.png \"Screenshot\")\n\nTo use it, you need to add your own account and access token from https://github.com/settings/tokens in line 10 (https://github.com/floe/github-bulk-editor/blob/master/github-bulk-editor.py#L10).\n  \nCurrently, the only well-tested actions are a) fetching a list of repos you have access to, and b) transferring those repos to another user/org, because that is the functionality I needed right now.\n\nHowever, I've tried to keep the internals as generic as possible (see https://github.com/floe/github-bulk-editor/blob/master/github-bulk-editor.py#L14-L27):\n\n```python\n# command title: [ GET url, JSON field to extract from result ]\nfetch_cmds = { \n    \"Get all repositories\": [ \"https://api.github.com/user/repos\", \"full_name\"],\n    \"Get all teams\": [ \"https://api.github.com/orgs/mmbuw/teams\", \"slug\" ], # TODO: make org name editable\n    \"Get all members\": [ \"https://api.github.com/orgs/mmbuw/members\", \"login\" ], # TODO: make org name editable\n}\n\n# command title: [ request function, url, parameters ] (will be passed through format(name,id), hence the double braces)\naction_cmds = {\n    \"Transfer repository\": [ \"github_post\", \"https://api.github.com/repos/{0}/transfer\", '{{ \"new_owner\": \"{0}\", \"team_ids\": [] }}' ],\n    \"Delete team\": [ \"github_delete\", \"https://api.github.com/teams/{1}\", \"\" ],\n    \"Remove member\": [ \"github_delete\", \"https://api.github.com/orgs/mmbuw/members/{0}\", \"\" ], # TODO: fixed org name\n}\n\n# ...\n\n# post a payload to url\ndef github_post(url,payload):\n    r = requests.post(url,auth=cred,headers=headers,data=payload,allow_redirects=True)\n    return r\n```\n\nIn theory, you should be able to just add new entries to `fetch_cmds` and `action_cmds` to support new API calls, and perhaps add something like another `github_put` (or whatever) function.\n\nP.S. If you're wondering why I used `requests` + `json` (as also suggested at https://stackoverflow.com/a/10626326/838719) instead of `PyGithub` or similar, none of the existing Python libraries actually support the \"Transfer Repo\" command. Duh.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloe%2Fgithub-bulk-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloe%2Fgithub-bulk-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloe%2Fgithub-bulk-editor/lists"}