OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 | |
qyearsley
2016/01/26 18:08:01
No need for two blank lines before the imports
chrisphan
2016/02/10 02:23:38
Done.
| |
6 import bisect_utils | |
7 import source_control | |
8 | |
9 | |
10 def get(bisect_results, opts, depot_registry): | |
prasadv
2016/02/09 21:20:38
Method names areinconsistent with other modules
chrisphan
2016/02/10 02:23:38
What are you looking for here? get_bisect_results
qyearsley
2016/02/10 02:53:53
Function names in Chromium repo are CapitalCamelCa
| |
11 """Returns the results as a jsonable object.""" | |
12 if opts.bisect_mode == bisect_utils.BISECT_MODE_RETURN_CODE: | |
13 change = '0' | |
14 else: | |
15 metric = '/'.join(opts.metric) | |
16 change = '%.02f%%' % bisect_results.regression_size | |
17 | |
18 status = 'completed' | |
qyearsley
2016/01/26 18:08:01
Note: (As noted in another CL) previously "status"
chrisphan
2016/02/10 02:23:38
Added this check in CL/1566013002.
qyearsley
2016/02/10 02:53:53
SGTM
| |
19 | |
20 return { | |
21 'try_job_id': opts.try_job_id, | |
22 'bug_id': opts.bug_id, | |
23 'status': status, | |
24 'buildbot_log_url': '', # TODO(chrisphan) Get this. | |
prasadv
2016/02/09 21:20:38
Is it possible to use bot environmental variables
chrisphan
2016/02/10 02:23:38
Thanks for that. Done.
| |
25 'bisect_bot': '', # TODO(chrisphan): Get this. | |
26 'command': opts.command, | |
27 'metric': metric, | |
28 'change': change, | |
29 'score': bisect_results.confidence, | |
30 'good_revision': opts.good_revision, | |
31 'bad_revision': opts.bad_revision, | |
32 'warnings': bisect_results.warnings, | |
33 'abort_reason': bisect_results.abort_reason, | |
34 'culprit_data': _culprit_data(bisect_results), | |
35 'revision_data': _revision_data(bisect_results, depot_registry) | |
36 } | |
37 | |
38 | |
39 def _culprit_data(bisect_results): | |
40 if not bisect_results.culprit_revisions: | |
41 return None | |
42 cl, culprit_info, depot = bisect_results.culprit_revisions[0] | |
43 commit_link = _GetViewVCLinkFromDepotAndHash(cl, depot) | |
44 if commit_link: | |
45 commit_link = '\nLink : %s' % commit_link | |
46 else: | |
47 commit_link = ('\Description:\n%s' % culprit_info['body']) | |
48 | |
49 return { | |
50 'subject': culprit_info['subject'], | |
51 'author': culprit_info['email'], | |
52 'email': culprit_info['email'], | |
53 'cl_date': culprit_info['date'], | |
54 'commit_info': commit_link, | |
55 'revisions_links': [], | |
56 'cl': cl | |
57 } | |
58 | |
59 | |
60 def _revision_data(bisect_results, depot_registry): | |
qyearsley
2016/01/26 18:08:01
Method names here (in the chromium repo) are Camel
chrisphan
2016/02/10 02:23:38
Done.
| |
61 revision_rows = [] | |
62 for state in bisect_results.state.GetRevisionStates(): | |
63 commit_position = source_control.GetCommitPosition( | |
64 state.revision, depot_registry.GetDepotDir(state.depot)) | |
65 revision_rows.append({ | |
66 'depot_name': state.depot, | |
67 'deps_revision': state.revision, | |
68 'commit_pos': commit_position, | |
69 'result': 'good' if state.passed else 'bad', | |
70 }) | |
71 return revision_rows | |
72 | |
73 | |
74 def _GetViewVCLinkFromDepotAndHash(git_revision, depot): | |
75 """Gets link to the repository browser.""" | |
76 if depot and 'viewvc' in bisect_utils.DEPOT_DEPS_NAME[depot]: | |
77 return bisect_utils.DEPOT_DEPS_NAME[depot]['viewvc'] + git_revision | |
78 return '' | |
OLD | NEW |