utils/git: use exact format for last_revision_*
Format for oneline can be overridden in user's gitconfig. If that's the
case, last_revision_commit_of_file won't work properly, and because of
that last_revision_of_file won't work at all.
Here's what I was getting when running brew tests:
expected: "6bec2de"
got: "\e[33m6bec2dee633f\e[m"
I have abbrev length set to 12, and oneline formatting is more colorful.
So, instead of relying on overrideable format, it should rather specify
"--format=%h" to get only hash, and speciy --abbrev=7 to force abbrev
length to be 7
After this commit tests are passing for me.
This commit is contained in:
parent
700a4b4ca7
commit
461bb20b7c
@ -8,9 +8,10 @@ module Git
|
||||
|
||||
out, = Open3.capture3(
|
||||
HOMEBREW_SHIMS_PATH/"scm/git", "-C", repo,
|
||||
"log", "--oneline", "--max-count=1", *args, "--", file
|
||||
"log", "--format=%h", "--abbrev=7", "--max-count=1",
|
||||
*args, "--", file
|
||||
)
|
||||
out.split(" ").first
|
||||
out.chomp
|
||||
end
|
||||
|
||||
def last_revision_of_file(repo, file, before_commit: nil)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user