Skip to content

Instantly share code, notes, and snippets.

@invisiblek
Created February 9, 2017 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invisiblek/1b3dd8c0e34141ff8572bae3f88349dd to your computer and use it in GitHub Desktop.
Save invisiblek/1b3dd8c0e34141ff8572bae3f88349dd to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
targetBranches = ["cm-14.1", "cm-13.0", "cm-12.1", "cm-11.0"]
orgName = "LineageOS"
import os
import sys
from github import Github
e = os.environ.copy()
# Environment variables for github username and api token
u = e["GHUSER"]
p = e["GHTOKEN"]
org = Github(u, p).get_organization(orgName)
for repo in org.get_repos():
repobranches = repo.get_branches()
repodefaultbranch = repo.default_branch
for tb in targetBranches:
if tb in repobranches:
if repodefaultbranch != tb:
print("Changing default branch from " + repodefaultbranch + " to " + tb + " for " + repo.name)
# repo.edit(name=repo.name, default_branch=targetBranch)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment