Fix --tag argument usage

The argument is currently omited and validation is currently using
un-tagged governance projects list. This change adds the --tag
argument with the correct default value to check-new-candidacy too

Change-Id: I2a4a33f7c105365800d95055195c2584c1130575
This commit is contained in:
Tristan Cacqueray 2016-09-12 00:26:06 +00:00
parent 3df9d87474
commit 3e3e2e7868
3 changed files with 14 additions and 3 deletions

View File

@ -44,6 +44,7 @@ def main():
try:
found = check_candidacy.check_candidacy(review['change_id'],
tag=args.tag,
review=review)
except Exception as exc:
print("[E] %s\n\n" % (exc))

View File

@ -16,6 +16,7 @@ from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import sys
import check_candidacy
@ -27,7 +28,15 @@ def get_reviews():
(utils.ELECTION_REPO))
def check_reviews():
def main():
description = ('Check if the owner of open changes are valid candidates as'
' described in the change')
parser = argparse.ArgumentParser(description)
parser.add_argument('--tag', dest='tag', default=utils.PROJECTS_TAG,
help=('The governance tag to validate against. '
'Default: %(default)s'))
args = parser.parse_args()
for review in get_reviews():
if review['status'] != 'NEW':
continue
@ -42,6 +51,7 @@ def check_reviews():
owner = review.get('owner', {})
try:
found = check_candidacy.check_candidacy(review['change_id'],
tag=args.tag,
review=review)
except Exception as exc:
print("[E] %s\n\n" % (exc))
@ -56,4 +66,4 @@ def check_reviews():
if __name__ == "__main__":
sys.exit(check_reviews())
sys.exit(main())

View File

@ -23,7 +23,7 @@ import utils
# FIXME: Printing from library function isn't great.
# change API to return the messages and let the consumer decide what to
# do with them
def check_candidacy(change_id, limit=1, tag=None, review=None):
def check_candidacy(change_id, limit=1, tag=utils.PROJECTS_TAG, review=None):
def pretty_datetime(dt_str):
dt = datetime.datetime.strptime(dt_str.split('.')[0],
'%Y-%m-%d %H:%M:%S')