GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - floe/github-bulk-editor: Allows bulk editing of Github repositories

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
github-bulk-editor.png
github-bulk-editor.png
 
 
github-bulk-editor.py
github-bulk-editor.py
 
 

Repository files navigation

github-bulk-editor

I 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).

So I put this tool together over the course of a couple of evenings, which allows you to:

  • fetch a list of items from the Github API - currently supported:
    • all repos the current user has permission for
    • all teams in an organization
    • all members of an organization
  • and execute an API command for a selected subset of the items - currently supported:
    • transfer repos to another organization
    • remove teams
    • remove members

Screenshot

To 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).

Currently, 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.

However, 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):

# command title: [ GET url, JSON field to extract from result ]
fetch_cmds = { 
    "Get all repositories": [ "https://api.github.com/user/repos", "full_name"],
    "Get all teams": [ "https://api.github.com/orgs/mmbuw/teams", "slug" ], # TODO: make org name editable
    "Get all members": [ "https://api.github.com/orgs/mmbuw/members", "login" ], # TODO: make org name editable
}

# command title: [ request function, url, parameters ] (will be passed through format(name,id), hence the double braces)
action_cmds = {
    "Transfer repository": [ "github_post", "https://api.github.com/repos/{0}/transfer", '{{ "new_owner": "{0}", "team_ids": [] }}' ],
    "Delete team": [ "github_delete", "https://api.github.com/teams/{1}", "" ],
    "Remove member": [ "github_delete", "https://api.github.com/orgs/mmbuw/members/{0}", "" ], # TODO: fixed org name
}

# ...

# post a payload to url
def github_post(url,payload):
    r = requests.post(url,auth=cred,headers=headers,data=payload,allow_redirects=True)
    return r

In 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.

P.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.

About

Allows bulk editing of Github repositories

Topics

githubgithub-apigithub-api-v3gtkgtk3jsonpythonpython3requests

Resources

Readme
GPL-3.0 license
Activity

Stars

40 stars

Watchers

0 watching

Forks

16 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.