bisect-kit: Improve strategy to get actions between branched CROS specs
When `prev_spec` and `next_spec` not on the same branch, we should
follow the branch stated in `next_spec` instead of `prev_spec` to
build the action list.
BUG=b:147575652
TEST=python3 -m unittest bisect_kit/cros_util_test.py
TEST=python3 -m unittest bisect_kit/git_util_test.py
TEST=./bisect_cr_localbuild_internal.py init --old 81.0.3995.0 --new 81.0.3999.0
TEST=./bisect_cros_version.py init --board samus-kernelnext --old R80-12739.10.0 --new R80-12739.11.0
TEST=./bisect_cros_repo.py init --board samus-kernelnext --old R80-12739.0.0 --new R80-12739.1.0
TEST=./bisect_cros_repo.py init --board samus-kernelnext --old R80-12739.10.0 --new R80-12739.11.0
TEST=./bisect_cros_repo.py init --board samus-kernelnext --old R80-12739.0.0 --new R80-12739.11.0
TEST=./bisect_cros_repo.py init --board samus-kernelnext --old R80-12730.0.0 --new R80-12739.0.0
TEST=./bisect_cros_repo.py init --board samus-kernelnext --old R80-12738.0.0-24800 --new R80-12739.11.0
Change-Id: I055527df79903c7ddc879024f2c9bf1dc8fa42b5
diff --git a/bisect_kit/git_util.py b/bisect_kit/git_util.py
index 2a2651b..d900bd9 100644
--- a/bisect_kit/git_util.py
+++ b/bisect_kit/git_util.py
@@ -321,7 +321,7 @@
return git_rev
-def get_commit_time(git_repo, rev, path):
+def get_commit_time(git_repo, rev, path=None):
"""Get git commit timestamp.
Args:
@@ -332,8 +332,10 @@
Returns:
timestamp (int)
"""
- line = util.check_output(
- 'git', 'log', '-1', '--format=%ct', rev, '--', path, cwd=git_repo)
+ cmd = ['git', 'log', '-1', '--format=%ct', rev]
+ if path:
+ cmd += ['--', path]
+ line = util.check_output(*cmd, cwd=git_repo)
return int(line)