Rakefile in u3d-1.2.3 vs Rakefile in u3d-1.3.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + ## --- BEGIN LICENSE BLOCK --- # Copyright (c) 2016-present WeWantToKnow AS # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -33,11 +35,11 @@ RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new class GithubChangelogGenerator - PATH = '.github_changelog_generator'.freeze + PATH = '.github_changelog_generator' class << self def future_release s = File.read(PATH) s.split("\n").each do |line| m = line.match(/future-release=v(.*)/) @@ -54,29 +56,29 @@ "future-release=v#{nextv}" else line end end - File.write(PATH, lines.join("\n") + "\n") + File.write(PATH, "#{lines.join("\n")}\n") end end end class U3dCode - PATH = 'lib/u3d/version.rb'.freeze + PATH = 'lib/u3d/version.rb' class << self def version=(version) s = File.read(PATH) lines = s.split("\n").map do |line| - m = line.match(/(.*VERSION = ').*('.freeze.*)/) + m = line.match(/(.*VERSION = ').*(')/) if m "#{m[1]}#{version}#{m[2]}" else line end end - File.write(PATH, lines.join("\n") + "\n") + File.write(PATH, "#{lines.join("\n")}\n") end end end def run_command(command, error_message = nil) @@ -124,21 +126,23 @@ server = 'github.com' github_team - [hub_user(server)] end ### +desc 'Ensure the git repository is clean. Fails otherwise' task :ensure_git_clean do branch = run_command('git rev-parse --abbrev-ref HEAD', "Couldn't get current git branch").strip UI.user_error!("You are not on 'master' but on '#{branch}'") unless branch == "master" output = run_command('git status --porcelain', "Couldn't get git status") UI.user_error!("git status not clean:\n#{output}") unless output == "" end -# ensure ready to prepare a PR +desc 'Ensure we are ready to prepare a PR' task :prepare_git_pr, [:pr_branch] do |_t, args| pr_branch = args['pr_branch'] raise "Missing pr_branch argument" unless pr_branch + UI.user_error! "Prepare git PR stopped by user" unless UI.confirm("Creating PR branch #{pr_branch}") run_command("git checkout -b #{pr_branch}") end desc 'Prepare a release: check repo status, generate changelog, create PR' @@ -214,12 +218,13 @@ version = nil File.readlines("CHANGELOG.md").each do |line| if (m = line.match(/^## \[(.*)\]/)) releases[version] = buffer if buffer version = m[1] - buffer = version + "\n\n" + buffer = "#{version}\n\n" else next unless version # skip first lines + buffer += line end end releases[version] = buffer releases