create_changelog 1.1.0 → 1.2.0
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 +10 -0
- data/README.md +6 -0
- data/bin/ccl +9 -3
- data/bin/ccl~ +10 -3
- data/lib/create_changelog.rb +3 -0
- data/lib/create_changelog.rb~ +77 -0
- data/lib/version.rb +1 -1
- data/lib/version.rb~ +1 -1
- metadata +2 -3
- data/lib/changelog_filter.rb~ +0 -57
- data/lib/git.rb~ +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb6680237cbad0391a0726ceb5bcb78dc4a53c9
|
4
|
+
data.tar.gz: caf83089dd06505fcd8acb43f17f0b5e587f9829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22bc16e610025ba7d66e02552327c0e17e0271af8f550a7fd425dbf6e8b5fb914ddaf1b02c427aeca65f9354cdbd4fd85d2b860e317f4bb1e34bfb1b47f22efe
|
7
|
+
data.tar.gz: ce631d8ff2693ab82f0946a6d9662dd98b521bd1341e4d2a87a5fd94464e3180cd5f1dbc26d23ff280fd66432b929806b2b32c75978b5520eb13547dfd5d4dd1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Version 1.2.0 (2015-01-18)
|
2
|
+
========================================================================
|
3
|
+
|
4
|
+
- FIX: Make "-r", "--recent" option actually work.
|
5
|
+
- FIX: Prevent combining -n and -r switch irrespective of order.
|
6
|
+
- NEW: Switch "-v", "--version" to print out the current version.
|
7
|
+
|
8
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
9
|
+
|
10
|
+
|
1
11
|
Version 1.1.0 (2015-01-18)
|
2
12
|
========================================================================
|
3
13
|
|
data/README.md
CHANGED
@@ -112,6 +112,8 @@ Live example
|
|
112
112
|
|
113
113
|
<http://xltoolbox.sf.net/changelog-ng>
|
114
114
|
|
115
|
+
... or of course [CHANGELOG.md][] in this repository.
|
116
|
+
|
115
117
|
|
116
118
|
Code
|
117
119
|
----
|
@@ -119,6 +121,9 @@ Code
|
|
119
121
|
To understand the code, you can run `rdoc` in the repository's
|
120
122
|
directory. The resulting `doc` subdirectory will be ignored by Git.
|
121
123
|
|
124
|
+
Alternatively, you may browse
|
125
|
+
<http://www.rubydoc.info/github/bovender/create-changelog>.
|
126
|
+
|
122
127
|
|
123
128
|
License
|
124
129
|
-------
|
@@ -142,5 +147,6 @@ License
|
|
142
147
|
[pandoc]: http://johnmacfarlane.net/pandoc
|
143
148
|
[nanoc]: http://nanoc.ws
|
144
149
|
[kacl]: http://keepachangelog.com
|
150
|
+
[CHANGELOG.md]: CHANGELOG.md
|
145
151
|
|
146
152
|
<!-- vim: set tw=72 : -->
|
data/bin/ccl
CHANGED
@@ -28,26 +28,32 @@ def main
|
|
28
28
|
working_dir = Dir.pwd
|
29
29
|
option_parser = OptionParser.new do |opts|
|
30
30
|
exe_name = File.basename($PROGRAM_NAME)
|
31
|
-
opts.banner = "
|
31
|
+
opts.banner = "create_changelog version #{CreateChangelog::VERSION}\n"
|
32
32
|
opts.banner += "Creates changelog from log entries in git log\n"
|
33
33
|
opts.banner += "Usage: #{exe_name} [options] [current_version]"
|
34
34
|
opts.on("-r", "--recent",
|
35
35
|
"Include only most recent changes") do
|
36
|
-
abort "FATAL: Cannot combine --recent and --no-recent" if options[:no_recent]
|
37
36
|
options[:only_recent] = true
|
38
37
|
end
|
39
38
|
opts.on("-n", "--no-recent",
|
40
39
|
"Exclude the most recent changes (from untagged commits)") do
|
41
|
-
abort "FATAL: Cannot combine --recent and --no-recent" if options[:recent]
|
42
40
|
options[:no_recent] = true
|
43
41
|
end
|
44
42
|
opts.on("-d WORKING_DIR", "--dir WORKING_DIR",
|
45
43
|
"Use alternate working directory") do |dir|
|
46
44
|
working_dir = dir
|
47
45
|
end
|
46
|
+
opts.on("-v", "--version", "Print version information and exit.") do
|
47
|
+
puts CreateChangelog::VERSION
|
48
|
+
exit
|
49
|
+
end
|
48
50
|
end
|
49
51
|
option_parser.parse!
|
50
52
|
|
53
|
+
if options[:no_recent] and options[:only_recent]
|
54
|
+
abort "FATAL: Cannot combine --recent and --no-recent"
|
55
|
+
end
|
56
|
+
|
51
57
|
Dir.chdir(working_dir) do
|
52
58
|
abort "FATAL: Not a git repository." unless Git.is_git_repository?
|
53
59
|
|
data/bin/ccl~
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
# The filtered lines are sorted and written to standard out.
|
20
20
|
|
21
21
|
require 'optparse'
|
22
|
-
require_relative '../lib/
|
22
|
+
require_relative '../lib/create_changelog.rb'
|
23
23
|
require_relative '../lib/git.rb'
|
24
24
|
require_relative '../lib/version.rb'
|
25
25
|
|
@@ -28,7 +28,7 @@ def main
|
|
28
28
|
working_dir = Dir.pwd
|
29
29
|
option_parser = OptionParser.new do |opts|
|
30
30
|
exe_name = File.basename($PROGRAM_NAME)
|
31
|
-
opts.banner = "
|
31
|
+
opts.banner = "create_changelog version #{CreateChangelog::VERSION}\n"
|
32
32
|
opts.banner += "Creates changelog from log entries in git log\n"
|
33
33
|
opts.banner += "Usage: #{exe_name} [options] [current_version]"
|
34
34
|
opts.on("-r", "--recent",
|
@@ -38,16 +38,23 @@ def main
|
|
38
38
|
end
|
39
39
|
opts.on("-n", "--no-recent",
|
40
40
|
"Exclude the most recent changes (from untagged commits)") do
|
41
|
-
abort "FATAL: Cannot combine --recent and --no-recent" if options[:recent]
|
42
41
|
options[:no_recent] = true
|
43
42
|
end
|
44
43
|
opts.on("-d WORKING_DIR", "--dir WORKING_DIR",
|
45
44
|
"Use alternate working directory") do |dir|
|
46
45
|
working_dir = dir
|
47
46
|
end
|
47
|
+
opts.on("-v", "--version", "Print version information and exit.") do
|
48
|
+
puts CreateChangelog::VERSION
|
49
|
+
exit
|
50
|
+
end
|
48
51
|
end
|
49
52
|
option_parser.parse!
|
50
53
|
|
54
|
+
if options[:no_recent] and options[:only_recent]
|
55
|
+
abort "FATAL: Cannot combine --recent and --no-recent" if options[:recent]
|
56
|
+
end
|
57
|
+
|
51
58
|
Dir.chdir(working_dir) do
|
52
59
|
abort "FATAL: Not a git repository." unless Git.is_git_repository?
|
53
60
|
|
data/lib/create_changelog.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# changelog.rb, part of Create-changelog
|
2
|
+
# Copyright 2015 Daniel Kraus
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
require_relative './commit_changelog.rb'
|
15
|
+
require_relative './tag_list.rb'
|
16
|
+
require_relative './tag.rb'
|
17
|
+
|
18
|
+
# Central class that puts together the changelog.
|
19
|
+
class Changelog
|
20
|
+
# Heading for the most recent changes.
|
21
|
+
attr_writer :recent_changes_heading
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@recent_changes_heading = "Unpublished changes"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Generates a decorated changelog.
|
28
|
+
def generate(exclude_recent = false)
|
29
|
+
# Traverse tags
|
30
|
+
tags = TagList.new(!exclude_recent)
|
31
|
+
output = String.new
|
32
|
+
tags.list.each_cons(2) do |current_tag, previous_tag|
|
33
|
+
output << generate_for(current_tag, previous_tag)
|
34
|
+
end
|
35
|
+
output
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns a simple, undecorated list of changelog entries
|
39
|
+
# since the most recent tag.
|
40
|
+
def generate_recent
|
41
|
+
tags = TagList.new
|
42
|
+
log = CommitChangelog.new(tags.list[0], tags.list[1])
|
43
|
+
log.changelog.inspect
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def generate_for(current_tag, previous_tag)
|
49
|
+
tag = Tag.new(current_tag)
|
50
|
+
commit_changelog = CommitChangelog.new(current_tag, previous_tag)
|
51
|
+
|
52
|
+
# Combine changelog entries from tag annotation and commit messages
|
53
|
+
if tag.changelog
|
54
|
+
combined_changelog = tag.changelog.concat(commit_changelog.changelog)
|
55
|
+
else
|
56
|
+
combined_changelog = commit_changelog.changelog
|
57
|
+
end
|
58
|
+
combined_changelog.uniq! if combined_changelog
|
59
|
+
|
60
|
+
output = String.new
|
61
|
+
tag.heading = @recent_changes_heading unless tag.heading
|
62
|
+
if tag.heading
|
63
|
+
output << tag.heading + " (#{tag.date})\n"
|
64
|
+
output << "=" * 72 + "\n"
|
65
|
+
end
|
66
|
+
output << tag.text.join("\n") + "\n" if tag.text
|
67
|
+
output << combined_changelog.join("\n") + "\n" if combined_changelog
|
68
|
+
output << end_separator if tag.heading or tag.text or combined_changelog
|
69
|
+
output
|
70
|
+
end
|
71
|
+
|
72
|
+
def end_separator
|
73
|
+
"\n" + ("* " * 36) +"\n\n\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# vim: nospell
|
data/lib/version.rb
CHANGED
data/lib/version.rb~
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_changelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kraus
|
@@ -24,11 +24,10 @@ files:
|
|
24
24
|
- bin/ccl~
|
25
25
|
- lib/array.rb
|
26
26
|
- lib/changelog_filter.rb
|
27
|
-
- lib/changelog_filter.rb~
|
28
27
|
- lib/commit_changelog.rb
|
29
28
|
- lib/create_changelog.rb
|
29
|
+
- lib/create_changelog.rb~
|
30
30
|
- lib/git.rb
|
31
|
-
- lib/git.rb~
|
32
31
|
- lib/tag.rb
|
33
32
|
- lib/tag_list.rb
|
34
33
|
- lib/version.rb
|
data/lib/changelog_filter.rb~
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# changelog_filter.rb, part of Create-changelog
|
2
|
-
# Copyright 2015 Daniel Kraus
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require_relative 'array'
|
16
|
-
|
17
|
-
# Filters a text or array for changelog entries.
|
18
|
-
class ChangelogFilter
|
19
|
-
# Factory method that creates an instance given a text string
|
20
|
-
def self.FromString(string)
|
21
|
-
unless string.is_a?(String)
|
22
|
-
fail "Must call this factory with String, not " + string.class.to_s
|
23
|
-
end
|
24
|
-
self.FromArray(string.chomp.split("\n"))
|
25
|
-
end
|
26
|
-
|
27
|
-
# Factory method that creates an instance given an array of strings
|
28
|
-
def self.FromArray(ary)
|
29
|
-
unless ary.is_a?(Array)
|
30
|
-
fail "Must call this factory with Array, not " + ary.class.to_s
|
31
|
-
end
|
32
|
-
filter = ChangelogFilter.new
|
33
|
-
log, filter.other_text = ary.partition do |line|
|
34
|
-
line.match(pattern)
|
35
|
-
end
|
36
|
-
filter.changelog = log.uniq.sort.remove_indent if log.length > 0
|
37
|
-
filter
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns the grep string that matches changelog entries.
|
41
|
-
def self.pattern
|
42
|
-
'\s*\*\s+[^:]+:\s'
|
43
|
-
end
|
44
|
-
|
45
|
-
# An array of changelog entries.
|
46
|
-
attr_accessor :changelog
|
47
|
-
|
48
|
-
# An array of text lines that are not changelog entries.
|
49
|
-
attr_accessor :other_text
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def initialize
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# vim: nospell
|
data/lib/git.rb~
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# git.rb, part of Create-changelog
|
2
|
-
# Copyright 2015 Daniel Kraus
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require_relative 'tag_list'
|
15
|
-
|
16
|
-
# A static wrapper class for git
|
17
|
-
class Git
|
18
|
-
|
19
|
-
# Determines whether the (current) directory is a git repository
|
20
|
-
def self.is_git_repository?(dir = nil)
|
21
|
-
dir = Dir.pwd if dir.nil?
|
22
|
-
system("git status > /dev/null 2>&1")
|
23
|
-
$? == 0
|
24
|
-
end
|
25
|
-
|
26
|
-
# Retrieves the first 99 lines of the annotation of a tag.
|
27
|
-
def self.get_tag_annotation(tag)
|
28
|
-
test_tag tag
|
29
|
-
`git tag -l -n99 #{tag}`.rstrip
|
30
|
-
end
|
31
|
-
|
32
|
-
# Retrieves the date of a tag
|
33
|
-
def self.get_tag_date(tag)
|
34
|
-
test_tag tag
|
35
|
-
`git log -1 --format=format:%ai #{tag}`
|
36
|
-
end
|
37
|
-
|
38
|
-
# Retrieves commit messages and filters them
|
39
|
-
# Todo: Armor this against code injection!
|
40
|
-
def self.get_filtered_messages(from_commit, to_commit, filter)
|
41
|
-
`git log #{from_commit}..#{to_commit} -E --grep='#{filter}' --format=%b`
|
42
|
-
end
|
43
|
-
|
44
|
-
@@tags = nil
|
45
|
-
|
46
|
-
def self.tags
|
47
|
-
@@tags = TagList.new unless @@tags
|
48
|
-
@@tags
|
49
|
-
end
|
50
|
-
|
51
|
-
# Tests if the given tag exists and fails if it doesn't
|
52
|
-
def self.test_tag(tag)
|
53
|
-
fail "Invalid tag: #{tag}" unless tags.list.include?(tag)
|
54
|
-
end
|
55
|
-
private_class_method :test_tag, :tags
|
56
|
-
end
|
57
|
-
|
58
|
-
# vim: nospell
|