Skip to content

Commit d7976a0

Browse files
committed
Introduce commit sha presenter
1 parent 42e03db commit d7976a0

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

lib/pyxis/managed_versioning/component_updater.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ def execute
4040
GithubClient.octokit.update_contents(
4141
Project::Reticulum.github_path,
4242
version_file,
43-
"Update #{component.component_name} version to #{new_version[0...11]}",
43+
"Update #{component.component_name} version to #{present_sha(new_version)}",
4444
version_file_content.sha,
4545
new_version,
4646
branch: update_branch
4747
)
4848

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

5151
pr = GithubClient.octokit.create_pull_request(
5252
Project::Reticulum.github_path,
5353
Project::Reticulum.default_branch,
5454
update_branch,
55-
"Update #{component.component_name} version to #{new_version[0...11]}",
55+
"Update #{component.component_name} version to #{present_sha(new_version)}",
5656
<<~DESCRIPTION
5757
Update #{component.component_name} to #{new_version_link} as part of managed versioning
5858
@@ -121,6 +121,10 @@ def filter_for_passing_checks(commits)
121121

122122
filtered_commits
123123
end
124+
125+
def present_sha(sha)
126+
Presenter::CommitSha.new(sha).as_short
127+
end
124128
end
125129
end
126130
end

lib/pyxis/presenter/commit_range.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(project, current_version, new_version)
1212
end
1313

1414
def as_markdown
15-
"[#{current_version[0...11]}...#{new_version[0...11]}](#{compare_link}) (#{commit_amount} commits)"
15+
"[#{present_sha(current_version)}...#{present_sha(new_version)}](#{compare_link}) (#{commit_amount} commits)"
1616
end
1717

1818
private
@@ -24,6 +24,10 @@ def compare_link
2424
def commit_amount
2525
GithubClient.octokit.compare(project.github_path, current_version, new_version).ahead_by
2626
end
27+
28+
def present_sha(sha)
29+
CommitSha.new(sha).as_short
30+
end
2731
end
2832
end
2933
end

lib/pyxis/presenter/commit_sha.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module Pyxis
4+
module Presenter
5+
class CommitSha
6+
attr_reader :sha
7+
8+
def initialize(sha)
9+
@sha = sha
10+
end
11+
12+
def as_short
13+
sha[0...11]
14+
end
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)