create_changelog 1.3.0 → 1.3.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ccl +10 -3
  3. data/bin/ccl~ +102 -44
  4. data/features/changelog_only_recent_changes.feature +51 -0
  5. data/features/changelog_only_recent_changes.feature~ +51 -0
  6. data/features/changelog_without_recent_changes.feature +51 -0
  7. data/features/changelog_without_recent_changes.feature~ +50 -0
  8. data/features/commandline.feature~ +21 -0
  9. data/features/complete_changelog.feature +51 -0
  10. data/features/complete_changelog.feature~ +51 -0
  11. data/features/create_changelog.feature~ +19 -0
  12. data/features/decorate_output.feature +30 -0
  13. data/features/decorate_output.feature~ +30 -0
  14. data/features/prepare_release.feature~ +26 -0
  15. data/features/step_definitions/git_steps.rb +61 -0
  16. data/features/step_definitions/git_steps.rb~ +74 -0
  17. data/features/step_definitions/stdout_steps.rb +7 -0
  18. data/features/step_definitions/stdout_steps.rb~ +10 -0
  19. data/features/support/assertions.rb +7 -0
  20. data/features/support/assertions.rb~ +7 -0
  21. data/features/support/env.rb +1 -0
  22. data/features/support/env.rb~ +6 -0
  23. data/lib/array.rb~ +18 -0
  24. data/lib/changelog.rb +5 -1
  25. data/lib/changelog.rb~ +14 -14
  26. data/lib/changelog_filter.rb~ +58 -0
  27. data/lib/commit_changelog.rb~ +9 -1
  28. data/lib/git.rb +66 -0
  29. data/lib/git.rb~ +76 -1
  30. data/lib/tag.rb~ +4 -5
  31. data/lib/tag_list.rb~ +13 -2
  32. data/lib/version.rb +1 -1
  33. data/lib/version.rb~ +1 -1
  34. data/test/test_changelog_filter.rb +21 -0
  35. data/test/test_changelog_filter.rb~ +19 -0
  36. data/test/test_tag_list.rb +12 -0
  37. data/test/test_tag_list.rb~ +12 -0
  38. metadata +74 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24eaf0e197456ddc73ee36dbe5c4befa32d7a8fb
4
- data.tar.gz: ac2e4abb1a874e0c8d98f3bc404273c733bf48ea
3
+ metadata.gz: ee4d6a862549a122e47311e28210893f4a37cc1d
4
+ data.tar.gz: 11a032d1d6705094838346f0e5e3c875fb619496
5
5
  SHA512:
6
- metadata.gz: 56de42ae4ca9ccf353baacf98df9729a9c90287871e30af061fc46d2f7087ed99a8ba1ee3f04a47707eb977c98c9f8f6c73417e419a7fb4ff28531df03b8d90b
7
- data.tar.gz: 40ca54406f53d1f2a7106cbe393e127a7f07f0b781a5276ecec945cb3a213669c0d9807fc286805dad29b543adbf1be049abc5712e9d5cfcc4de99eae91dac96
6
+ metadata.gz: 56db6e02d66a4616a232a7e9dbed824546b7bc8143df921723161158c4e5333700b00921766b12f73d73aca6a0990987249383eb851e68c2d269a3c3424d894b
7
+ data.tar.gz: 6297b071daa7820fd209c231f7a1fb36b90fe8cb00a939f4a31ece50c8f9519368e2cd3d7be52b36d17eaba5ab6be4945e3f1ba2a5dabfdcc9e53db292a2e26e
data/bin/ccl CHANGED
@@ -23,13 +23,20 @@ require_relative '../lib/changelog.rb'
23
23
  require_relative '../lib/git.rb'
24
24
  require_relative '../lib/version.rb'
25
25
 
26
+ if !Git.is_installed?
27
+ abort("FATAL: Git is not installed or cannot be executed.")
28
+ end
29
+
26
30
  options = {}
