git-cl: Report git push information to metrics collection.

Bug: 897394
Change-Id: I52a31bb4840b5de89b96545a3e7544c6708f148f
Reviewed-on: https://chromium-review.googlesource.com/c/1312240
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
Edward Lemur
2018-11-01 23:14:14 +00:00
committed by Commit Bot
parent 8f8a50d00a
commit fec80c4135
3 changed files with 56 additions and 2 deletions

View File

@@ -142,6 +142,23 @@ GIT_VERSION_RE = re.compile(
r'git version (\d)\.(\d{0,2})\.(\d{0,2})'
)
KNOWN_SUBCOMMAND_ARGS = {
'cc',
'hashtag',
'l=Auto-Submit+1',
'l=Commit-Queue+1',
'l=Commit-Queue+2',
'label',
'm',
'notify=ALL',
'notify=NONE',
'private',
'r',
'ready',
'topic',
'wip'
}
def get_python_version():
"""Return the python version in the major.minor.micro format."""
@@ -178,6 +195,19 @@ def seconds_to_weeks(duration):
return int(duration) >> 19
def extract_known_subcommand_args(args):
"""Extract the known arguments from the passed list of args."""
known_args = []
for arg in args:
if arg in KNOWN_SUBCOMMAND_ARGS:
known_args.append(arg)
else:
arg = arg.split('=')[0]
if arg in KNOWN_SUBCOMMAND_ARGS:
known_args.append(arg)
return known_args
def extract_http_metrics(request_uri, method, status, response_time):
"""Extract metrics from the request URI.