Skip to content

Commit

Permalink
minor fix in version regex
Browse files Browse the repository at this point in the history
  • Loading branch information
peaky76 committed Dec 20, 2024
1 parent b985151 commit b434ca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Bump
SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ # rubocop:disable Layout/LineLength
SEPARATOR = /\s*[:=]\s*/
VERSION_KEY = /(?:^|\.|\s|"|'|_*)(?:base|version)(?:_*["']*)/
VERSION_KEY = /(?:^_+|^|\.|\s|"|')(?:base|version)(?:["']*|_+)/
VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze

def initialize(config, level)
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/utils/bump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
version = '__version__ = "1.0.0"'
expect(Bump::VERSION_SETTING).to match(version)
end

it 'does not match unrelated semvers' do
version = 'expected_ruby_version = "3.3.0"'
expect(Bump::VERSION_SETTING).not_to match(version)
end
end

describe '#bump_everything' do
Expand Down

0 comments on commit b434ca2

Please sign in to comment.