Skip to content

Commit 09021de

Browse files
committed
Fix: prune command must remove .sha1 files, too
1 parent 35616b9 commit 09021de

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/commands/prune.cr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ module Shards
1515
if locks.none? { |d| d.name == name }
1616
Shards.logger.debug "rm -rf '#{Helpers::Path.escape(path)}'"
1717
FileUtils.rm_rf(path)
18+
19+
sha1 = "#{path}.sha1"
20+
if File.exists?(sha1)
21+
Shards.logger.debug "rm '#{Helpers::Path.escape(sha1)}'"
22+
File.delete(sha1)
23+
end
24+
1825
Shards.logger.info "Pruned #{File.join(File.basename(Shards.install_path), name)}"
1926
end
2027
end

test/integration/prune_test.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require "../integration_helper"
33
class PruneCommandTest < Minitest::Test
44
def setup
55
metadata = {
6-
dependencies: {web: "*", orm: "*"},
6+
dependencies: {web: "*", orm: {git: git_url(:orm), branch: "master"}},
77
development_dependencies: {mock: "*"},
88
}
99
with_shard(metadata) { run "shards install" }
@@ -17,6 +17,7 @@ class PruneCommandTest < Minitest::Test
1717
def test_removes_unused_dependencies
1818
Dir.cd(application_path) { run "shards prune" }
1919
assert_equal ["web"], installed_dependencies
20+
refute File.exists?(File.join(application_path, "lib", "orm.sha1"))
2021
end
2122

2223
def test_removes_directories

0 commit comments

Comments
 (0)