Class: ConventionalChangelog::Git
- Inherits:
-
Object
- Object
- ConventionalChangelog::Git
- Defined in:
- lib/conventional_changelog/git.rb
Constant Summary collapse
- DELIMITER =
"/////"
Class Method Summary collapse
Class Method Details
.commits(options) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/conventional_changelog/git.rb', line 7 def self.commits() log().split("\n").map { |commit| commit.split DELIMITER }.select { |commit| [:since_date].nil? or commit[1] > [:since_date] }.map do |commit| comment = commit[2].match(/(\w*)(\(([\w\$\.\-\* ]*)\))?\: (.*)/) next unless comment { id: commit[0], date: commit[1], type: comment[1], component: comment[3], change: comment[4] } end.compact end |
.log(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/conventional_changelog/git.rb', line 15 def self.log() output, status = Open3.capture2(%Q{ git log \ --pretty=format:"%h#{DELIMITER}%ad#{DELIMITER}%s%x09" --date=short \ --grep="^(feat|fix)(\\(.*\\))?:" -E \ #{version_filter()} }) if status.success? output else raise "Can't load Git commits, check your arguments" end end |
.version_filter(options) ⇒ Object
30 31 32 |
# File 'lib/conventional_changelog/git.rb', line 30 def self.version_filter() [:since_version] ? "#{[:since_version]}..HEAD" : "" end |