bisect-kit: accept tag commit in spec file
BUG=b:177628432
TEST=./bisect_cr_localbuild_internal.py --old 89.0.4379.0 --new 89.0.4380.0
Change-Id: I8d19b6ebfc9e35bc8e1ed56d1b189a449b5d00c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/bisect-kit/+/2631772
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Auto-Submit: Kuang-che Wu <kcwu@chromium.org>
Commit-Queue: Zheng-Jie Chang <zjchang@chromium.org>
Reviewed-by: Zheng-Jie Chang <zjchang@chromium.org>
diff --git a/bisect_kit/git_util.py b/bisect_kit/git_util.py
index 588cd5a..c43c4cb 100644
--- a/bisect_kit/git_util.py
+++ b/bisect_kit/git_util.py
@@ -326,7 +326,7 @@
try:
return util.check_output(
- 'git', 'cat-file', '-t', rev, cwd=git_repo) == 'commit\n'
+ 'git', 'cat-file', '-t', rev, cwd=git_repo) in ['commit\n', 'tag\n']
except subprocess.CalledProcessError:
return False
except OSError:
@@ -362,9 +362,9 @@
meta = {}
header, meta['message'] = s.split('\n\n', 1)
for line in header.splitlines():
- m = re.match(r'^tree (\w+)', line)
+ m = re.match(r'^(object|tree|type) (\w+)', line)
if m:
- meta['tree'] = m.group(1)
+ meta[m.group(1)] = m.group(2)
continue
m = re.match(r'^parent (\w+)', line)
@@ -429,7 +429,8 @@
if not m.group(3):
metas[object_name] = None
continue
- assert object_type == 'commit', 'unsupported object type: %s' % object_type
+ assert object_type in ['commit',
+ 'tag'], 'unsupported object type: %s' % object_type
object_size = int(m.group(3))
assert data[object_size] == ord(b'\n'), repr(data[object_size])
obj, data = data[:object_size], data[object_size + 1:]