lib/helpers/git.rb in overview-0.0.5.pre.22 vs lib/helpers/git.rb in overview-0.0.6.pre.24

- old
+ new

@@ -57,23 +57,26 @@ end def self.parse_crashlytics(commitMessage) return commitMessage.scan(/(c|C):(?<crashlytics>\d+)/).flatten.collect { |x| x.to_i }.uniq end def self.parse_sprintly(commitMessage) - commands = %w(close closed closes finish finished finishes fix fixed fixes breaks unfixes reopen reopens re-open re-opens addresses re ref references refs start starts see).collect{ |x| "\\b#{x}\\b" }.join("|") - prefixes = %w(task issue defect bug item ticket).collect{ |x| "\\b#{x}:\\b" }.join("|") + "|#" - re = Regexp.new(/(?:#{commands})\s(?:#{prefixes})(\d+)/) - return commitMessage.downcase.scan(re).flatten.collect{ |x| x.to_i }.uniq + #logic from https://github.com/sprintly/sprintly-commit-parser/blob/master/sprintly_commit_parser/commit_parser.py + commandsRE = Regexp.new(/(?<action>[A-Za-z]*) ?(task|issue|defect|bug|item|ticket|:)?.?(?<ticket>(?:#|(?:ticket|issue|item|defect|bug)[: ]?)(\d+)(?:(?:[, &]*|[ ,]+?and[ ]?)(?:#|(?:ticket|issue|item|defect|bug)[: ]?)(\d+))*)/) + ticketsRE = Regexp.new(/(?:#|(?:ticket|issue|item|defect|bug)[: ]?)(\d+)/) + commands = commitMessage.downcase.scan(commandsRE) + tickets = commands.collect { |command| + command.last.scan(ticketsRE) unless command.first.empty? #only collect tickets with commands + } + return tickets.flatten.compact.collect{ |x| x.to_i }.uniq end def self.parse_commit_message(commitMessage) h = {} - deploy, message = self.parse_deploy(commitMessage) + deploy = self.parse_deploy(commitMessage) sprintly_tickets = self.parse_sprintly(commitMessage) crashlytics_ids = self.parse_crashlytics(commitMessage) - h["deploy?"] = deploy - h["message"] = message - h["sprintly"] = sprintly_tickets - h["crashlytics"] = crashlytics_ids + h[:deploy] = deploy + h[:sprintly] = sprintly_tickets + h[:crashlytics] = crashlytics_ids return h end def self.commit_sha `git rev-parse HEAD`.strip end