bake-modernize 0.61.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e4b0b39c09795d386c79a00ca6b6ee8fe14365b6653ef96a5e89171d6cbed2f
4
- data.tar.gz: 9e69e65ee1a2da00295b425ef16df650a67ff93d06f1573f0515d6ab4cad349f
3
+ metadata.gz: f1285a821430d0892953c2d45e86f8e5d11fe8d27d8212614ddb87914599370c
4
+ data.tar.gz: f1c4f3edb34b0bbecc4b5cada2286f2572173db3d168d21aa0fd8193dcb60b79
5
5
  SHA512:
6
- metadata.gz: 91a9ef1fa66f27cd1cb13989a3c8e610e93598c74f2a8058da17b5f7ce8f072b613e4f7e5c828b9934842739ac57b24f937fd1eb3d2cc4abbfb30046e5f30b19
7
- data.tar.gz: 425c31215daed9ed88e7827885347211afa152c2f97c77a2e73420358638b7c64a6d4b4f7485dc252dc5686b4734ec07e844fb01ee2ad8f33cbea8d82b461126
6
+ metadata.gz: f75c658d10774d709155f72b2933bcd818cad028d2cff2c80071b1b09f46e9caa3fccc82e3503d988d29d410dd08027887d4bba51d6ace5a5abd4931d2b08434
7
+ data.tar.gz: 35962d24b690a376da309acf3608817cee9340e1d330cf11a589153c445387e1a4e9e390d6b0836b021e5bb9f212878c7eb4a60bcdeedacb28fdce7ca23b0252
checksums.yaml.gz.sig CHANGED
Binary file
@@ -66,50 +66,7 @@ private
66
66
 
67
67
  def update_source_file_authors(authorship, path, modifications)
68
68
  copyrights = authorship.copyrights_for_modifications(modifications)
69
-
70
- input = File.readlines(path)
71
- output = []
72
-
73
- if input.first =~ /^\#!/
74
- output.push input.shift
75
- end
76
-
77
- # Drop any old copyright statements.
78
- while input.first =~ /Copyright/i
79
- input.shift
80
- end
81
-
82
- if input.first =~ /^\#.*?\:/
83
- output.push input.shift
84
- if input.first.chomp.empty?
85
- input.shift
86
- end
87
- output << "\n"
88
- end
89
-
90
- # Remove any existing license:
91
- while input.first =~ /^#.*$/
92
- input.shift
93
- end
94
-
95
- # Remove any empty lines:
96
- while input.first&.chomp&.empty?
97
- input.shift
98
- end
99
-
100
- output << "# Released under the MIT License.\n"
101
-
102
- copyrights.each do |copyright|
103
- output << "# #{copyright.statement}\n"
104
- end
105
-
106
- output << "\n"
107
-
108
- output.concat(input)
109
-
110
- File.open(path, "w") do |file|
111
- file.puts(output)
112
- end
69
+ Bake::Modernize::License::SourceFile.update(path, copyrights: copyrights.map(&:statement))
113
70
  end
114
71
 
115
72
  def remove_license(readme_path)
@@ -67,7 +67,9 @@ bundle exec bake modernize:releases:github
67
67
 
68
68
  This task adds `bake-gem-github` to maintenance dependencies, removes the direct `bake-gem` dependency when present, and updates release notes and Bake hooks. `bake-gem-github` supplies `bake-gem` and `bake-releases` as dependencies. Existing `bake-gem-github` version requirements are preserved.
69
69
 
70
- Keep `after_gem_release_version_increment`, which updates release notes and project documentation. GitHub publishing replaces the `after_gem_release` call to `releases:github:release`. When merging an existing `bake.rb`, review the generated edit to ensure it removes that call while preserving unrelated custom behavior. Subsequent `modernize:releases` runs select the same template based on the target project's dependencies and do not add the publishing hook back. Contributing instructions also use `gem:github:release:patch` for projects that have adopted it.
70
+ Keep `after_gem_release_version_increment`, which runs `modernize:license` to refresh `license.md` and Ruby copyright headers before updating release notes and project documentation. This copyright refresh is included in the generated hook for both `bake-gem` and `bake-gem-github`. When upgrading an existing project, run `bundle exec bake modernize:releases` and review the merged `bake.rb` to include the new call.
71
+
72
+ GitHub publishing replaces the `after_gem_release` call to `releases:github:release`. When merging an existing `bake.rb`, review the generated edit to ensure it removes that call while preserving unrelated custom behavior. Subsequent `modernize:releases` runs select the same template based on the target project's dependencies and do not add the publishing hook back. Contributing instructions also use `gem:github:release:patch` for projects that have adopted it.
71
73
 
