Skip to content

Commit

Permalink
Handle git dependencies when creating PR message for libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
greysteil committed Jan 10, 2019
1 parent e58d010 commit ffd8f50
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/dependabot/pull_request_creator/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ def old_library_requirement(dependency)
old_reqs.find { |r| r[:file].match?(%r{^[^/]*\.gemspec$}) }
return gemspec.fetch(:requirement) if gemspec

old_reqs.first.fetch(:requirement)
req = old_reqs.first.fetch(:requirement)
return req if req
return previous_ref(dependency) if ref_changed?(dependency)

raise "No previous requirement!"
end

def new_library_requirement(dependency)
Expand All @@ -643,7 +647,11 @@ def new_library_requirement(dependency)
updated_reqs.find { |r| r[:file].match?(%r{^[^/]*\.gemspec$}) }
return gemspec.fetch(:requirement) if gemspec

updated_reqs.first.fetch(:requirement)
req = updated_reqs.first.fetch(:requirement)
return req if req
return new_ref(dependency) if ref_changed?(dependency)

raise "No new requirement!"
end

def link_issues(text:, dependency:)
Expand Down
38 changes: 38 additions & 0 deletions spec/dependabot/pull_request_creator/message_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,44 @@ def commits_details(base:, head:)
to eq("Update business requirement from ~> 1.4.0 to ~> 1.5.0")
end

context "with a git dependency" do
let(:dependency) do
Dependabot::Dependency.new(
name: "business",
version: "1.5.0",
previous_version: "1.4.0",
package_manager: "bundler",
requirements: [{
file: "package.json",
requirement: nil,
groups: [],
source: {
ref: "v0.4.1",
url: "https://github.com/wireapp/wire-web-config-default",
type: "git",
branch: nil
}
}],
previous_requirements: [{
file: "Gemfile",
requirement: nil,
groups: [],
source: {
ref: "v0.3.0",
url: "https://github.com/wireapp/wire-web-config-default",
type: "git",
branch: nil
}
}]
)
end

it "has the right title" do
expect(pr_name).
to eq("Update business requirement from v0.3.0 to v0.4.1")
end
end

context "with a security vulnerability fixed" do
let(:vulnerabilities_fixed) { { "business": [{}] } }
it { is_expected.to start_with("[Security] Update business") }
Expand Down

0 comments on commit ffd8f50

Please sign in to comment.