Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect locks when adding new dependencies #336

Merged
merged 1 commit into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions spec/integration/install_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ describe "install" do
end
end

it "install subdependency of new dependency respecting lock" do
create_git_repository "c"
create_git_release "c", "0.1.0", "name: c\nversion: 0.1.0\ndependencies:\n d:\n git: #{git_path("d")}\n version: 0.1.0\n"
create_git_release "c", "0.2.0", "name: c\nversion: 0.2.0\ndependencies:\n d:\n git: #{git_path("d")}\n version: 0.2.0\n"
create_git_repository "d"
create_git_release "d", "0.1.0", "name: d\nversion: 0.1.0\n"
create_git_release "d", "0.2.0", "name: d\nversion: 0.2.0\n"

metadata = {dependencies: {c: "*", d: "*"}}
lock = {d: "0.1.0"}

with_shard(metadata, lock) do
run "shards install"

assert_installed "c", "0.1.0"
assert_installed "d", "0.1.0"
end
end

it "installs and updates lockfile for added dependencies" do
metadata = {
dependencies: {
Expand Down
4 changes: 3 additions & 1 deletion src/molinillo_solver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ module Shards
end

if (locks = @locks) && (locked = locks.find { |dep| dep.name == dependency.name })
matching << locked.version
if Versions.matches?(locked.version, dependency.version)
matching << locked.version
end
end

if matching.size == 1 && matching.first == "HEAD"
Expand Down