27
31
  working_dir = Dir.pwd
28
32
  option_parser = OptionParser.new do |opts|
29
33
  exe_name = File.basename($PROGRAM_NAME)
30
- opts.banner = "create_changelog version #{CreateChangelog::VERSION}\n"
31
- opts.banner += "Creates changelog from log entries in git log\n"
32
- opts.banner += "Usage: #{exe_name} [options] [current_version]"
34
+ opts.banner = <<EOF
35
+ create_changelog version #{CreateChangelog::VERSION} - <https://github.com/bovender/create-changelog>
36
+ (c) Copyright 2015 Daniel Kraus - distriuted under Apache License Version 2.0
37
+ Creates changelog from log entries in git log\n
38
+ Usage: #{exe_name} [options] [current_version]
39
+ EOF
33
40
  opts.on("-r", "--recent",
34
41
  "Include only most recent changes") do
35
42
  options[:only_recent] = true
data/bin/ccl~ CHANGED
@@ -23,54 +23,112 @@ require_relative '../lib/changelog.rb'
23
23
  require_relative '../lib/git.rb'
24
24
  require_relative '../lib/version.rb'
25
25
 
26
- def main
27
- options = {}
28
- working_dir = Dir.pwd
29
- option_parser = OptionParser.new do |opts|
30
- exe_name = File.basename($PROGRAM_NAME)
31
- opts.banner = "create_changelog version #{CreateChangelog::VERSION}\n"
32
- opts.banner += "Creates changelog from log entries in git log\n"
33
- opts.banner += "Usage: #{exe_name} [options] [current_version]"
34
- opts.on("-r", "--recent",
35
- "Include only most recent changes") do
36
- options[:only_recent] = true
37
- end
38
- opts.on("-n", "--no-recent",
39
- "Exclude the most recent changes (from untagged commits)") do
40
- options[:no_recent] = true
41
- end
42
- opts.on("-d WORKING_DIR", "--dir WORKING_DIR",
43
- "Use alternate working directory") do |dir|
44
- working_dir = dir
45
- end
46
- opts.on("-v", "--version", "Print version information and exit.") do
47
- puts CreateChangelog::VERSION
48
- exit
49
- end
50
- end
51
- option_parser.parse!
26
+ if !Git.is_installed?
27
+ abort("FATAL: Git is not installed or cannot be executed.")
28
+ end
29
+
30
+ class CreateChangelogCli
31
+
32
+ def initialize
33
+ @action = nil
34
+ @working_dir = Dir.pwd
35
+ @exclude_recent = false
36
+ end
37
+
38
+ # Sets the desired action and aborts if an action was previously set.
39
+ # This serves to exclude conflicting flags on the command line.
40
+ #
41
+ # @param [Symbol] action
42
+ # Desired action
43
+ def set_action(action)
44
+ abort "FATAL: Cannot combine these flags: #{action} and #{@action}." if @action
45
+ @action = action
46
+ end
47
+
48
+ def get_options
49
+ OptionParser.new do |opts|
50
+ exe_name = File.basename($PROGRAM_NAME)
51
+ opts.banner = <<EOF
52
+ create_changelog version #{CreateChangelog::VERSION} - <https://github.com/bovender/create-changelog>
53
+ (c) Copyright 2015 Daniel Kraus - distriuted under Apache License Version 2.0
54
+ Creates changelog from log entries in git log\n
55
+ Usage: #{exe_name} [options] [current_version]
56
+ EOF
57
+ opts.on("-r", "--recent",
58
+ "Include only most recent changes") do
59
+ set_action :recent
60
+ end
61
+ opts.on("-n", "--no-recent",
62
+ "Exclude the most recent changes (from untagged commits)") do
63
+ @exclude_recent = true
64
+ end
65
+ opts.on("-d WORKING_DIR", "--dir WORKING_DIR",
66
+ "Use alternate working directory") do |dir|
67
+ @working_dir = dir
68
+ end
69
+ opts.on("-v", "--version", "Print version information and exit.") do
70
+ set_action :version
71
+ end
72
+ end
73
+ end
74
+
75
+ # Changes to the repository directory and executes the block, but only
76
+ # if the directory does contain a Git repository and if the repository
77
+ # is not empty.
78
+ #
79
+ # @param [Block] &block
80
+ # Code to execute in the repository directory.
81
+ #
82
+ def in_repository(&block)
83
+ abort "FATAL: Directory does not exist" unless Dir.exist?(@working_dir)
84
+ Dir.chdir(@working_dir) do
85
+ abort "FATAL: Not a Git repository." unless Git.is_git_repository?
86
+ yield unless Git.is_empty_repository?
87
+ end
88
+ end
52
89
 
