Skip to content

Commit

Permalink
Brief form for relnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-cooper committed Aug 12, 2020
1 parent b5e8f94 commit 774e9e0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
5 changes: 3 additions & 2 deletions Rakefile
Expand Up @@ -40,13 +40,14 @@ namespace :release_notes do
# bundle exec rake release_notes:generate[$current_version,master]
# bundle exec rake release_notes:generate[v2.7.1,master]
desc 'Generate a release notes formatted document between commits'
task :generate, [:since, :target] do |_t, args|
task :generate, [:since, :target, :style] do |_t, args|
target = args.fetch(:target, 'master')
style = args.fetch(:style, 'brief')
log = ReleaseNotes::GitLogParser.run(
path: __dir__,
since: args.fetch(:since, 'master'),
target: target
)
puts ReleaseNotes::Generator.new(version: target, log: log).process
puts ReleaseNotes::Generator.new(version: target, log: log, style: style).process
end
end
38 changes: 26 additions & 12 deletions scripts/tasks/release_notes.rb
Expand Up @@ -21,12 +21,12 @@ def self.run(path:, since:, target:)
data[:desc] = desc
log << data
end
log
log.sort_by { |l| l[:pr_number].to_i }
end
end

class Generator
attr_reader :contributors, :contributions, :doc, :log, :messages, :version
attr_reader :contributors, :contributions, :doc, :log, :messages, :style, :version
ANW_URL = 'https://archivesspace.atlassian.net/browse'
PR_URL = 'https://github.com/archivesspace/archivesspace/pull'
EXCLUDE_AUTHORS = [
Expand All @@ -37,21 +37,25 @@ class Generator
'Mark Cooper',
'dependabot[bot]'
]
def initialize(version:, log:)
@contributors = Hash.new(0)
def initialize(version:, log:, style:)
@contributors = {}
@contributions = 0
@doc = []
@log = log
@messages = []
@style = style
@version = version
end

def process
log.each do |data|
contributors[data[:author]] += 1 unless EXCLUDE_AUTHORS.include?(data[:author])
unless EXCLUDE_AUTHORS.include?(data[:author])
contributors[data[:author]] = [] unless contributors.key? data[:author]
contributors[data[:author]] << data[:desc]
end
messages << format_log_entry(data)
end
@contributions = contributors.values.reduce(:+)
@contributions = contributors.map{ |_, v| v.count }.reduce(:+)
make_doc
self
end
Expand All @@ -70,9 +74,16 @@ def anw_link(anw_number)

def format_log_entry(data)
links = [pr_link(data[:pr_number]), anw_link(data[:anw_number])]
msg = "PR: #{links.compact.join(' - ')} "
msg += "by #{data[:author]} accepted on #{data[:date]}\n"
msg += "#{data[:desc]}\n"
msg = ''
if style == 'brief'
msg = "- PR: #{links.compact.join(' - ')}: #{data[:desc]}"
elsif style == 'verbose'
msg = "PR: #{links.compact.join(' - ')} "
msg += "by #{data[:author]} accepted on #{data[:date]}\n"
msg += "#{data[:desc]}\n"
else
raise "Invalid style: #{style}"
end
msg
end

Expand All @@ -88,10 +99,13 @@ def make_doc
on or after **#{DateTime.now.next_year(1).to_date}**. For more information see
the [ArchivesSpace API documentation](https://archivesspace.github.io/archivesspace/api/).\n"
doc << find_deprecations
doc << "## Other considerations (plugins etc.):\n"
doc << "__TODO: add anything else to call out here__\n"
doc << "## Community Contributions\n"
doc << "Our thanks go out to these members of the community for their code contributions: \n"
doc.concat contributors.sort_by { |k, _| k }.map { |c| "- #{c[0]}: #{c[1]}" }
doc << ''
doc << "Our thanks go out to these members of the community for their code contributions:\n"
doc.concat contributors.sort_by { |k, _| k }.map { |c|
"- #{c[0]}:\n#{c[1].map { |c| " - #{c}\n" }.join}"
}
doc << "Total community contributions accepted: #{contributions}\n"
doc << "## JIRA Tickets and Pull Requests Completed\n"
doc.concat messages
Expand Down

0 comments on commit 774e9e0

Please sign in to comment.