0
私はプルリクエストを閉じるためにPythonスクリプトで作業していますが、私はリクエストを適切にフォーマットできないようです...誰かが私がここで間違っていることを教えてくれますか?python githubクリーンアップ
for repo in g.get_user().get_repos():
print (repo.full_name)
json_pulls = requests.get(base_url + repo.full_name + '/pulls?state=open+updated>=' + str(cutoff_date.date())+ '&sort=created&order=asc')
if (json_pulls.ok):
for item in json_pulls.json():
print('Name: ' + item['title'])
print('Number: ' + str(item['number']))
print('State: ' + item['state'])
print('Last Updated: ' + str(item['updated_at']))
print('Last Merged : ' + str(item['merged_at']))
print (' ')
pull_num = str(item['number'])
merged_date = item['merged_at']
if isinstance(merged_date, datetime) and (merged_date < cutoff_date):
print('Pull Request recently merged.... Skipping... ')
print(' ')
print(' ')
else:
print('Action: Close pull request: ' + pull_num)
print(' ')
print(' ')
head = {"Authorization": "Token token=" + OAUTH_KEY}
payload = {
"state": "closed"
}
r = requests.patch(base_url + repo.full_name + '/pulls/' + pull_num, head, json=payload)
print(r.json())
出力:助けを
Name: Issue01
Number: 1
State: open
Last Updated: 2017-04-18T14:21:31Z
Last Merged : None
Action: Close pull request: 1
{'message': 'Not Found', 'documentation_url': 'https://developer.github.com/v3/pulls/#update-a-pull-request'}
ありがとう!