53
- if options[:no_recent] and options[:only_recent]
54
- abort "FATAL: Cannot combine --recent and --no-recent"
55
- end
90
+ # Generates a log of most recent changes only (since last tag)
91
+ #
92
+ def generate_recent
93
+ in_repository do
94
+ change_log = Changelog.new
95
+ output = change_log.generate_recent
96
+ puts output if output
97
+ end
98
+ end
56
99
 
57
- Dir.chdir(working_dir) do
58
- abort "FATAL: Not a git repository." unless Git.is_git_repository?
100
+ # Generates a complete changelog
101
+ #
102
+ def generate_complete
103
+ in_repository do
104
+ change_log = Changelog.new
105
+ change_log.recent_changes_heading = ARGV[0] unless ARGV.empty?
106
+ output = change_log.generate(@exclude_recent)
107
+ puts output.rstrip if output
108
+ end
109
+ end
59
110
 
60
- unless Git.is_empty_repository?
61
- change_log = Changelog.new
62
- change_log.recent_changes_heading = ARGV[0] unless ARGV.empty?
63
- if options[:only_recent]
64
- output = change_log.generate_recent
65
- puts output if output
66
- else
67
- output = change_log.generate(options[:no_recent])
68
- puts output.rstrip if output
69
- end
70
- end
71
- end
111
+ # Main method of the command line application
112
+ #
113
+ def main
114
+ get_options.parse!
115
+ @action = :complete if @action.nil?
116
+ if @exclude_recent && @action != :complete
117
+ abort "FATAL: --no-recent switch does not make sense here"
118
+ end
119
+ case @action
120
+ when :recent
121
+ generate_recent
122
+ when :complete
123
+ generate_complete
124
+ when :version
125
+ puts CreateChangelog::VERSION
126
+ else
127
+ abort "FATAL: Unknown action '#{@action}'"
128
+ end
129
+ end
72
130
  end
73
131
 
74
- main
132
+ CreateChangelogCli.new.main
75
133
 
76
134
  # vim: nospell
