Skip to content

Commit

Permalink
Merge pull request #185 from lesleh/master
Browse files Browse the repository at this point in the history
Retain modified version file content when bumping version
  • Loading branch information
addersuk authored Feb 23, 2024
2 parents 3143aed + faa03c8 commit d19dbc1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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

0 comments on commit d19dbc1

Please sign in to comment.