feat: 将 commit gitea 地址添加到 issue 里 TUN-26 TUN-25 TUN-27
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f2cd178d42
commit
025ce562e4
12
app.py
12
app.py
@ -89,6 +89,17 @@ def gitea_push():
|
|||||||
logger.error('Failed to get completed state')
|
logger.error('Failed to get completed state')
|
||||||
return jsonify({'message': 'Failed to get completed state'}), 500
|
return jsonify({'message': 'Failed to get completed state'}), 500
|
||||||
|
|
||||||
|
def _attach_url_to_issue(issue_id, url, title=None):
|
||||||
|
data = {'query': 'mutation { attachmentLinkURL (title: "%s" url: "%s" issueId: "%s") { success } }' % (title, url, issue_id)}
|
||||||
|
resp = requests.post(LINEAR_API_URL, json=data, headers=headers)
|
||||||
|
if resp.status_code != 200:
|
||||||
|
logger.error('Failed to attach url to issue: %s' % resp.text)
|
||||||
|
return False
|
||||||
|
if not resp.json().get('data', {}).get('attachmentLinkURL', {}).get('success'):
|
||||||
|
logger.error('Failed to attach url to issue: %s' % resp.text)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
# check if the commit message contains a linear issue id like 'TUN-21'
|
# check if the commit message contains a linear issue id like 'TUN-21'
|
||||||
# if yes, update the issue state to completed
|
# if yes, update the issue state to completed
|
||||||
for commit in data['commits']:
|
for commit in data['commits']:
|
||||||
@ -104,6 +115,7 @@ def gitea_push():
|
|||||||
if not issue_data:
|
if not issue_data:
|
||||||
logger.error('Issue not found: %s' % issue_id)
|
logger.error('Issue not found: %s' % issue_id)
|
||||||
continue
|
continue
|
||||||
|
_attach_url_to_issue(issue_id, commit['url'], f'Gitea Commit: {commit["id"][:7]}')
|
||||||
issue_data = issue_data['issue']
|
issue_data = issue_data['issue']
|
||||||
if issue_data['state']['type'] == 'completed':
|
if issue_data['state']['type'] == 'completed':
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user