OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix rubocop violations in copyright_authors.rake
Ivan Kuchin83904c96c214
diff --git a/lib/tasks/copyright_authors.rake b/lib/tasks/copyright_authors.rakeindex 9e54370af65..5f10190ae89 100644--- a/lib/tasks/copyright_authors.rake+++ b/lib/tasks/copyright_authors.rake@@ -26,6 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#+++# rubocop:disable Rails/RakeEnvironmentnamespace :copyright donamespace :authors dodesc "Shows contributors of a repository"@@ -38,30 +39,30 @@ namespace :copyright doprivate- CONTRIBUTION = Struct.new(:author, :date)- CONTRIBUTION_PERIOD = Struct.new(:author, :begin, :end)+ def contributions_of_repository(path)+ contribution_info = Data.define(:author, :date)- CONTRIBUTION_REGEX = /^(?<date>\d\d\d\d-\d\d-\d\d) (?<author>.*)$/-- def contribution_periods_of_repository(path)- contributions = []- contribution_periods = []path = "." if path.nil?log = `git --git-dir #{path}/.git log --date=short --pretty=format:"%ad %aN"`- log.scan(CONTRIBUTION_REGEX).each do |m|- contributions << CONTRIBUTION.new(m[1], Date.parse(m[0]))+ log.scan(/^(?<date>\d\d\d\d-\d\d-\d\d) (?<author>.*)$/).map do |m|+ contribution_info.new(m[1], Date.parse(m[0]))end+ end- authors = contributions.collect(&:author).uniq+ def contribution_periods_of_repository(path)+ contribution_period = Data.define(:author, :begin, :end)- authors.each do |a|- first, last = contributions.select { |c| c.author == a }- .minmax_by(&:date)- contribution_periods << CONTRIBUTION_PERIOD.new(a, first.date.year, last.date.year)- end+ contribution_periods = contributions_of_repository(path)+ .group_by(&:author).map do |author, author_contributions|+ first, last = author_contributions.map { |c| c.date.year }.minmax++ contribution_period.new(author, first, last)+ end- contribution_periods.sort_by { |c| [c.end, c.begin] }.reverse+ contribution_periods+ .sort_by { |c| [c.end, c.begin] }+ .reverseenddef format_contribution_periods(contribution_periods)@@ -79,3 +80,4 @@ namespace :copyright doendendend+# rubocop:enable Rails/RakeEnvironment