aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/git.rb
diff options
context:
space:
mode:
authormansimarkaur2017-07-28 00:37:32 +0530
committermansimarkaur2017-08-27 01:23:32 +0530
commitd91036e8912b31e3eb145b1cb3964a321a587c4f (patch)
tree96e55ed4a4fac27d24af276b3945372f441e933b /Library/Homebrew/utils/git.rb
parent551e5dd94578062e0ab42bc56e0fdd106807839b (diff)
downloadbrew-d91036e8912b31e3eb145b1cb3964a321a587c4f.tar.bz2
Added tests for last_revision_commit_of_file
Diffstat (limited to 'Library/Homebrew/utils/git.rb')
-rw-r--r--Library/Homebrew/utils/git.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index 43d93b64e..3668b9d11 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -4,7 +4,7 @@ module Git
module_function
def last_revision_commit_of_file(repo, file, before_commit: nil)
- args = [before_commit.nil? ? "--skip=1" : before_commit.split("..").first]
+ args = ["--skip=#{before_commit.nil? ? 1 : before_commit.split("..").first}"]
out, = Open3.capture3(
HOMEBREW_SHIMS_PATH/"scm/git", "-C", repo,
@@ -16,11 +16,10 @@ module Git
def last_revision_of_file(repo, file, before_commit: nil)
relative_file = Pathname(file).relative_path_from(repo)
- commit_hash = last_revision_commit_of_file(repo, file, before_commit: before_commit)
-
+ commit_hash = last_revision_commit_of_file(repo, relative_file, before_commit: before_commit)
out, = Open3.capture3(
HOMEBREW_SHIMS_PATH/"scm/git", "-C", repo,
- "show", "#{commit_hash}:#{relative_file}"
+ "show", "#{commit_hash}:#{file}"
)
out
end
@@ -28,8 +27,7 @@ end
module Utils
def self.git_available?
- return @git if instance_variable_defined?(:@git)
- @git = quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
+ @git ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
end
def self.git_path