Skip to content
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
5 changes: 1 addition & 4 deletions lib/pyxis/managed_versioning/component_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def execute

new_version_link = "[#{new_version[0...11]}](https://github.com/#{component.github_path}/commits/#{new_version})"

commit_count = GithubClient.octokit.compare(component.github_path, current_version, new_version).ahead_by
commit_range = "#{current_version[0...11]}...#{new_version[0...11]} (#{commit_count} commits)"
compare_link = "[#{commit_range}](https://github.com/#{component.github_path}/compare/#{current_version}...#{new_version})"
pr = GithubClient.octokit.create_pull_request(
Project::Reticulum.github_path,
Project::Reticulum.default_branch,
Expand All @@ -59,7 +56,7 @@ def execute
<<~DESCRIPTION
Update #{component.component_name} to #{new_version_link} as part of managed versioning

#{compare_link}
#{Presenter::CommitRange.new(component, current_version, new_version).as_markdown}
DESCRIPTION
)
logger.info('Created pull request', pull_request_url: pr.html_url)
Expand Down
29 changes: 29 additions & 0 deletions lib/pyxis/presenter/commit_range.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Pyxis
module Presenter
class CommitRange
attr_reader :project, :current_version, :new_version

def initialize(project, current_version, new_version)
@project = project
@current_version = current_version
@new_version = new_version
end

def as_markdown
"[#{current_version[0...11]}...#{new_version[0...11]}](#{compare_link}) (#{commit_amount} commits)"
end

private

def compare_link
"https://github.com/#{project.github_path}/compare/#{current_version}...#{new_version}"
end

def commit_amount
GithubClient.octokit.compare(project.github_path, current_version, new_version).ahead_by
end
end
end
end