Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain modified version file content when bumping version #185

Merged
merged 1 commit into from
Feb 23, 2024
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
3 changes: 1 addition & 2 deletions lib/utils/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def bump_everything
commit = Commit.new(@config)
files = []
@other_version_file_paths.push(@version_file_path).each do |version_file_path|
base_branch_content = Content.new(config: @config, ref: @base_branch, path: version_file_path)
head_branch_content = Content.new(config: @config, ref: @head_branch, path: version_file_path)
updated_base_branch_content = base_branch_content.content.gsub @version.to_s, @updated_version.to_s
updated_base_branch_content = head_branch_content.content.gsub @version.to_s, @updated_version.to_s

if head_branch_content.content == updated_base_branch_content
puts "::notice title=Nothing to update::The desired version bump is already present for: #{version_file_path}"
Expand Down
18 changes: 18 additions & 0 deletions spec/lib/utils/bump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,23 @@
"#{version_file_path}\n"
).to_stdout
end

it 'retains modified version file content' do
allow(head_content).to receive(:content).and_return('version: 1.0.0 extra stuff here')
allow(base_content).to receive(:content).and_return('version: 1.0.0')

bump = Bump.new(config, 'patch')
expect(commit).to receive(:multiple_files).with(
[
{
path: other_version_file_paths[0], mode: '100644', type: 'blob',
content: 'version: 1.0.1 extra stuff here'
},
{ path: version_file_path, mode: '100644', type: 'blob', content: 'version: 1.0.1 extra stuff here' }
],
'Bump patch version'
)
bump.bump_everything
end
end
end
Loading