Merge "tools: Print UTC time of branch deletion"
This commit is contained in:
commit
77a2f385ce
@ -21,6 +21,7 @@ import getpass
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo_utils import timeutils
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
@ -38,17 +39,17 @@ def delete_branch(username, project_name, branch_id):
|
|||||||
f'branches/stable%2F{branch_id}')
|
f'branches/stable%2F{branch_id}')
|
||||||
response = requests.delete(url, auth=gerrit_auth)
|
response = requests.delete(url, auth=gerrit_auth)
|
||||||
if response.status_code == 204:
|
if response.status_code == 204:
|
||||||
print(f'Branch stable/{branch_id} successfully deleted '
|
print(f'{timeutils.utcnow()} | Branch stable/{branch_id} successfully deleted '
|
||||||
f'from {project_name}!')
|
f'from {project_name}!')
|
||||||
return 0
|
return 0
|
||||||
elif response.status_code == 401:
|
elif response.status_code == 401:
|
||||||
print('401 Unauthorized.')
|
print(f'{timeutils.utcnow()} | 401 Unauthorized.')
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
# NOTE(elod.illes): other possible errors from gerrit:
|
# NOTE(elod.illes): other possible errors from gerrit:
|
||||||
# 404: In case of project or branch is not found
|
# 404: In case of project or branch is not found
|
||||||
# 409: Branch has open changes
|
# 409: Branch has open changes
|
||||||
print(f'Delete failed ({response.status_code}): {response.text}')
|
print(f'{timeutils.utcnow()} | Delete failed ({response.status_code}): {response.text}')
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user