Skip to content

Commit 32d3833

Browse files
committed
Extract component update into a method
1 parent d7976a0 commit 32d3833

1 file changed

Lines changed: 35 additions & 33 deletions

File tree

lib/pyxis/managed_versioning/component_updater.rb

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,7 @@ def execute
3030

3131
logger.info('Updating component version', current_version: current_version, new_version: new_version)
3232

33-
unless Pyxis::GlobalStatus.dry_run?
34-
GithubClient.octokit.create_ref(
35-
Project::Reticulum.github_path,
36-
"refs/heads/#{update_branch}",
37-
GithubClient.octokit.branch(Project::Reticulum.github_path, Project::Reticulum.default_branch).commit.sha
38-
)
39-
40-
GithubClient.octokit.update_contents(
41-
Project::Reticulum.github_path,
42-
version_file,
43-
"Update #{component.component_name} version to #{present_sha(new_version)}",
44-
version_file_content.sha,
45-
new_version,
46-
branch: update_branch
47-
)
48-
49-
new_version_link = "[#{present_sha(new_version)}](https://github.com/#{component.github_path}/commits/#{new_version})"
50-
51-
pr = GithubClient.octokit.create_pull_request(
52-
Project::Reticulum.github_path,
53-
Project::Reticulum.default_branch,
54-
update_branch,
55-
"Update #{component.component_name} version to #{present_sha(new_version)}",
56-
<<~DESCRIPTION
57-
Update #{component.component_name} to #{new_version_link} as part of managed versioning
58-
59-
#{Presenter::CommitRange.new(component, current_version, new_version).as_markdown}
60-
DESCRIPTION
61-
)
62-
logger.info('Created pull request', pull_request_url: pr.html_url)
63-
64-
Pyxis::Services::AutoMergeService.new(Project::Reticulum, pr).execute
65-
end
33+
update_component_version(current_version, new_version) unless Pyxis::GlobalStatus.dry_run?
6634

6735
logger.info('Finished component updater', current_version: current_version, new_version: new_version)
6836
end
@@ -86,6 +54,40 @@ def update_branch
8654

8755
private
8856

57+
def update_component_version(current_version, new_version)
58+
GithubClient.octokit.create_ref(
59+
Project::Reticulum.github_path,
60+
"refs/heads/#{update_branch}",
61+
GithubClient.octokit.branch(Project::Reticulum.github_path, Project::Reticulum.default_branch).commit.sha
62+
)
63+
64+
GithubClient.octokit.update_contents(
65+
Project::Reticulum.github_path,
66+
version_file,
67+
"Update #{component.component_name} version to #{present_sha(new_version)}",
68+
version_file_content.sha,
69+
new_version,
70+
branch: update_branch
71+
)
72+
73+
new_version_link = "[#{present_sha(new_version)}](https://github.com/#{component.github_path}/commits/#{new_version})"
74+
75+
pr = GithubClient.octokit.create_pull_request(
76+
Project::Reticulum.github_path,
77+
Project::Reticulum.default_branch,
78+
update_branch,
79+
"Update #{component.component_name} version to #{present_sha(new_version)}",
80+
<<~DESCRIPTION
81+
Update #{component.component_name} to #{new_version_link} as part of managed versioning
82+
83+
#{Presenter::CommitRange.new(component, current_version, new_version).as_markdown}
84+
DESCRIPTION
85+
)
86+
logger.info('Created pull request', pull_request_url: pr.html_url)
87+
88+
Pyxis::Services::AutoMergeService.new(Project::Reticulum, pr).execute
89+
end
90+
8991
def update_branch_exists?
9092
GithubClient.octokit.branch(Project::Reticulum.github_path, update_branch).name == update_branch
9193
rescue Octokit::NotFound

0 commit comments

Comments
 (0)