Skip to content

Commit ded1b46

Browse files
authored
Use a hash for repository directory. (#710)
1 parent 35aff16 commit ded1b46

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spec/installer/repository_spec.cr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ describe "Repository" do
66
context "failures" do
77
context "json" do
88
it "raises error on bad mint.json" do
9-
FileUtils.mkdir_p("#{tmp_dir}/success")
10-
File.write("#{tmp_dir}/success/mint.json", "hello")
9+
FileUtils.mkdir_p("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")
10+
File.write("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076/mint.json", "hello")
1111

1212
repository = Mint::Installer::Repository.new("name", "success")
1313

@@ -24,7 +24,7 @@ describe "Repository" do
2424
end
2525

2626
it "raises error on no mint.json" do
27-
FileUtils.rm_rf("#{tmp_dir}/success")
27+
FileUtils.rm_rf("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")
2828

2929
repository = Mint::Installer::Repository.new("name", "success")
3030

@@ -91,7 +91,7 @@ describe "Repository" do
9191
end
9292

9393
it "raises error on clone" do
94-
FileUtils.rm_rf("#{tmp_dir}/error")
94+
FileUtils.rm_rf("#{tmp_dir}/cb5e100e5a9a3e7f6d1fd97512215282")
9595

9696
message = <<-MESSAGE
9797
░ ERROR (REPOSITORY_COULD_NOT_CLONE) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
@@ -115,7 +115,7 @@ describe "Repository" do
115115
end
116116

117117
it "raises error on update" do
118-
FileUtils.mkdir_p("#{tmp_dir}/error")
118+
FileUtils.mkdir_p("#{tmp_dir}/cb5e100e5a9a3e7f6d1fd97512215282")
119119

120120
message = <<-MESSAGE
121121
░ ERROR (REPOSITORY_COULD_NOT_UPDATE) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
@@ -146,14 +146,14 @@ describe "Repository" do
146146
end
147147

148148
it "clones successfully" do
149-
FileUtils.rm_rf("#{tmp_dir}/success")
149+
FileUtils.rm_rf("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")
150150

151151
repository = Mint::Installer::Repository.open("name", "success")
152152
repository.output.should eq(" ✔ Cloned name (success)")
153153
end
154154

155155
it "updates successfully" do
156-
FileUtils.mkdir_p("#{tmp_dir}/success")
156+
FileUtils.mkdir_p("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")
157157

158158
repository = Mint::Installer::Repository.open("name", "success")
159159
repository.output.should eq(" ✔ Updated name (success)")

src/installer/repository.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ module Mint
206206

207207
# The directory of the repository
208208
def directory
209-
Path[MINT_PACKAGES_DIR, url].to_s
209+
Path[MINT_PACKAGES_DIR, Digest::MD5.hexdigest(url)].to_s
210210
end
211211

212212
# Runs a shell command and returns its status, output and error in a tuple.

0 commit comments

Comments
 (0)