File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,17 @@ describe "install" do
200200 end
201201 end
202202
203+ it " fails to install when dependency requirement (commit) changed in production" do
204+ metadata = {dependencies: {inprogress: {git: git_url(:inprogress ), commit: git_commits(:inprogress )[1 ]}}}
205+ lock = {inprogress: git_commits(:inprogress ).first}
206+
207+ with_shard(metadata, lock) do
208+ ex = expect_raises(FailedCommand ) { run " shards install --no-color --production" }
209+ ex.stdout.should contain(" Outdated shard.lock" )
210+ refute_installed " inprogress"
211+ end
212+ end
213+
203214 it " updates when dependency requirement changed" do
204215 metadata = {dependencies: {web: " 2.0.0" }}
205216 lock = {web: " 1.0.0" }
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ private def setup_repositories
6666 create_git_release " renamed" , " 0.2.0" , " name: new_name\n version: 0.2.0"
6767 create_git_version_commit " renamed" , " 0.3.0" , " name: another_name\n version: 0.3.0"
6868
69+ create_git_repository " inprogress"
70+ create_git_version_commit " inprogress" , " 0.1.0"
71+ create_git_version_commit " inprogress" , " 0.1.0"
72+
6973 create_git_repository " transitive"
7074 create_file " transitive" , " src/version.cr" , %( require "version"; puts Version::STRING)
7175 create_git_release " transitive" , " 0.2.0" , <<-YAML
Original file line number Diff line number Diff line change @@ -33,10 +33,10 @@ module Shards
3333 private def validate (packages )
3434 packages.each do |package |
3535 if lock = locks.find { |d | d.name == package.name }
36- if version = lock.version?
37- validate_locked_version(package, version)
38- elsif commit = lock[" commit" ]?
36+ if commit = lock[" commit" ]?
3937 validate_locked_commit(package, commit)
38+ elsif version = lock.version?
39+ validate_locked_version(package, version)
4040 else
4141 raise InvalidLock .new # unknown lock resolver
4242 end
@@ -48,12 +48,11 @@ module Shards
4848
4949 private def validate_locked_version (package , version )
5050 return if package.version == version
51- return if Versions .matches?(version, package.spec.version)
5251 raise LockConflict .new(" #{ package.name } requirements changed" )
5352 end
5453
5554 private def validate_locked_commit (package , commit )
56- return if commit == package. commit
55+ return if package. commit == commit
5756 raise LockConflict .new(" #{ package.name } requirements changed" )
5857 end
5958
You can’t perform that action at this time.
0 commit comments