72
74
  Configure the release workflows separately using the installed gem's setup task. Pass the actual required CI job names; for example, a repository using the standard Ruby matrix and coverage workflows might use:
73
75
 
@@ -12,6 +12,55 @@ module Bake
12
12
  module License
13
13
  GIT_BLAME_IGNORE_REVS = ".git-blame-ignore-revs"
14
14
 
15
+ # Updates Ruby source headers without removing documentation comments.
16
+ class SourceFile
17
+ MAGIC_COMMENT = /\A#\s*(?:-\*-\s*)?(?:coding|encoding|frozen_string_literal|warn_indent|shareable_constant_value)\s*[:=]/i
18
+ LICENSE_COMMENT = /\A#\s*(?:Released under\b|Copyright\b|SPDX-License-Identifier:)/i
19
+
20
+ # Replace the license and copyright header for a Ruby source file.
21
+ # @parameter path [String] The source file path.
22
+ # @parameter copyrights [Array(String)] The copyright statements to write.
23
+ def self.update(path, copyrights:)
24
+ input = File.readlines(path)
25
+ prefix = []
26
+
27
+ prefix << input.shift if input.first&.start_with?("#!")
28
+ while input.first&.match?(MAGIC_COMMENT)
29
+ prefix << input.shift
30
+ end
31
+
32
+ # Keep the complete leading comment block, removing only known license metadata.
33
+ documentation = []
34
+ while line = input.first
35
+ break unless line.match?(/\A\s*#/) || line.strip.empty?
36
+
37
+ input.shift
38
+ next if line.match?(LICENSE_COMMENT)
39
+
40
+ documentation << line
41
+ end
42
+
43
+ while documentation.first&.strip&.empty?
44
+ documentation.shift
45
+ end
46
+ while documentation.last&.strip&.empty?
47
+ documentation.pop
48
+ end
49
+
50
+ output = prefix.dup
51
+ output << "\n" if output.any?
52
+ output << "# Released under the MIT License.\n"
53
+ copyrights.each do |copyright|
54
+ output << "# #{copyright}\n"
55
+ end
56
+ output << "\n"
57
+ output.concat(documentation)
58
+ output.concat(input)
59
+
60
+ File.write(path, output.join)
61
+ end
62
+ end
63
+
15
64
  # Represents revisions to skip when analyzing authorship.
16
65
  class SkipList
17
66
  # Load the skip list from a directory.
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.61.0"
8
+ VERSION = "0.63.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Copyright, 2020-2026, by Samuel Williams.
4
4
  Copyright, 2021-2023, by Olle Jonsson.
5
5
  Copyright, 2025, by Copilot.
6
+ Copyright, 2026, by Sampo Kuokkanen.
6
7
 
7
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
9
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -14,6 +14,10 @@ Please see the [project documentation](https://ioquatix.github.io/bake-modernize
14
14
 
15
15
  Please see the [project releases](https://ioquatix.github.io/bake-modernize/releases/index) for all releases.
16
16
 
17
+ ### v0.62.0
18
+
19
+ - Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
20
+
17
21
  ### v0.61.0
18
22
 
19
23
  - Provide agent context for updating gems and configuring GitHub releases.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.62.0
4
+
5
+ - Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
6
+
3
7
  ## v0.61.0
4
8
 
5
9
  - Provide agent context for updating gems and configuring GitHub releases.
@@ -3,10 +3,11 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2025-2026, by Samuel Williams.
5
5
 
6
- # Update the project documentation with the new version number.
6
+ # Update copyrights and project documentation for the new version.
7
7
  #
8
8
  # @parameter version [String] The new version number.
9
9
  def after_gem_release_version_increment(version)
10
+ context["modernize:license"].call
10
11
  context["releases:update"].call(version)
11
12
  context["utopia:project:update"].call
12
13
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-modernize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.61.0
4
+ version: 0.63.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file