From 461bb20b7cd72ec8fc23b9b6b6d75ef6cb534624 Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Mon, 12 Mar 2018 13:26:43 +0300 Subject: [PATCH] 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. --- Library/Homebrew/utils/git.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb index 0ffcab7b1d..af0eea92ab 100644 --- a/Library/Homebrew/utils/git.rb +++ b/Library/Homebrew/utils/git.rb @@ -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)