changelog-rb 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/changelog/0.1.1/added_show_script.yml +4 -0
- data/changelog/0.1.1/support_date_option_for_tag_command.yml +4 -0
- data/changelog/0.1.1/tag.yml +1 -0
- data/lib/changelog-rb.rb +1 -0
- data/lib/changelog/cli.rb +11 -1
- data/lib/changelog/helpers/changes.rb +46 -0
- data/lib/changelog/print.rb +7 -36
- data/lib/changelog/show.rb +22 -0
- data/lib/changelog/tag.rb +2 -2
- data/lib/changelog/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4fe9745c044a09676d9afd807291f41fdbdc615
|
4
|
+
data.tar.gz: '039689a6b3b8189a2e923c0339aaaf7589938784'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81598ba10ac219d95e0429c057045c4e381295c757b3d48b665c08d31ed09560fb5873ba9dd4296f71eef760d763bbda255cd3da38d92278f3b31cb5eb36a2ed
|
7
|
+
data.tar.gz: 0dad477768fa74970a0d3860b13f7b1b6acdceec294cec8bd82d703de58b60d7c2699f67bc4d3b39d5ce2c8a7906c8fb6077a735cbd9882fc4d93ccf04846922
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
date: 2017-09-18
|
data/lib/changelog-rb.rb
CHANGED
data/lib/changelog/cli.rb
CHANGED
@@ -39,8 +39,13 @@ module Changelog
|
|
39
39
|
end
|
40
40
|
|
41
41
|
desc 'tag VERSION', 'Tag the unreleased changes to a version'
|
42
|
+
method_option :date,
|
43
|
+
type: :string,
|
44
|
+
desc: 'Date of release. Default: Today',
|
45
|
+
lazy_default: nil,
|
46
|
+
aliases: %w(-d)
|
42
47
|
def tag(version)
|
43
|
-
Changelog::Tag.new.go(version)
|
48
|
+
Changelog::Tag.new.go(version, options.symbolize_keys)
|
44
49
|
end
|
45
50
|
|
46
51
|
desc 'untag VERSION', 'Moved the changes from version folder to unreleased'
|
@@ -48,6 +53,11 @@ module Changelog
|
|
48
53
|
Changelog::Untag.new.go(version)
|
49
54
|
end
|
50
55
|
|
56
|
+
desc 'show VERSION', 'Print changes of VERSION'
|
57
|
+
def show(version)
|
58
|
+
Changelog::Show.new.go(version)
|
59
|
+
end
|
60
|
+
|
51
61
|
desc 'print', 'Print ./changelog to CHANGELOG.md'
|
52
62
|
def print
|
53
63
|
Changelog::Print.new.go
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Changelog
|
4
|
+
module Helpers
|
5
|
+
module Changes
|
6
|
+
def version_header(folder)
|
7
|
+
if folder == "unreleased"
|
8
|
+
"## [Unreleased]\n"
|
9
|
+
else
|
10
|
+
meta = YAML.load_file(File.join(destination_root, "changelog/#{folder}/tag.yml"))
|
11
|
+
date = meta['date'].to_s
|
12
|
+
"## [#{folder}] - #{date}\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def read_changes(folder)
|
17
|
+
items = {}
|
18
|
+
changelog_files(folder).each do |file|
|
19
|
+
yaml = YAML.load_file(file)
|
20
|
+
items[yaml['type']] ||= []
|
21
|
+
items[yaml['type']] << "#{yaml['title'].strip} (@#{yaml['author']})"
|
22
|
+
end
|
23
|
+
|
24
|
+
sections = []
|
25
|
+
Changelog.natures.each.with_index do |nature, i|
|
26
|
+
if changes = items[nature].presence
|
27
|
+
lines = []
|
28
|
+
lines << "### #{nature}\n"
|
29
|
+
changes.each do |change|
|
30
|
+
lines << "- #{change}\n"
|
31
|
+
end
|
32
|
+
sections << lines.join
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sections.join("\n")
|
37
|
+
end
|
38
|
+
|
39
|
+
def changelog_files(folder)
|
40
|
+
Dir[File.join(destination_root, "changelog/#{folder}/*.yml")] - [
|
41
|
+
File.join(destination_root, "changelog/#{folder}/tag.yml")
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/changelog/print.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'yaml'
|
3
3
|
require 'semantic'
|
4
|
+
require 'changelog/helpers/changes'
|
4
5
|
|
5
6
|
module Changelog
|
6
7
|
class Print < Thor
|
7
8
|
include Thor::Actions
|
8
9
|
|
9
10
|
no_commands do
|
11
|
+
include Changelog::Helpers::Changes
|
12
|
+
|
10
13
|
def go
|
11
14
|
remove_file 'CHANGELOG.md'
|
12
15
|
add_file 'CHANGELOG.md'
|
13
16
|
|
14
|
-
append_to_file 'CHANGELOG.md', "# Changelog\n
|
15
|
-
|
16
|
-
shell.say_status :append, "changes in changelog/unreleased", :green unless shell.mute?
|
17
|
-
append_to_file 'CHANGELOG.md', "## [Unreleased]\n", verbose: false
|
18
|
-
print_changes 'unreleased'
|
17
|
+
append_to_file 'CHANGELOG.md', "# Changelog\n", verbose: false
|
19
18
|
|
20
|
-
version_folders.each do |version|
|
19
|
+
%w[unreleased].concat(version_folders).each do |version|
|
21
20
|
shell.say_status :append, "changes in changelog/#{version}", :green unless shell.mute?
|
22
21
|
print_version_header version
|
23
22
|
print_changes version
|
@@ -26,33 +25,11 @@ module Changelog
|
|
26
25
|
|
27
26
|
def print_version_header(folder)
|
28
27
|
append_to_file 'CHANGELOG.md', "\n", verbose: false, force: true
|
29
|
-
|
30
|
-
meta = YAML.load_file(File.join(destination_root, "changelog/#{folder}/tag.yml"))
|
31
|
-
date = meta['date'].to_s
|
32
|
-
append_to_file 'CHANGELOG.md', "## [#{folder}] - #{date}\n", verbose: false
|
28
|
+
append_to_file 'CHANGELOG.md', version_header(folder), verbose: false
|
33
29
|
end
|
34
30
|
|
35
31
|
def print_changes(folder)
|
36
|
-
|
37
|
-
changelog_files(folder).each do |file|
|
38
|
-
yaml = YAML.load_file(file)
|
39
|
-
items[yaml['type']] ||= []
|
40
|
-
items[yaml['type']] << "#{yaml['title'].strip} (@#{yaml['author']})"
|
41
|
-
end
|
42
|
-
|
43
|
-
sections = []
|
44
|
-
Changelog.natures.each.with_index do |nature, i|
|
45
|
-
if changes = items[nature].presence
|
46
|
-
lines = []
|
47
|
-
lines << "### #{nature}\n"
|
48
|
-
changes.each do |change|
|
49
|
-
lines << "- #{change}\n"
|
50
|
-
end
|
51
|
-
sections << lines.join
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
append_to_file 'CHANGELOG.md', sections.join("\n"), verbose: false, force: true
|
32
|
+
append_to_file 'CHANGELOG.md', read_changes(folder), verbose: false, force: true
|
56
33
|
end
|
57
34
|
|
58
35
|
def version_folders
|
@@ -60,12 +37,6 @@ module Changelog
|
|
60
37
|
File.join(destination_root, "changelog/unreleased")
|
61
38
|
]).collect {|path| File.basename(path)}.sort_by {|version| Semantic::Version.new(version)}.reverse
|
62
39
|
end
|
63
|
-
|
64
|
-
def changelog_files(folder)
|
65
|
-
Dir[File.join(destination_root, "changelog/#{folder}/*.yml")] - [
|
66
|
-
File.join(destination_root, "changelog/#{folder}/tag.yml")
|
67
|
-
]
|
68
|
-
end
|
69
40
|
end
|
70
41
|
end
|
71
42
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yaml'
|
3
|
+
require 'changelog/helpers/changes'
|
4
|
+
|
5
|
+
module Changelog
|
6
|
+
class Show < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
no_commands do
|
10
|
+
include Changelog::Helpers::Changes
|
11
|
+
|
12
|
+
def go(version)
|
13
|
+
if File.exists?(File.join(destination_root, "changelog/#{version}"))
|
14
|
+
puts version_header(version)
|
15
|
+
puts read_changes(version)
|
16
|
+
else
|
17
|
+
say "changelog/#{version} not found"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/changelog/tag.rb
CHANGED
@@ -9,9 +9,9 @@ module Changelog
|
|
9
9
|
end
|
10
10
|
|
11
11
|
no_commands do
|
12
|
-
def go(version)
|
12
|
+
def go(version, date: nil)
|
13
13
|
@version = version
|
14
|
-
@date = Date.today.to_s
|
14
|
+
@date = date || Date.today.to_s
|
15
15
|
|
16
16
|
empty_directory "changelog/#{@version}"
|
17
17
|
template 'tag.yml', "changelog/#{@version}/tag.yml"
|
data/lib/changelog/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changelog-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pinglamb
|
@@ -136,15 +136,20 @@ files:
|
|
136
136
|
- changelog/0.1.0/make_print_supports_version_folders.yml
|
137
137
|
- changelog/0.1.0/support_getting_title_from_git_commit.yml
|
138
138
|
- changelog/0.1.0/tag.yml
|
139
|
+
- changelog/0.1.1/added_show_script.yml
|
140
|
+
- changelog/0.1.1/support_date_option_for_tag_command.yml
|
141
|
+
- changelog/0.1.1/tag.yml
|
139
142
|
- changelog/unreleased/.gitkeep
|
140
143
|
- exe/changelog
|
141
144
|
- lib/changelog-rb.rb
|
142
145
|
- lib/changelog/add.rb
|
143
146
|
- lib/changelog/cli.rb
|
147
|
+
- lib/changelog/helpers/changes.rb
|
144
148
|
- lib/changelog/helpers/git.rb
|
145
149
|
- lib/changelog/helpers/shell.rb
|
146
150
|
- lib/changelog/print.rb
|
147
151
|
- lib/changelog/setup.rb
|
152
|
+
- lib/changelog/show.rb
|
148
153
|
- lib/changelog/tag.rb
|
149
154
|
- lib/changelog/untag.rb
|
150
155
|
- lib/changelog/version.rb
|