@@ -0,0 +1,51 @@
1
+ @announce
2
+ Feature: Creating changelog including recent changes only.
3
+
4
+ Scenario: Repository with identical changelog lines only in commit messages
5
+ Given an empty Git repository
6
+ When 2 commits with standard changelog line are added
7
+ And I successfully run `ccl --recent`
8
+ Then the stdout should contain 1 line starting with "- "
9
+
10
+ Scenario: Repository with multiple changelog lines only in commit messages
11
+ Given an empty Git repository
12
+ When 3 commits with unique changelog line are added
13
+ And I successfully run `ccl --recent`
14
+ Then the stdout should contain 3 lines starting with "- "
15
+
16
+ Scenario: Changelog lines in commit messages and tag without changelog line
17
+ Given an empty Git repository
18
+ When 3 commits with unique changelog line are added
19
+ And a tag without changelog line is added
20
+ And I successfully run `ccl --recent`
21
+ Then the stdout should not contain anything
22
+
23
+ Scenario: Changelog lines in commit messages and tag with different changelog line
24
+ Given an empty Git repository
25
+ When 3 commits with unique changelog line are added
26
+ And a tag with unique changelog line is added
27
+ And I successfully run `ccl --recent`
28
+ Then the stdout should not contain anything
29
+
30
+ Scenario: Changelog lines in commit messages and tag with same changelog line
31
+ Given an empty Git repository
32
+ When 3 commits with standard changelog line are added
33
+ And a tag with standard changelog line is added
34
+ And I successfully run `ccl --recent`
35
+ Then the stdout should not contain anything
36
+
37
+ Scenario: Unique changelog lines in commit messages, tag, and recent commits
38
+ Given an empty Git repository
39
+ When 3 commits with unique changelog line are added
40
+ And a tag with unique changelog line is added
41
+ And 2 commits with unique changelog line are added
42
+ And I successfully run `ccl --recent`
43
+ Then the stdout should contain 2 lines starting with "- "
44
+
45
+ Scenario: Same changelog lines in commit messages, tag, and recent commits
46
+ Given an empty Git repository
47
+ When 3 commits with standard changelog line are added
48
+ And a tag with standard changelog line is added
49
+ And 2 commits with standard changelog line are added
50
+ And I successfully run `ccl --recent`
51
+ Then the stdout should contain 1 line starting with "- "
@@ -0,0 +1,51 @@
1
+ @announce
2
+ Feature: Creating changelog including recent changes only.
3
+
4
+ Scenario: Repository with identical changelog lines only in commit messages
5
+ Given an empty Git repository
6
+ When 2 commits with standard changelog line are added
7
+ And I successfully run `ccl --recent`
8
+ Then the stdout should contain 1 line starting with "- "
9
+
10
+ Scenario: Repository with multiple changelog lines only in commit messages
11
+ Given an empty Git repository
12
+ When 3 commits with unique changelog line are added
13
+ And I successfully run `ccl --recent`
14
+ Then the stdout should contain 3 lines starting with "- "
15
+
16
+ Scenario: Changelog lines in commit messages and tag without changelog line
17
+ Given an empty Git repository
18
+ When 3 commits with unique changelog line are added
19
+ And a tag without changelog line is added
20
+ And I successfully run `ccl --recent`
21
+ Then the stdout should not contain anything
22
+
23
+ Scenario: Changelog lines in commit messages and tag with different changelog line
24
+ Given an empty Git repository
25
+ When 3 commits with unique changelog line are added
26
+ And a tag with unique changelog line is added
27
+ And I successfully run `ccl --recent`
28
+ Then the stdout should not contain anything
29
+
30
+ Scenario: Changelog lines in commit messages and tag with same changelog line
31
+ Given an empty Git repository
32
+ When 3 commits with standard changelog line are added
33
+ And a tag with standard changelog line is added
34
+ And I successfully run `ccl --recent`
35
+ Then the stdout should not contain anything
36
+
37
+ Scenario: Unique changelog lines in commit messages, tag, and recent commits
38
+ Given an empty Git repository
39
+ When 3 commits with unique changelog line are added
40
+ And a tag with unique changelog line is added
41
+ And 2 commits with unique changelog line are added
42
+ And I successfully run `ccl --recent`
43
+ Then the stdout should contain 2 lines starting with "- "
44
+
45
+ Scenario: Same changelog lines in commit messages, tag, and recent commits
46
+ Given an empty Git repository
47
+ When 3 commits with standard changelog line are added
48
+ And a tag with standard changelog line is added
49
+ And 2 commits with standard changelog line are added
50
+ And I successfully run `ccl --recent`
51
+ Then the stdout should contain 1 line starting with "- "
@@ -0,0 +1,51 @@
1
+ @announce
2
+ Feature: Create a changelog that does not contain recent changes.
3
+
4
+ Scenario: Repository with identical changelog lines only in commit messages
5
+ Given an empty Git repository
6
+ When 2 commits with standard changelog line are added
7
+ And I successfully run `ccl --no-recent`
8
+ Then the stdout should not contain anything
9
+
10
+ Scenario: Repository with multiple changelog lines only in commit messages
11
+ Given an empty Git repository
12
+ When 3 commits with unique changelog line are added
13
+ And I successfully run `ccl --no-recent`
14
+ Then the stdout should not contain anything
15
+
16
+ Scenario: Changelog lines in commit messages and tag without changelog line
17
+ Given an empty Git repository
18
+ When 3 commits with unique changelog line are added
19
+ And a tag without changelog line is added
20
+ And I successfully run `ccl --no-recent`
21
+ Then the stdout should contain 3 lines starting with "- "
22
+
23
+ Scenario: Changelog lines in commit messages and tag with different changelog line
24
+ Given an empty Git repository
25
+ When 3 commits with unique changelog line are added
26
+ And a tag with unique changelog line is added
27
+ And I successfully run `ccl --no-recent`
28
+ Then the stdout should contain 4 lines starting with "- "
29
+
30
+ Scenario: Changelog lines in commit messages and tag with same changelog line
31
+ Given an empty Git repository
32
+ When 3 commits with standard changelog line are added
33
+ And a tag with standard changelog line is added
34
+ And I successfully run `ccl --no-recent`
35
+ Then the stdout should contain 1 line starting with "- "
36
+
37
+ Scenario: Unique changelog lines in commit messages, tag, and recent commits
38
+ Given an empty Git repository
39
+ When 3 commits with unique changelog line are added
40
+ And a tag with unique changelog line is added
41
+ And 2 commits with unique changelog line are added
42
+ And I successfully run `ccl --no-recent`
43
+ Then the stdout should contain 4 lines starting with "- "
44
+
45
+ Scenario: Same changelog lines in commit messages, tag, and recent commits
46
+ Given an empty Git repository
47
+ When 3 commits with standard changelog line are added
48
+ And a tag with standard changelog line is added
49
+ And 2 commits with standard changelog line are added
50
+ And I successfully run `ccl --no-recent`
51
+ Then the stdout should contain 1 line starting with "- "
@@ -0,0 +1,50 @@
1
+ Feature: Create a changelog that does not contain recent changes.
2
+
3
+ Scenario: Repository with identical changelog lines only in commit messages
4
+ Given an empty Git repository
5
+ When 2 commits with standard changelog line are added
6
+ And I successfully run `ccl --no-recent`
7
+ Then the stdout should not contain anything
8
+
9
+ Scenario: Repository with multiple changelog lines only in commit messages
10
+ Given an empty Git repository
11
+ When 3 commits with unique changelog line are added
12
+ And I successfully run `ccl --no-recent`
13
+ Then the stdout should not contain anything
14
+
15
+ Scenario: Changelog lines in commit messages and tag without changelog line
16
+ Given an empty Git repository
17
+ When 3 commits with unique changelog line are added
18
+ And a tag without changelog line is added
19
+ And I successfully run `ccl --no-recent`
20
+ Then the stdout should contain 3 lines starting with "- "
21
+
22
+ Scenario: Changelog lines in commit messages and tag with different changelog line
23
+ Given an empty Git repository
24
+ When 3 commits with unique changelog line are added
25
+ And a tag with unique changelog line is added
26
+ And I successfully run `ccl --no-recent`
27
+ Then the stdout should contain 4 lines starting with "- "
28
+
29
+ Scenario: Changelog lines in commit messages and tag with same changelog line
30
+ Given an empty Git repository
31
+ When 3 commits with standard changelog line are added
32
+ And a tag with standard changelog line is added
33
+ And I successfully run `ccl --no-recent`
34
+ Then the stdout should contain 1 line starting with "- "
35
+
36
+ Scenario: Unique changelog lines in commit messages, tag, and recent commits
37
+ Given an empty Git repository
38
+ When 3 commits with unique changelog line are added
39
+ And a tag with unique changelog line is added
40
+ And 2 commits with unique changelog line are added
41
+ And I successfully run `ccl --no-recent`
42
+ Then the stdout should contain 4 lines starting with "- "
43
+
44
+ Scenario: Same changelog lines in commit messages, tag, and recent commits
45
+ Given an empty Git repository
46
+ When 3 commits with standard changelog line are added
47
+ And a tag with standard changelog line is added
48
+ And 2 commits with standard changelog line are added
49
+ And I successfully run `ccl --no-recent`
50
+ Then the stdout should contain 1 line starting with "- "
@@ -0,0 +1,21 @@
1
+ @announce
2
+ Feature: Command line switches
3
+ Scenario: Combining -r and -n switches is not allowed
4
+ Given an empty Git repository
5
+ When I run `ccl -r -n`
6
+ Then the exit status should not be 0
7
+
8
+ Scenario: Combining -r and -v switches is not allowed
9
+ Given an empty Git repository
10
+ When I run `ccl -r -v`
11
+ Then the exit status should not be 0
12
+
13
+ Scenario: Combining -n and -v switches is not allowed
14
+ Given an empty Git repository
15
+ When I run `ccl -n -v`
16
+ Then the exit status should not be 0
17
+
18
+ Scenario: Attempt to work with non-existent directory
19
+ When I run `ccl -d /this/does/not/exist`
20
+ Then the exit status should not be 0
21
+ And the stderr should contain "FATAL: Directory does not exist"
@@ -0,0 +1,51 @@
1
+ @announce
2
+ Feature: Creating a complete, decorated changelog.
3
+
4
+ Scenario: Repository with identical changelog lines only in commit messages
5
+ Given an empty Git repository
6
+ When 2 commits with standard changelog line are added
7
+ And I successfully run `ccl`
8
+ Then the stdout should contain 1 line starting with "- "
9
+
10
+ Scenario: Repository with multiple changelog lines only in commit messages
11
+ Given an empty Git repository
12
+ When 3 commits with unique changelog line are added
13
+ And I successfully run `ccl`
14
+ Then the stdout should contain 3 lines starting with "- "
15
+
16
+ Scenario: Changelog lines in commit messages and tag without changelog line
17
+ Given an empty Git repository
18
+ When 3 commits with unique changelog line are added
19
+ And a tag without changelog line is added
20
+ And I successfully run `ccl`
21
+ Then the stdout should contain 3 lines starting with "- "
22
+
23
+ Scenario: Changelog lines in commit messages and tag with different changelog line
24
+ Given an empty Git repository
25
+ When 3 commits with unique changelog line are added
26
+ And a tag with unique changelog line is added
27
+ And I successfully run `ccl`
28
+ Then the stdout should contain 4 lines starting with "- "
29
+
30
+ Scenario: Changelog lines in commit messages and tag with same changelog line
31
+ Given an empty Git repository
32
+ When 3 commits with standard changelog line are added
33
+ And a tag with standard changelog line is added
34
+ And I successfully run `ccl`
35
+ Then the stdout should contain 1 line starting with "- "
36
+
37
+ Scenario: Unique changelog lines in commit messages, tag, and recent commits
38
+ Given an empty Git repository
39
+ When 3 commits with unique changelog line are added
40
+ And a tag with unique changelog line is added
41
+ And 2 commits with unique changelog line are added
42
+ And I successfully run `ccl`
43
+ Then the stdout should contain 6 lines starting with "- "
44
+
45
+ Scenario: Same changelog lines in commit messages, tag, and recent commits
46
+ Given an empty Git repository
47
+ When 3 commits with standard changelog line are added
48
+ And a tag with standard changelog line is added
49
+ And 2 commits with standard changelog line are added
50
+ And I successfully run `ccl`
51
+ Then the stdout should contain 2 lines starting with "- "