Skip to content

Commit 0c6bbb8

Browse files
titusfortnersandeepsuryaprasad
authored andcommitted
[build] add more context to pre-generated change logs
1 parent ed0173b commit 0c6bbb8

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

Rakefile

+19-10
Original file line numberDiff line numberDiff line change
@@ -1218,16 +1218,25 @@ end
12181218

12191219
def update_changelog(version, language, path, changelog, header)
12201220
tag = previous_tag(version, language)
1221-
log = if language == 'javascript'
1222-
`git --no-pager log #{tag}...HEAD --pretty=format:"- %s" --reverse #{path}`
1223-
else
1224-
`git --no-pager log #{tag}...HEAD --pretty=format:"* %s" --reverse #{path}`
1225-
end
1226-
commits = log.split('>>>').map { |entry|
1227-
lines = entry.split("\n")
1228-
lines.reject! { |line| line.match?(/^(----|Co-authored|Signed-off)/) || line.empty? }
1229-
lines.join("\n")
1230-
}.join("\n>>>")
1221+
bullet = language == 'javascript' ? '- ' : '* '
1222+
commit_delimiter = '===DELIM==='
1223+
tags_to_remove = /\[(dotnet|rb|py|java|js|rust)\]:?\s?/
1224+
1225+
command = "git --no-pager log #{tag}...HEAD --pretty=format:\"%s%n%b#{commit_delimiter}\" --reverse #{path}"
1226+
puts "Executing git command: #{command}"
1227+
1228+
log = `#{command}`
1229+
1230+
commits = log.split(commit_delimiter).map { |commit|
1231+
lines = commit.gsub(tags_to_remove, '').strip.lines.map(&:chomp)
1232+
subject = "#{bullet}#{lines[0]}"
1233+
1234+
body = lines[1..]
1235+
.reject { |line| line.match?(/^(----|Co-authored|Signed-off)/) || line.empty? }
1236+
.map { |line| " > #{line}" }
1237+
.join("\n")
1238+
body.empty? ? subject : "#{subject}\n#{body}"
1239+
}.join("\n")
12311240

12321241
File.open(changelog, 'r+') do |file|
12331242
new_content = "#{header}\n#{commits}\n\n#{file.read}"

0 commit comments

Comments
 (0)