Class: ChangesSince::CommitParser
- Inherits:
-
Object
- Object
- ChangesSince::CommitParser
- Defined in:
- lib/changes_since/commit_parser.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(tag, options) ⇒ CommitParser
constructor
A new instance of CommitParser.
- #parse ⇒ Object
- #parse_all_commits ⇒ Object
Constructor Details
#initialize(tag, options) ⇒ CommitParser
Returns a new instance of CommitParser.
7 8 9 10 11 |
# File 'lib/changes_since/commit_parser.rb', line 7 def initialize(tag, ) git = Git.open(Dir.pwd) @log = git.log(100000).between(tag) @options = end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
5 6 7 |
# File 'lib/changes_since/commit_parser.rb', line 5 def log @log end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/changes_since/commit_parser.rb', line 5 def @options end |
Instance Method Details
#parse ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/changes_since/commit_parser.rb', line 42 def parse commits = if [:all] parse_all_commits else log.select { |commit| commit. =~ /Merge pull request/ } end if [:author_filter] = /#{[:author_filter].join("|")}/i commits = commits.select do |commit| [commit..name, commit..email].any? do |str| str =~ end end end commits end |
#parse_all_commits ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/changes_since/commit_parser.rb', line 13 def parse_all_commits interesting = Set.new all_commits = log.to_a link_re = /^\s*\[(.*?)\]/m linked_commits, remaining_commits = all_commits.partition do |commit| commit. =~ link_re end linked_commits.uniq! do |commit| commit.[link_re,1] end interesting = interesting + linked_commits interesting_re = / (?:\#(bug|public|internal)) | # anything explicitly tagged (?:closes\s\#\d+) | # a squash-merge commit closing the linked PR (?:Merge\spull\srequest) # a straight PR merge /xmi remaining_commits.each do |commit| if commit. =~ interesting_re interesting << commit end end commits = interesting.to_a end |