Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/puppet/provider/package/yum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def self.check_updates(disablerepo, enablerepo, disableexcludes)
def self.parse_updates(str)
# Strip off all content that contains Obsoleting, Security: or Update
body = str.partition(/^(Obsoleting|Security:|Update)/).first

body = body.gsub(/^Upgrades.*?$/m, '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
body = body.gsub(/^Upgrades.*?$/m, '')

I would keep the empty newline after the body modifications.

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
body.gsub!(/^Upgrades.*?$/m, '')

@OpenVoxProject do you prefer the in-place gsub call?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muald I just learnt that in Ruby RegExp the anchors ^ and $ match in m mode actually at the line boundaries and not at the string boundaries (according to the back of my head this used to be different... in Python). This means, due to the $ anchor the match will definitely anchor at the end of the first line. As we want the whole first line gone, we then probably don't need the non-greedy ?.

But we definitely need the m mode otherwise $ would anchor at the end of the whole body string.

We do leave an empty newline after the substitution.

Alternatively, without m mode, we could also do this:

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
# https://regex101.com/r/LiVD53/2/substitution
body.gsub!(/^Upgrades.*\R/, '')

This would remove only the whole first line of the body, if it starts with Upgrades.

@bastelfreak what do you think?

updates = Hash.new { |h, k| h[k] = [] }

body.split(/^\s*\n/).each do |line|
Expand Down