Skip to content

Instantly share code, notes, and snippets.

@sbesson
Created June 13, 2019 09:41
Show Gist options
  • Save sbesson/fc62c7c1a6de5f1234c6d93dfb738d9a to your computer and use it in GitHub Desktop.
Save sbesson/fc62c7c1a6de5f1234c6d93dfb738d9a to your computer and use it in GitHub Desktop.
Remove obsolete integration branches
#! /usr/bin/env python
# Remove obsolete integration branches
import scc.git
import sys
# Login and check the organization
gh = scc.git.get_github(scc.git.get_token())
print "Authenticated as %s" % gh.get_user().login
branch = sys.argv[1]
refname = 'heads/%s' % branch
for repo in gh.get_user().get_repos():
try:
ref = repo.get_git_ref(refname)
except Exception, e:
ref = None
if ref is not None:
print "Deleting %s from %s" % (branch, repo.name)
ref.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment