aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormansimarkaur2017-08-25 17:55:54 +0530
committermansimarkaur2017-08-29 22:53:10 +0530
commit784250d55099f16d8b9c3553a219d603c200cb6b (patch)
tree7146fa561b423316bdcf9240ad238ae1874ddc29
parentc695dffd373aefaaa84f1cf1098d23bd9f1d998d (diff)
downloadbrew-784250d55099f16d8b9c3553a219d603c200cb6b.tar.bz2
Used already existing clear_git_available_cache to remove @git
-rw-r--r--Library/Homebrew/test/utils/git_spec.rb37
-rw-r--r--Library/Homebrew/utils/git.rb4
2 files changed, 10 insertions, 31 deletions
diff --git a/Library/Homebrew/test/utils/git_spec.rb b/Library/Homebrew/test/utils/git_spec.rb
index 65dd3bf41..e511212f4 100644
--- a/Library/Homebrew/test/utils/git_spec.rb
+++ b/Library/Homebrew/test/utils/git_spec.rb
@@ -4,37 +4,36 @@ describe Git do
before(:each) do
git = HOMEBREW_SHIMS_PATH/"scm/git"
- @file = "blah.rb"
-
HOMEBREW_CACHE.cd do
system git, "init"
- File.open(@file, "w") { |f| f.write("blah") }
- system git, "add", HOMEBREW_CACHE/@file
+ File.open(file, "w") { |f| f.write("blah") }
+ system git, "add", HOMEBREW_CACHE/file
system git, "commit", "-m", "'File added'"
@h1 = `git rev-parse HEAD`
- File.open(@file, "w") { |f| f.write("brew") }
- system git, "add", HOMEBREW_CACHE/@file
+ File.open(file, "w") { |f| f.write("brew") }
+ system git, "add", HOMEBREW_CACHE/file
system git, "commit", "-m", "'written to File'"
@h2 = `git rev-parse HEAD`
end
end
+ let(:file) { "blah.rb" }
let(:hash1) { @h1[0..6] }
let(:hash2) { @h2[0..6] }
describe "#last_revision_commit_of_file" do
it "gives last revision commit when before_commit is nil" do
expect(
- described_class.last_revision_commit_of_file(HOMEBREW_CACHE, @file),
+ described_class.last_revision_commit_of_file(HOMEBREW_CACHE, file),
).to eq(hash1)
end
it "gives revision commit based on before_commit when it is not nil" do
expect(
described_class.last_revision_commit_of_file(HOMEBREW_CACHE,
- @file,
+ file,
before_commit: hash2),
).to eq(hash2)
end
@@ -44,13 +43,13 @@ describe Git do
it "returns last revision of file" do
expect(
described_class.last_revision_of_file(HOMEBREW_CACHE,
- HOMEBREW_CACHE/@file),
+ HOMEBREW_CACHE/file),
).to eq("blah")
end
it "returns last revision of file based on before_commit" do
expect(
- described_class.last_revision_of_file(HOMEBREW_CACHE, HOMEBREW_CACHE/@file,
+ described_class.last_revision_of_file(HOMEBREW_CACHE, HOMEBREW_CACHE/file,
before_commit: "0..3"),
).to eq("brew")
end
@@ -59,7 +58,7 @@ end
describe Utils do
before(:each) do
- described_class.clear_git_version_cache
+ described_class.clear_git_available_cache
end
describe "::git_available?" do
@@ -148,20 +147,4 @@ describe Utils do
end
end
end
-
- describe "::clear_git_available_cache" do
- it "removes @git_path and @git_version if defined" do
- described_class.clear_git_available_cache
-
- expect(described_class.instance_variable_get(:@git_path)).to be_nil
- expect(described_class.instance_variable_get(:@git_version)).to be_nil
- end
-
- it "removes @git if defined" do
- described_class.git_available?
- described_class.clear_git_available_cache
-
- expect(described_class.instance_variable_get(:@git)).to be_nil
- end
- end
end
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index 4fdcf1a2e..1fc01188c 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -26,10 +26,6 @@ module Git
end
module Utils
- def self.clear_git_version_cache
- remove_instance_variable(:@git) if instance_variable_defined?(:@git)
- end
-
def self.git_available?
return @git if instance_variable_defined?(:@git)
@git = quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"