diff --git a/src/resolvers/git.cr b/src/resolvers/git.cr index 7fb1cae9..6957fe6b 100644 --- a/src/resolvers/git.cr +++ b/src/resolvers/git.cr @@ -81,18 +81,11 @@ module Shards cleanup_install_directory Dir.mkdir_p(install_path) - if file_exists?(refs, SPEC_FILENAME) - run "git archive --format=tar #{refs} #{SPEC_FILENAME} | tar -x -f - -C #{FileUtils.escape install_path}" - else + unless file_exists?(refs, SPEC_FILENAME) File.write(File.join(install_path, "shard.yml"), read_spec(version)) end - # TODO: search for LICENSE* files - if file_exists?(refs, "LICENSE") - run "git archive --format=tar #{refs} 'LICENSE' | tar -x -f - -C #{FileUtils.escape install_path}" - end - - run "git archive --format=tar --prefix= #{refs}:src/ | tar -x -f - -C #{FileUtils.escape install_path}" + run "git archive --format=tar --prefix= #{refs} | tar -x -f - -C #{FileUtils.escape install_path}" if version =~ RELEASE_VERSION File.delete(sha1_path) if File.exists?(sha1_path) diff --git a/src/resolvers/path.cr b/src/resolvers/path.cr index 6177e3cd..b9f3d164 100644 --- a/src/resolvers/path.cr +++ b/src/resolvers/path.cr @@ -43,13 +43,12 @@ module Shards end def install(version = nil) + path = File.expand_path(local_path) + raise Error.new("Failed no such path: #{path}") unless Dir.exists?(path) + cleanup_install_directory Dir.mkdir_p(File.dirname(install_path)) - - src_path = File.expand_path(File.join(local_path, "src")) - raise Error.new("Failed no such path: #{local_path}") unless Dir.exists?(src_path) - - File.symlink(src_path, install_path) + File.symlink(path, install_path) end end diff --git a/test/git_resolver_test.cr b/test/git_resolver_test.cr index c7709536..1a5c7719 100644 --- a/test/git_resolver_test.cr +++ b/test/git_resolver_test.cr @@ -33,12 +33,11 @@ module Shards assert_equal "name: library\nversion: 0.1.1\n", resolver("library").read_spec("0.1.1") end - # TODO: test that LICENSE was installed def test_install library, legacy = resolver("library"), resolver("legacy") library.install("0.1.2") - assert File.exists?(install_path("library", "library.cr")) + assert File.exists?(install_path("library", "src/library.cr")) assert File.exists?(install_path("library", "shard.yml")) assert_equal "0.1.2", library.installed_spec.not_nil!.version #assert File.exists?(install_path("library", "LICENSE")) @@ -47,11 +46,11 @@ module Shards assert_equal "0.2.0", library.installed_spec.not_nil!.version legacy.install - assert File.exists?(install_path("legacy", "legacy.cr")) + assert File.exists?(install_path("legacy", "src/legacy.cr")) assert File.exists?(install_path("legacy", "shard.yml")) legacy.install("1.0.0") - assert File.exists?(install_path("legacy", "legacy.cr")) + assert File.exists?(install_path("legacy", "src/legacy.cr")) assert File.exists?(install_path("legacy", "shard.yml")) assert_equal "1.0.0", legacy.installed_spec.not_nil!.version end @@ -64,7 +63,7 @@ module Shards empty = resolver("empty") empty.install # HEAD - assert File.exists?(install_path("empty", "empty.cr")) + assert File.exists?(install_path("empty", "src/empty.cr")) assert File.exists?(install_path("empty", "shard.yml")) spec = empty.installed_spec.not_nil! diff --git a/test/integration_helper.cr b/test/integration_helper.cr index 61a7e4cb..26ca74b3 100644 --- a/test/integration_helper.cr +++ b/test/integration_helper.cr @@ -47,11 +47,11 @@ class Minitest::Test create_git_commit "empty", "initial release" create_git_repository "post" - create_file "post", "src/Makefile", "all:\n\ttouch made.txt\n" + create_file "post", "Makefile", "all:\n\ttouch made.txt\n" create_git_release "post", "0.1.0", "name: post\nversion: 0.1.0\nscripts:\n postinstall: make\n" create_git_repository "fails" - create_file "fails", "src/Makefile", "all:\n\ttest -n ''\n" + create_file "fails", "Makefile", "all:\n\ttest -n ''\n" create_git_release "fails", "0.1.0", "name: fails\nversion: 0.1.0\nscripts:\n postinstall: make\n" create_path_repository "foo" diff --git a/test/path_resolver_test.cr b/test/path_resolver_test.cr index 37e31737..723f3131 100644 --- a/test/path_resolver_test.cr +++ b/test/path_resolver_test.cr @@ -36,14 +36,14 @@ module Shards def test_install resolver("library").tap do |library| library.install - assert File.exists?(install_path("library", "library.cr")) - refute File.exists?(install_path("library", "shard.yml")) + assert File.exists?(install_path("library", "src/library.cr")) + assert File.exists?(install_path("library", "shard.yml")) assert_equal "1.2.3", library.installed_spec.not_nil!.version end resolver("legacy").tap do |legacy| legacy.install - assert File.exists?(install_path("legacy", "legacy.cr")) + assert File.exists?(install_path("legacy", "src/legacy.cr")) refute File.exists?(install_path("legacy", "shard.yml")) assert_equal DEFAULT_VERSION, legacy.installed_spec.not_nil!.version end