conventional-changelog 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +3 -0
- data/bin/conventional-changelog +4 -0
- data/conventional-changelog.gemspec +25 -0
- data/lib/conventional_changelog.rb +6 -0
- data/lib/conventional_changelog/generator.rb +49 -0
- data/lib/conventional_changelog/git.rb +16 -0
- data/spec/generator_spec.rb +108 -0
- data/spec/spec_helper.rb +4 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0dba23ec731da9e6232f288559d0e9ef5985c94
|
4
|
+
data.tar.gz: 589d787a3d640e259ee87e2bb349248cc3301c8a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d33fcf2c24912cfe6c5b011221ebf5e8e87c2dc22aa25d4fe1bb0dbab8dfcdfdf0992b7cabf065298dea628e435628b54a2da01eed7e8fdd44787be42007344
|
7
|
+
data.tar.gz: fdc03d6823f5abb87ac7f29852670c19c73cb393bd2783b26d03ea38b5edcc75b7896a470ed1efe4595821fcc6f68f04d0e23ab9b4ec2beb45df47b7f0574229
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Diego Carrion
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Conventional::Changelog
|
2
|
+
|
3
|
+
Generates a CHANGELOG.md file from Git metadata using the AngularJS commit conventions.
|
4
|
+
|
5
|
+
- [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/)
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
$ gem install conventional-changelog
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
$ conventional-changelog
|
16
|
+
|
17
|
+
or programatically:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'conventional_changelog'
|
21
|
+
ConventionalChangelog::Generator.new.generate!
|
22
|
+
```
|
23
|
+
|
24
|
+
## Examples
|
25
|
+
|
26
|
+
Converts this:
|
27
|
+
|
28
|
+
2015-03-30 feat(admin): increase reports ranges
|
29
|
+
2015-03-30 fix(api): fix annoying bug
|
30
|
+
2015-03-28 feat(api): add cool service
|
31
|
+
2015-03-28 feat(api): add cool feature
|
32
|
+
2015-03-28 feat(admin): add page to manage users
|
33
|
+
|
34
|
+
into this:
|
35
|
+
|
36
|
+
<a name="2015-03-30"></a>
|
37
|
+
### 2015-03-30
|
38
|
+
|
39
|
+
|
40
|
+
#### Features
|
41
|
+
|
42
|
+
* **admin**
|
43
|
+
* increase reports ranges (4303fd4)
|
44
|
+
|
45
|
+
|
46
|
+
#### Bug Fixes
|
47
|
+
|
48
|
+
* **api**
|
49
|
+
* fix annoying bug (4303fd5)
|
50
|
+
|
51
|
+
|
52
|
+
<a name="2015-03-28"></a>
|
53
|
+
### 2015-03-28
|
54
|
+
|
55
|
+
|
56
|
+
#### Features
|
57
|
+
|
58
|
+
* **api**
|
59
|
+
* add cool service (4303fd6)
|
60
|
+
* add cool feature (4303fd7)
|
61
|
+
|
62
|
+
* **admin**
|
63
|
+
* add page to manage users (4303fd8)
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it ( https://github.com/[my-github-username]/conventional-changelog/fork )
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'conventional_changelog'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "conventional-changelog"
|
8
|
+
spec.version = ConventionalChangelog::VERSION
|
9
|
+
spec.authors = ["Diego Carrion"]
|
10
|
+
spec.email = ["dc.rec1@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby binary to generate a conventional changelog — Edit}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.2"
|
24
|
+
spec.add_development_dependency "fakefs"
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ConventionalChangelog
|
2
|
+
class Generator
|
3
|
+
def generate!
|
4
|
+
File.open("CHANGELOG.md", "w") do |file|
|
5
|
+
write_new_lines_to file
|
6
|
+
file.puts previous_body
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def write_new_lines_to(f)
|
13
|
+
Git.commits(since: last_date).group_by { |commit| commit[:date] }.sort.reverse.each do |date, commits|
|
14
|
+
f.puts version_header(date)
|
15
|
+
append_changes f, commits, "feat", "Features"
|
16
|
+
append_changes f, commits, "fix", "Bug Fixes"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def last_date
|
21
|
+
previous_body == "" ? nil : previous_body.split("\n")[0].to_s.match(/"(.*)"/)[1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def previous_body
|
25
|
+
@previous_body ||= File.open("CHANGELOG.md", "a+").read
|
26
|
+
end
|
27
|
+
|
28
|
+
def version_header(date)
|
29
|
+
<<-HEADER
|
30
|
+
<a name="#{date}"></a>
|
31
|
+
### #{date}
|
32
|
+
|
33
|
+
|
34
|
+
HEADER
|
35
|
+
end
|
36
|
+
|
37
|
+
def append_changes(f, commits, type, title)
|
38
|
+
unless (type_commits = commits.select { |commit| commit[:type] == type }).empty?
|
39
|
+
f.puts "#### #{title}", ""
|
40
|
+
type_commits.group_by { |commit| commit[:component] }.each do |component, commits|
|
41
|
+
f.puts "* **#{component}**"
|
42
|
+
commits.each { |commit| f.puts " * #{commit[:change]} (#{commit[:id]})" }
|
43
|
+
f.puts ""
|
44
|
+
end
|
45
|
+
f.puts ""
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ConventionalChangelog
|
2
|
+
class Git
|
3
|
+
DELIMITER = "/////"
|
4
|
+
|
5
|
+
def self.commits(since:)
|
6
|
+
log.split("\n").map { |commit| commit.split DELIMITER }.select { |commit| since.nil? or commit[1] > since }.map do |commit|
|
7
|
+
comment = commit[2].match(/(.*)\((.*)\): (.*)/)
|
8
|
+
{ id: commit[0], date: commit[1], type: comment[1], component: comment[2], change: comment[3] }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.log
|
13
|
+
`git log --pretty=format:'%h#{DELIMITER}%ad#{DELIMITER}%s%x09' --date=short --grep='^(feat|fix)\\(' -E`
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ConventionalChangelog::Generator do
|
4
|
+
describe "#generate!" do
|
5
|
+
context "with no commits" do
|
6
|
+
before :each do
|
7
|
+
allow(ConventionalChangelog::Git).to receive(:log).and_return ""
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates an empty changelog when no commits' do
|
11
|
+
subject.generate!
|
12
|
+
expect(File.open("CHANGELOG.md").read).to eql "\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with multiple commits" do
|
17
|
+
before :each do
|
18
|
+
log = <<-LOG
|
19
|
+
4303fd4/////2015-03-30/////feat(admin): increase reports ranges
|
20
|
+
4303fd5/////2015-03-30/////fix(api): fix annoying bug
|
21
|
+
4303fd6/////2015-03-28/////feat(api): add cool service
|
22
|
+
4303fd7/////2015-03-28/////feat(api): add cool feature
|
23
|
+
4303fd8/////2015-03-28/////feat(admin): add page to manage users
|
24
|
+
LOG
|
25
|
+
allow(ConventionalChangelog::Git).to receive(:log).and_return log
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'parses simple lines into dates' do
|
29
|
+
subject.generate!
|
30
|
+
body = <<-BODY
|
31
|
+
<a name="2015-03-30"></a>
|
32
|
+
### 2015-03-30
|
33
|
+
|
34
|
+
|
35
|
+
#### Features
|
36
|
+
|
37
|
+
* **admin**
|
38
|
+
* increase reports ranges (4303fd4)
|
39
|
+
|
40
|
+
|
41
|
+
#### Bug Fixes
|
42
|
+
|
43
|
+
* **api**
|
44
|
+
* fix annoying bug (4303fd5)
|
45
|
+
|
46
|
+
|
47
|
+
<a name="2015-03-28"></a>
|
48
|
+
### 2015-03-28
|
49
|
+
|
50
|
+
|
51
|
+
#### Features
|
52
|
+
|
53
|
+
* **api**
|
54
|
+
* add cool service (4303fd6)
|
55
|
+
* add cool feature (4303fd7)
|
56
|
+
|
57
|
+
* **admin**
|
58
|
+
* add page to manage users (4303fd8)
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
BODY
|
63
|
+
expect(File.open("CHANGELOG.md").read).to eql body
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'preserves previous changes' do
|
67
|
+
previous_body = <<-BODY
|
68
|
+
<a name="2015-03-28"></a>
|
69
|
+
### 2015-03-28
|
70
|
+
|
71
|
+
|
72
|
+
#### Features
|
73
|
+
|
74
|
+
* **api**
|
75
|
+
* add cool service (4303fd6)
|
76
|
+
* add cool feature (4303fd7)
|
77
|
+
|
78
|
+
* **admin**
|
79
|
+
* add page to manage users (4303fd8)
|
80
|
+
|
81
|
+
BODY
|
82
|
+
File.open("CHANGELOG.md", "w") { |f| f.puts previous_body }
|
83
|
+
body = <<-BODY
|
84
|
+
<a name="2015-03-30"></a>
|
85
|
+
### 2015-03-30
|
86
|
+
|
87
|
+
|
88
|
+
#### Features
|
89
|
+
|
90
|
+
* **admin**
|
91
|
+
* increase reports ranges (4303fd4)
|
92
|
+
|
93
|
+
|
94
|
+
#### Bug Fixes
|
95
|
+
|
96
|
+
* **api**
|
97
|
+
* fix annoying bug (4303fd5)
|
98
|
+
|
99
|
+
|
100
|
+
#{previous_body}
|
101
|
+
|
102
|
+
BODY
|
103
|
+
subject.generate!
|
104
|
+
expect(File.open("CHANGELOG.md").read).to eql body
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conventional-changelog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Carrion
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fakefs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- dc.rec1@gmail.com
|
72
|
+
executables:
|
73
|
+
- conventional-changelog
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/conventional-changelog
|
83
|
+
- conventional-changelog.gemspec
|
84
|
+
- lib/conventional_changelog.rb
|
85
|
+
- lib/conventional_changelog/generator.rb
|
86
|
+
- lib/conventional_changelog/git.rb
|
87
|
+
- spec/generator_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: ''
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Ruby binary to generate a conventional changelog — Edit
|
113
|
+
test_files:
|
114
|
+
- spec/generator_spec.rb
|
115
|
+
- spec/spec_helper.rb
|