Skip to content

Commit 8a6e8b9

Browse files
authored
Merge pull request #8307 from rubygems/segiddins/stop-storing-executable-names-in-ivars
Stop storing executable names in ivars
2 parents 0359f86 + 7c634ec commit 8a6e8b9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/rubygems/resolver/git_set.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
3636
def initialize # :nodoc:
3737
super()
3838

39-
@git = ENV["git"] || "git"
4039
@need_submodules = {}
4140
@repositories = {}
4241
@root_dir = Gem.dir

lib/rubygems/source/git.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def initialize(name, repository, reference, submodules = false)
5858

5959
@remote = true
6060
@root_dir = Gem.dir
61-
@git = ENV["git"] || "git"
6261
end
6362

6463
def <=>(other)
@@ -81,6 +80,10 @@ def ==(other) # :nodoc:
8180
@need_submodules == other.need_submodules
8281
end
8382

83+
def git_command
84+
ENV.fetch("git", "git")
85+
end
86+
8487
##
8588
# Checks out the files for the repository into the install_dir.
8689

@@ -90,18 +93,18 @@ def checkout # :nodoc:
9093
return false unless File.exist? repo_cache_dir
9194

9295
unless File.exist? install_dir
93-
system @git, "clone", "--quiet", "--no-checkout",
96+
system git_command, "clone", "--quiet", "--no-checkout",
9497
repo_cache_dir, install_dir
9598
end
9699

97100
Dir.chdir install_dir do
98-
system @git, "fetch", "--quiet", "--force", "--tags", install_dir
101+
system git_command, "fetch", "--quiet", "--force", "--tags", install_dir
99102

100-
success = system @git, "reset", "--quiet", "--hard", rev_parse
103+
success = system git_command, "reset", "--quiet", "--hard", rev_parse
101104

102105
if @need_submodules
103106
require "open3"
104-
_, status = Open3.capture2e(@git, "submodule", "update", "--quiet", "--init", "--recursive")
107+
_, status = Open3.capture2e(git_command, "submodule", "update", "--quiet", "--init", "--recursive")
105108

106109
success &&= status.success?
107110
end
@@ -118,11 +121,11 @@ def cache # :nodoc:
118121

119122
if File.exist? repo_cache_dir
120123
Dir.chdir repo_cache_dir do
121-
system @git, "fetch", "--quiet", "--force", "--tags",
124+
system git_command, "fetch", "--quiet", "--force", "--tags",
122125
@repository, "refs/heads/*:refs/heads/*"
123126
end
124127
else
125-
system @git, "clone", "--quiet", "--bare", "--no-hardlinks",
128+
system git_command, "clone", "--quiet", "--bare", "--no-hardlinks",
126129
@repository, repo_cache_dir
127130
end
128131
end
@@ -182,7 +185,7 @@ def rev_parse # :nodoc:
182185
hash = nil
183186

184187
Dir.chdir repo_cache_dir do
185-
hash = Gem::Util.popen(@git, "rev-parse", @reference).strip
188+
hash = Gem::Util.popen(git_command, "rev-parse", @reference).strip
186189
end
187190

188191
raise Gem::Exception,

0 commit comments

Comments
 (0)