Class: Schmersion::CommitParser
- Inherits:
-
Object
- Object
- Schmersion::CommitParser
- Defined in:
- lib/schmersion/commit_parser.rb
Constant Summary collapse
- MAX_COMMITS =
100_000_000
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
Instance Method Summary collapse
-
#initialize(repo, start_commit, end_commit, **options) ⇒ CommitParser
constructor
A new instance of CommitParser.
- #next_version_after(current_version, **options) ⇒ Object
- #parse ⇒ Object
- #skip_commit?(commit) ⇒ Boolean
Constructor Details
#initialize(repo, start_commit, end_commit, **options) ⇒ CommitParser
Returns a new instance of CommitParser.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/schmersion/commit_parser.rb', line 13 def initialize(repo, start_commit, end_commit, **) @start_commit = start_commit @end_commit = end_commit @options = @commits = [] if @start_commit == :start # If start is provided, use the first commit as the initial reference. # Ideally this would actually start from the beginning of time and include # this commit. first_commit = repo.log(MAX_COMMITS).last @start_commit = first_commit.sha end @raw_commits = repo.log(MAX_COMMITS).between(@start_commit, @end_commit) parse end |
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
11 12 13 |
# File 'lib/schmersion/commit_parser.rb', line 11 def commits @commits end |
Instance Method Details
#next_version_after(current_version, **options) ⇒ Object
46 47 48 49 |
# File 'lib/schmersion/commit_parser.rb', line 46 def next_version_after(current_version, **) calculator = VersionCalculator.new(current_version, commits, **) calculator.calculate end |
#parse ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/schmersion/commit_parser.rb', line 33 def parse @commits = [] @raw_commits.each do |commit| commit = Commit.new(commit) next if skip_commit?(commit) @commits << commit end @commits = @commits.reverse @commits end |
#skip_commit?(commit) ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/schmersion/commit_parser.rb', line 51 def skip_commit?(commit) # We never want to see merge commits... return true if commit.raw_commit.parents.size > 1 return true unless commit..valid? false end |