Skip to content

Commit

Permalink
[DOC] Update changelogse.rake
Browse files Browse the repository at this point in the history
- Exclude CI-skipped commits from changelogs
- Make timestamps in a ISO 8601-like format
  • Loading branch information
nobu committed Apr 17, 2024
1 parent 1167731 commit 8d33e4c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rakelib/changelogs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ task "build" => "changelogs"
changelog = proc do |output, ver = nil, prev = nil|
ver &&= Gem::Version.new(ver)
range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..")
IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log|
cmd = %W[git log --date=iso --format=fuller --topo-order --no-merges
--invert-grep --fixed-strings --grep=#{'[ci skip]'}
#{range} --]
IO.popen(cmd) do |log|
line = log.gets
FileUtils.mkpath(File.dirname(output))
File.open(output, "wb") do |f|
Expand All @@ -18,13 +21,13 @@ changelog = proc do |output, ver = nil, prev = nil|
end

tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1}
tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)}
if !tags.empty? and IO.popen(%W[git log --format=%H v#{tags.last}..HEAD], &:read).empty?
tags.pop
end
tags.inject(nil) do |prev, tag|
task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]}
tag
unless tags.empty?
tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)}
tags.pop if IO.popen(%W[git log --format=%H v#{tags.last}..HEAD --], &:read).empty?
tags.inject(nil) do |prev, tag|
task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]}
tag
end
end

desc "Make ChangeLog"
Expand Down

0 comments on commit 8d33e4c

Please sign in to comment.