Skip to content
Closed
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
6 changes: 5 additions & 1 deletion lib/unwrappr/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def to_s
private

def segment(index)
segment = @version.canonical_segments[index] || 0
segment = if @version.respond_to?(:canonical_segments)
@version.canonical_segments[index] || 0
else
@version.segments[index] || 0
end
(segment.is_a?(Numeric) ? segment : nil)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/unwrappr/git_command_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def create_and_annotate_pull_request

def annotate_pull_request(pr_number)
LockFileAnnotator.annotate_github_pull_request(
repo: repo_name_and_org,
pr_number: pr_number,
client: git_client
repo: repo_name_and_org,
pr_number: pr_number,
client: git_client
)
end

Expand Down
10 changes: 5 additions & 5 deletions lib/unwrappr/github/pr_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def initialize(repo, pr_number, client)
def each_file
lock_file_diffs.each do |lock_file_diff|
yield LockFileDiff.new(
filename: lock_file_diff.filename,
base_file: file_contents(lock_file_diff.filename, base_sha),
head_file: file_contents(lock_file_diff.filename, head_sha),
patch: lock_file_diff.patch,
sha: head_sha
filename: lock_file_diff.filename,
base_file: file_contents(lock_file_diff.filename, base_sha),
head_file: file_contents(lock_file_diff.filename, head_sha),
patch: lock_file_diff.patch,
sha: head_sha
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/unwrappr/lock_file_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def initialize(filename:, base_file:, head_file:, patch:, sha:)
def each_gem_change
version_changes.each do |change|
yield GemChange.new(
name: change[:dependency].to_s,
base_version: gem_version(change[:before]),
head_version: gem_version(change[:after]),
line_number: line_number_for_change(change),
name: change[:dependency].to_s,
base_version: gem_version(change[:before]),
head_version: gem_version(change[:after]),
line_number: line_number_for_change(change),
lock_file_diff: self
)
end
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/unwrappr/github/pr_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ module Unwrappr
it 'produces a LockFileDiff with the expected attributes' do
files
expect(LockFileDiff).to have_received(:new)
.with(filename: 'my/Gemfile.lock',
base_file: 'content-1',
head_file: 'content-2',
patch: 'my-gem-patch',
sha: 'head-sha')
.with(filename: 'my/Gemfile.lock',
base_file: 'content-1',
head_file: 'content-2',
patch: 'my-gem-patch',
sha: 'head-sha')
end
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/lib/unwrappr/lock_file_annotator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@ module Unwrappr
before do
allow(::Unwrappr::RubyGems).to receive(:gem_info)
.with('rspec-support')
.and_return(spy(homepage_uri: 'home-uri',
source_code_uri: 'source-uri',
changelog_uri: 'changelog-uri'))
.and_return(spy(homepage_uri: 'home-uri',
source_code_uri: 'source-uri',
changelog_uri: 'changelog-uri'))
allow(lock_file_diff_source).to receive(:each_file)
.and_yield(LockFileDiff.new(filename: 'Gemfile.lock',
base_file: base_lock_file,
head_file: head_lock_file,
patch: patch,
sha: '89ee3f7d'))
.and_yield(LockFileDiff.new(filename: 'Gemfile.lock',
base_file: base_lock_file,
head_file: head_lock_file,
patch: patch,
sha: '89ee3f7d'))
end

it 'annotates gem changes' do
annotate
expect(annotation_sink).to have_received(:annotate_change)
.with(
having_attributes(name: 'rspec-support',
having_attributes(name: 'rspec-support',
base_version: GemVersion.new('3.7.0'),
head_version: GemVersion.new('3.7.1'),
filename: 'Gemfile.lock',
sha: '89ee3f7d',
line_number: 5),
filename: 'Gemfile.lock',
sha: '89ee3f7d',
line_number: 5),
<<~MESSAGE
### [rspec-support](home-uri)

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/unwrappr/lock_file_diff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Unwrappr
RSpec.describe LockFileDiff do
subject(:lock_file_diff) do
LockFileDiff.new(
filename: 'Gemfile.lock',
filename: 'Gemfile.lock',
base_file: base_file,
head_file: head_file,
patch: patch,
sha: '123'
patch: patch,
sha: '123'
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/unwrappr/writers/project_links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Writers
let(:gem_change_info) do
{
ruby_gems: spy(source_code_uri: 'source-uri',
changelog_uri: 'changelog-uri')
changelog_uri: 'changelog-uri')
}
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/unwrappr/writers/version_change_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module Writers
subject(:write) { VersionChange.write(gem_change, gem_change_info) }

let(:gem_change) do
GemChange.new(name: 'test-gem',
head_version: head_version,
base_version: base_version,
line_number: 9870,
GemChange.new(name: 'test-gem',
head_version: head_version,
base_version: base_version,
line_number: 9870,
lock_file_diff: instance_double(LockFileDiff))
end
let(:gem_change_info) { {} }
Expand Down
1 change: 1 addition & 0 deletions unwrappr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require 'unwrappr/version'
AUTHORS = {
'emilyn.escabarte@envato.com' => 'Emilyn Escabarte',
'joe.sustaric@envato.com' => 'Joe Sustaric',
'orien.madgwick@envato.com' => 'Orien Madgwick',
'pete.johns@envato.com' => 'Pete Johns',
'vladimir.chervanev@envato.com' => 'Vladimir Chervanev'
}.freeze
Expand Down