Skip to content

Commit

Permalink
Remove puts on every run and failure when run outside Scarpe dir
Browse files Browse the repository at this point in the history
  • Loading branch information
noahgibbs committed Oct 10, 2023
1 parent 761b738 commit 530db55
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lacci/lib/shoes/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ def initialize
end

def get_latest_release_info
changelog_content = File.read("CHANGELOG.md")

release_name_pattern = /^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})$/m

release_matches = changelog_content.scan(release_name_pattern)

latest_release = release_matches.max_by { |version, _date| Gem::Version.new(version) }

if latest_release
puts "Found release #{latest_release[0]} in CHANGELOG.md"
# @log.debug("Found release #{latest_release[0]} in CHANGELOG.md")
{ RELEASE_NAME: latest_release[0], RELEASE_BUILD_DATE: latest_release[1] }
else
puts "No release found in CHANGELOG.md"
{ RELEASE_NAME: nil, RELEASE_BUILD_DATE: nil }
changelog_dir = File.dirname(__FILE__, 4) # this duplicates constants.rb, but how to share?
changelog_file = "#{changelog_dir}/CHANGELOG.md"

if File.exist?(changelog_file)
changelog_content = File.read(changelog_file)
release_name_pattern = /^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})$/m
release_matches = changelog_content.scan(release_name_pattern)
latest_release = release_matches.max_by { |version, _date| Gem::Version.new(version) }

if latest_release
#puts "Found release #{latest_release[0]} in CHANGELOG.md"
# @log.debug("Found release #{latest_release[0]} in CHANGELOG.md") # Logger isn't initialized yet
return({ RELEASE_NAME: latest_release[0], RELEASE_BUILD_DATE: latest_release[1] })
end
end

puts "No release found in CHANGELOG.md"
{ RELEASE_NAME: nil, RELEASE_BUILD_DATE: nil }
end
end
end

0 comments on commit 530db55

Please sign in to comment.