Commit cd3696cf authored by Nicolas Boichat's avatar Nicolas Boichat Committed by LUCI CQ

my_activity: Add config file option to add additional gerrit instances

my_activity can definitely be useful outside of Chromium, and the
gerrit instances are sometimes private. This allows users to carry
an additional list of instances in a json file (and possibly
monorail projects, but that seems like likely to be useful).

Change-Id: Ic0fec3bd4f815200f27cc0a8530cfd88f4328269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2925677
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: 's avatarDirk Pranke <dpranke@google.com>
parent 30cde45e
......@@ -12,6 +12,18 @@ Example:
- my_activity.py -b 4/24/19 for stats since April 24th 2019.
- my_activity.py -b 4/24/19 -e 6/16/19 stats between April 24th and June 16th.
- my_activity.py -jd to output stats for the week to json with deltas data.
To add additional gerrit instances, one can pass a JSON file as parameter:
- my_activity.py -F config.json
{
"gerrit_instances": {
"team-internal-review.googlesource.com": {
"shorturl": "go/teamcl",
"short_url_protocol": "http"
},
"team-external-review.googlesource.com": {}
}
}
"""
# These services typically only provide a created time and a last modified time
......@@ -745,6 +757,10 @@ def main():
help='Skips listing own issues without changes when showing changes '
'grouped by referenced issue(s). See --changes-by-issue for more '
'details.')
parser.add_option(
'-F', '--config_file', metavar='<config_file>',
help='Configuration file in JSON format, used to add additional gerrit '
'instances (see source code for an example).')
activity_types_group = optparse.OptionGroup(parser, 'Activity Types',
'By default, all activity will be looked up and '
......@@ -900,6 +916,22 @@ def main():
logging.info('Searching for activity by %s', options.user)
logging.info('Using range %s to %s', options.begin, options.end)
if options.config_file:
with open(options.config_file) as f:
config = json.load(f)
for item, entries in config.items():
if item == 'gerrit_instances':
for repo, dic in entries.items():
# Use property name as URL
dic['url'] = repo
gerrit_instances.append(dic)
elif item == 'monorail_projects':
monorail_projects.append(entries)
else:
logging.error('Invalid entry in config file.')
return 1
my_activity = MyActivity(options)
my_activity.show_progress('Loading data')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment