Skip to content

Commit 4fddd36

Browse files
author
Kevin Paulisse
committed
Add helper function to strip log messages
1 parent b6f7365 commit 4fddd36

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

spec/octocatalog-diff/tests/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ def self.remove_file_and_line(diff)
228228
obj.map { |x| x[0] =~ /^[\-\+]$/ ? x[0..2] : x[0..3] }
229229
end
230230

231+
# Strip off timestamps and other extraneous content from log messages so that matching
232+
# of individual elements can be done via string and not regexp.
233+
def self.strip_log_message(message)
234+
return message unless message.strip =~ /\A\w,\s*\[[^\]]+\]\s+(\w+)\s*--\s*:(.+)/
235+
"#{Regexp.last_match(1)} - #{Regexp.last_match(2).strip}"
236+
end
237+
231238
# Get the Puppet version from the Puppet binary
232239
def self.puppet_version
233240
require require_path('util/puppetversion')

0 commit comments

Comments
 (0)