bisect-kit: output candidates information in json
diagnose_cros_autotest.py and bisectors can use 'view --json' subcommand
to dump candidates information in machine readable format.
BUG=b:117860228
TEST=unittest; run diagnose_cros_autotest.py end-to-end test manually
Change-Id: Iafcfc79f6331575b5cbca2fb0e98ac1d577a1b46
Reviewed-on: https://chromium-review.googlesource.com/1337352
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
diff --git a/bisect_git.py b/bisect_git.py
index 4846dc8..85710fe 100755
--- a/bisect_git.py
+++ b/bisect_git.py
@@ -13,12 +13,16 @@
"""
from __future__ import print_function
+import logging
+import subprocess
from bisect_kit import cli
from bisect_kit import core
from bisect_kit import errors
from bisect_kit import git_util
+logger = logging.getLogger(__name__)
+
class GitDomain(core.BisectDomain):
"""BisectDomain for git revisions."""
@@ -53,8 +57,23 @@
env['GIT_REPO'] = self.config['git_repo']
env['GIT_REV'] = rev
- def view(self, revlist, old, new):
- print('git log %s..%s' % (old, new))
+ def fill_candidate_summary(self, summary, interesting_indexes):
+ for i in interesting_indexes:
+ rev_info = summary['rev_info'][i]
+ rev = rev_info['rev']
+ try:
+ commit_summary = git_util.get_commit_log(self.config['git_repo'],
+ rev).splitlines()[0]
+ except subprocess.CalledProcessError:
+ logger.warning('failed to get commit log of %s at %s', rev[:10],
+ self.config['git_repo'])
+ commit_summary = '(unknown)'
+ text = 'commit %s %r' % (rev[:10], commit_summary)
+ rev_info.update({
+ 'actions': [{
+ 'text': text,
+ }],
+ })
if __name__ == '__main__':