Skip to content

Commit

Permalink
Use a hash for repository directory. (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign authored Nov 24, 2024
1 parent 35aff16 commit ded1b46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions spec/installer/repository_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ describe "Repository" do
context "failures" do
context "json" do
it "raises error on bad mint.json" do
FileUtils.mkdir_p("#{tmp_dir}/success")
File.write("#{tmp_dir}/success/mint.json", "hello")
FileUtils.mkdir_p("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")
File.write("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076/mint.json", "hello")

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

Expand All @@ -24,7 +24,7 @@ describe "Repository" do
end

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

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

Expand Down Expand Up @@ -91,7 +91,7 @@ describe "Repository" do
end

it "raises error on clone" do
FileUtils.rm_rf("#{tmp_dir}/error")
FileUtils.rm_rf("#{tmp_dir}/cb5e100e5a9a3e7f6d1fd97512215282")

message = <<-MESSAGE
░ ERROR (REPOSITORY_COULD_NOT_CLONE) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Expand All @@ -115,7 +115,7 @@ describe "Repository" do
end

it "raises error on update" do
FileUtils.mkdir_p("#{tmp_dir}/error")
FileUtils.mkdir_p("#{tmp_dir}/cb5e100e5a9a3e7f6d1fd97512215282")

message = <<-MESSAGE
░ ERROR (REPOSITORY_COULD_NOT_UPDATE) ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Expand Down Expand Up @@ -146,14 +146,14 @@ describe "Repository" do
end

it "clones successfully" do
FileUtils.rm_rf("#{tmp_dir}/success")
FileUtils.rm_rf("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")

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

it "updates successfully" do
FileUtils.mkdir_p("#{tmp_dir}/success")
FileUtils.mkdir_p("#{tmp_dir}/260ca9dd8a4577fc00b7bd5810298076")

repository = Mint::Installer::Repository.open("name", "success")
repository.output.should eq(" ✔ Updated name (success)")
Expand Down
2 changes: 1 addition & 1 deletion src/installer/repository.cr
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ module Mint

# The directory of the repository
def directory
Path[MINT_PACKAGES_DIR, url].to_s
Path[MINT_PACKAGES_DIR, Digest::MD5.hexdigest(url)].to_s
end

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

0 comments on commit ded1b46

Please sign in to comment.