Skip to content

Instantly share code, notes, and snippets.

@nicoddemus
Created June 16, 2015 21:00
Show Gist options
  • Save nicoddemus/8a5656dcc5d0411ae6de to your computer and use it in GitHub Desktop.
Save nicoddemus/8a5656dcc5d0411ae6de to your computer and use it in GitHub Desktop.
Close bitbucket issues for pytest repository, after migrating to GitHub
import requests
auth = ('nicoddemus', 'XXXX')
for issue_id in xrange(1, 768+1):
url = 'https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues/{issue_id}/comments'
url = url.format(accountname='pytest-dev', repo_slug='pytest', issue_id=issue_id)
print '-' *10, issue_id
data = {
"content": "This issue has been moved to GitHub: https://github.com/pytest-dev/pytest/issues/{issue_id}".format(issue_id=issue_id),
}
respo = requests.post(url, data=data, auth=auth)
if respo.status_code != 200:
print respo.text
#print respo.json()
url = 'https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues/{issue_id}'
url = url.format(accountname='pytest-dev', repo_slug='pytest', issue_id=issue_id)
data = {
'status': 'on hold',
}
respo = requests.put(url, data=data, auth=auth)
if respo.status_code != 200:
print respo.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment