Skip to content

Commit 42e03db

Browse files
authored
Merge pull request #3 from code0-tech/update-commit-range-representation
Extract commit range representation into presenter
2 parents 875d579 + 8f5d92a commit 42e03db

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

lib/pyxis/managed_versioning/component_updater.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ def execute
4848

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

51-
commit_count = GithubClient.octokit.compare(component.github_path, current_version, new_version).ahead_by
52-
commit_range = "#{current_version[0...11]}...#{new_version[0...11]} (#{commit_count} commits)"
53-
compare_link = "[#{commit_range}](https://github.com/#{component.github_path}/compare/#{current_version}...#{new_version})"
5451
pr = GithubClient.octokit.create_pull_request(
5552
Project::Reticulum.github_path,
5653
Project::Reticulum.default_branch,
@@ -59,7 +56,7 @@ def execute
5956
<<~DESCRIPTION
6057
Update #{component.component_name} to #{new_version_link} as part of managed versioning
6158
62-
#{compare_link}
59+
#{Presenter::CommitRange.new(component, current_version, new_version).as_markdown}
6360
DESCRIPTION
6461
)
6562
logger.info('Created pull request', pull_request_url: pr.html_url)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
module Pyxis
4+
module Presenter
5+
class CommitRange
6+
attr_reader :project, :current_version, :new_version
7+
8+
def initialize(project, current_version, new_version)
9+
@project = project
10+
@current_version = current_version
11+
@new_version = new_version
12+
end
13+
14+
def as_markdown
15+
"[#{current_version[0...11]}...#{new_version[0...11]}](#{compare_link}) (#{commit_amount} commits)"
16+
end
17+
18+
private
19+
20+
def compare_link
21+
"https://github.com/#{project.github_path}/compare/#{current_version}...#{new_version}"
22+
end
23+
24+
def commit_amount
25+
GithubClient.octokit.compare(project.github_path, current_version, new_version).ahead_by
26+
end
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)