Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bitbucket issue migration between repos
import requests
import json
from requests.auth import HTTPBasicAuth
account_name = 'MY_NICKNAME'
password = 'PASSWORD'
old_repo = 'OLD_REPO'
new_repo = 'NEW_REPO'
old_url = 'https://api.bitbucket.org/1.0/repositories/{0}/{1}/issues/?limit=50'.format(account_name, old_repo)
new_url = 'https://api.bitbucket.org/1.0/repositories/{0}/{1}/issues/'.format(account_name, new_repo)
auth = HTTPBasicAuth(account_name, password)
# Getting old issues
result = []
start = 0
count = 1
while True:
if start > count:
break
r = requests.get(old_url+'&start={0}'.format(start), auth=auth)
content = json.loads(r.content)
count = content['count']
result.extend(content['issues'])
start += 50
# converting to payload
new_res = dict([(x['local_id'], {'title':x['title'],'content':x['content'],'status':x['status'],'priority':x['priority'],'kind':x['metadata']['kind']}) for x in result])
for data in new_res.values():
requests.post(new_url, data=data, auth=auth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.