Make git blame test pass independently of core.abbrev setting
7-digit hashes are bogus, so I run with core.abbrev = 12.
Non-default settings for core.abbrev caused the git blame test to fail,
because it was hard-coded to look for exactly 7 digits. This change
allows an --abbrev option to be passed to the git-blame wrapper, and
ensures that the same value is used for the git-blame operation and the
computed expectation.
TEST=tests/git_common_test.py GitReadOnlyFunctionsTest.testBlame
Change-Id: I83cbf4dd7267ea36607119bef52f303d59c3f840
Reviewed-on: https://chromium-review.googlesource.com/451124
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
diff --git a/git_common.py b/git_common.py
index b1e4af8..ab936cb 100644
--- a/git_common.py
+++ b/git_common.py
@@ -294,12 +294,14 @@
sys.exit(1)
-def blame(filename, revision=None, porcelain=False, *_args):
+def blame(filename, revision=None, porcelain=False, abbrev=None, *_args):
command = ['blame']
if porcelain:
command.append('-p')
if revision is not None:
command.append(revision)
+ if abbrev is not None:
+ command.append('--abbrev=%d' % abbrev)
command.extend(['--', filename])
return run(*command)