Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
With atlassian falling apart and abandoning mercurial (the only reason to use bitbucket unless you're one of those anti-microsoft holdouts) you may find yourself looking to collect all your bitbucket repos to take elsewhere ... like ... github. This script is the first step. This is the first draft, only tested on mac running python 3.7 but shou…
from requests import get
from os import environ, getcwd, chdir, mkdir, system
from json import dumps
basedir = getcwd() + '/repos'
def grab_repos(repos):
for repo in repos:
print(">> grabbing >>", repo['slug'])
if repo['scm'] == 'hg':
print("cloning %s via hg" % repo['slug'])
system('hg clone ssh://' % (team, repo['slug']))
elif repo['scm'] == 'git':
print("cloning %s via git" % repo['slug'])
system('git clone --mirror' % (team, repo['slug']))
raise Exception("Unable to handle: " . dumps(repo))
repolist = []
next_page = '' % team
while next_page != None:
print(">> loading repo list from", next_page)
results = get(next_page, auth=(username, password)).json()
next_page = results.get('next', None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.