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
@@ -38,7 +38,15 @@ class CommitChangelog
38
38
  @changelog = filter.changelog
39
39
  end
40
40
 
41
- # Adds changelog information contained in a specific commit message.
41
+ # Adds changelog information contained in a specific commit message. This
42
+ # method is typically used to parse the initial commit's commit message.
43
+ #
44
+ # @param [String] commit
45
+ # Sha-1 of the commit whose commit message to filter for changelog lines.
46
+ #
47
+ # @return
48
+ # Undefined
49
+ #
42
50
  def add_commit(commit)
43
51
  pattern = ChangelogFilter.pattern
44
52
  filtered_text = Git.get_filtered_message(commit, pattern)
data/lib/git.rb CHANGED
@@ -16,6 +16,16 @@ require_relative 'tag_list'
16
16
  # A static wrapper class for git
17
17
  class Git
18
18
 
19
+ # Determines whether Git is installed
20
+ #
21
+ # @return [bool]
22
+ # True if Git is installed, false if not.
23
+ #
24
+ def self.is_installed?
25
+ `git --version`
26
+ $? == 0
27
+ end
28
+
19
29
  # Determines whether the (current) directory is a git repository
20
30
  #
21
31
  # @param [String] dir
@@ -36,6 +46,62 @@ class Git
36
46
  $? != 0
37
47
  end
38
48
 
49
+ # Retrieves the name of the current branch.
50
+ #
51
+ # @return [String]
52
+ # Current branch.
53
+ def self.current_branch
54
+ `git branch`.rstrip
55
+ end
56
+
57
+ # Launches the text editor that Git uses for commit messages,
58
+ # and passes file as a command line argument to it.
59
+ #
60
+ # @see https://github.com/git/git/blob/master/editor.c
61
+ # Git's editor.c on GitHub
62
+ #
63
+ # @param [String] file
64
+ # Filename to pass to the editor.
65
+ #
66
+ # @return [int]
67
+ # Exit code of the editor process, or false if no editor found.
68
+ #
69
+ def self.launch_editor(file)
70
+ # const char *editor = getenv("GIT_EDITOR");
71
+ editor = ENV['GIT_EDITOR']
72
+
73
+ # const char *terminal = getenv("TERM");
74
+ terminal = ENV['TERM'];
75
+
76
+ # int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
77
+ terminal_is_dumb = !terminal || terminal == 'dumb'
78
+
79
+ # if (!editor && editor_program)
80
+ editor = `git config --get core.editor`.rstrip if editor.nil? || editor.empty?
81
+
82
+ # if (!editor && !terminal_is_dumb)
83
+ # editor = getenv("VISUAL");
84
+ editor = ENV['VISUAL'] if (editor.nil? || editor.empty?) && !terminal_is_dumb
85
+
86
+ # if (!editor)
87
+ # editor = getenv("EDITOR");
88
+ editor = ENV['EDITOR'] if (editor.nil? || editor.empty?)
89
+
90
+ # if (!editor && terminal_is_dumb)
91
+ # return NULL;
92
+ # if (!editor)
93
+ # editor = DEFAULT_EDITOR;
94
+ # Use vi, Git's hard-coded default
95
+ editor = 'vi' if (editor.nil? || editor.empty?) && !terminal_is_dumb
96
+
97
+ if editor && !editor.empty?
98
+ system "#{editor} '#{file}'"
99
+ $?
100
+ else
101
+ false
102
+ end
103
+ end
104
+
39
105
  # Retrieves the first 99 lines of the annotation of a tag.
40
106
  #
41
107
  def self.get_tag_annotation(tag)
data/lib/git.rb~ CHANGED
@@ -16,7 +16,23 @@ require_relative 'tag_list'
16
16
  # A static wrapper class for git
17
17
  class Git
18
18
 
19
+ # Determines whether Git is installed
20
+ #
21
+ # @return [bool]
22
+ # True if Git is installed, false if not.
23
+ #
24
+ def self.is_installed?
25
+ `git --version`
26
+ $? == 0
27
+ end
28
+
19
29
  # Determines whether the (current) directory is a git repository
30
+ #
31
+ # @param [String] dir
32
+ # Directory to check; if nil, uses the current directory.
33
+ #
34
+ # @return [bool]
35
+ # True if the directory is a Git repository, false if not.
20
36
  def self.is_git_repository?(dir = nil)
21
37
  dir = Dir.pwd if dir.nil?
22
38
  system("git status > /dev/null 2>&1")
@@ -24,18 +40,77 @@ class Git
24
40
  end
25
41
 
26
42
  # Determines if the repository in the current directory is empty.
43
+ #
27
44
  def self.is_empty_repository?
28
45
  `git show HEAD > /dev/null 2>&1`
29
46
  $? != 0
30
47
  end
31
48
 
49
+ # Retrieves the name of the current branch.
50
+ #
51
+ # @return [String]
52
+ # Current branch.
53
+ def self.current_branch
54
+ `git branch`.rstrip
55
+ end
56
+
57
+ # Launches the text editor that Git uses for commit messages,
58
+ # and passes file as a command line argument to it.
59
+ #
60
+ # @see https://github.com/git/git/blob/master/editor.c
61
+ # Git's editor.c on GitHub
62
+ #
63
+ # @param [String] file
64
+ # Filename to pass to the editor.
65
+ #
66
+ # @return [int]
67
+ # Exit code of the editor process, or false if no editor found.
68
+ #
69
+ def self.launch_editor(file)
70
+ # const char *editor = getenv("GIT_EDITOR");
71
+ editor = ENV['GIT_EDITOR']
72
+
73
+ # const char *terminal = getenv("TERM");
74
+ terminal = ENV['TERM'];
75
+
76
+ # int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
77
+ terminal_is_dumb = !terminal || terminal == 'dumb'
78
+
79
+ # if (!editor && editor_program)
80
+ editor = `git config --get core.editor`.rstrip if editor.nil? || editor.empty?
81
+
82
+ # if (!editor && !terminal_is_dumb)
83
+ # editor = getenv("VISUAL");
84
+ editor = ENV['VISUAL'] if (editor.nil? || editor.empty?) && !terminal_is_dumb
85
+
86
+ # if (!editor)
87
+ # editor = getenv("EDITOR");
88
+ editor = ENV['EDITOR'] if (editor.nil? || editor.empty?)
89
+
90
+ # if (!editor && terminal_is_dumb)
91
+ # return NULL;
92
+ # if (!editor)
93
+ # editor = DEFAULT_EDITOR;
94
+ # Use vi, Git's hard-coded default
95
+ editor = 'vi' if (editor.nil? || editor.empty?) && !terminal_is_dumb
96
+
97
+ if editor && !editor.empty?
98
+ system "#{editor} '#{file}'"
99
+ $?
100
+ else
101
+ false
102
+ end
103
+ end
104
+
32
105
  # Retrieves the first 99 lines of the annotation of a tag.
106
+ #
33
107
  def self.get_tag_annotation(tag)
34
108
  test_tag tag
35
109
  `git tag -l -n99 #{tag}`.rstrip
36
110
  end
37
111
 
38
- # Retrieves the date of a tag
112
+ # Retrieves the author date of a tag
113
+ #
39
114
  def self.get_tag_date(tag)
40
115
  test_tag tag
41
116
  `git log -1 --format=format:%ai #{tag}`
data/lib/tag.rb~ CHANGED
@@ -15,7 +15,7 @@ require 'date'
15
15
  require_relative 'git'
16
16
  require_relative 'changelog_filter'
17
17
 
18
- # Represents a git tag and its annotation.
18
+ # Represents a Git tag and its annotation.
19
19
  class Tag
20
20
  # The heading of the tag annotation.
21
21
  attr_accessor :heading
@@ -30,10 +30,9 @@ class Tag
30
30
  attr_reader :date
31
31
 
32
32
  # Gets change information for a specific tagged version.
33
- # This will prepend the summary for the annotated tag before
34
- # the list of changes. If the tag annotation contains changelog
35
- # entries, they are merged with the changelog entries filtered
36
- # from the commit messages, and only unique entries are used.
33
+ #
34
+ # @param [String] tag
35
+ # Tag for which to instantiate the class.
37
36
  def initialize(tag)
38
37
  annotation = Git.get_tag_annotation(tag)
39
38
  @date = Date.parse(Git.get_tag_date(tag))
data/lib/tag_list.rb~ CHANGED
@@ -24,8 +24,10 @@ class TagList
24
24
  attr_reader :list
25
25
 
26
26
  # Instantiates the tag list.
27
- # include_head indicates whether or not to include
28
- # the most recent changes
27
+ #
28
+ # @param [bool] include_head
29
+ # Indicates whether or not to include the most recent changes.
30
+ #
29
31
  def initialize(include_head = true)
30
32
  @include_head = include_head
31
33
  @list = build_list
@@ -33,6 +35,9 @@ class TagList
33
35
 
34
36
  # Returns the most recent tag in the git repository,
35
37
  # or the sha1 of the initial commit if there is no tag.
38
+ #
39
+ # @return [String]
40
+ #
36
41
  def latest_tag
37
42
  # Index 0 is HEAD
38
43
  # Index 1 is most recent tag or first commit
@@ -46,10 +51,16 @@ class TagList
46
51
  # of the repository. Usually there should be not more than
47
52
  # one such commit.
48
53
  # See http://stackoverflow.com/a/1007545/270712
54
+ #
49
55
  def get_initial_commit
50
56
  `git rev-list --max-parents=0 HEAD`.chomp
51
57
  end
52
58
 
59
+ # Builds a list of Git tags and encloses it with HEAD and the
60
+ # Sha-1 of the initial commit.
61
+ #
62
+ # @return [Array]
63
+ # Array of tags, surrounded by HEAD and the Sha-1 of the initial commit.
53
64
  def build_list
54
65
  tags = []
55
66
  tags << get_initial_commit
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CreateChangelog
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
data/lib/version.rb~ CHANGED
@@ -1,3 +1,3 @@
1
1
  module CreateChangelog
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ require_relative '../lib/changelog_filter'
3
+
4
+ class TestChangelogFilter < Test::Unit::TestCase
5
+ def test_filter_from_string
6
+ log_entry = "- TEST: This is a test log entry"
7
+ string = <<-EOF
8
+ This is a multiline
9
+ test string
10
+ #{log_entry}
11
+ and more text
12
+ EOF
13
+ filter = ChangelogFilter.FromString(string)
14
+ assert(filter.changelog.length == 1,
15
+ 'Filter should contain one changelog entry.')
16
+ assert(filter.changelog[0].lstrip == log_entry,
17
+ 'Filtered changelog did not contain test entry.')
18
+ assert(filter.other_text.size == 3,
19
+ 'Other text should have 3 lines')
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require_relative '../lib/changelog_filter'
3
+
4
+ class TestChangelogFilter < Test::Unit::TestCase
5
+ def test_filter_from_string
6
+ log_entry = "- TEST: This is a test log entry"
7
+ string = <<-EOF
8
+ This is a multiline
9
+ test string
10
+ #{log_entry}
11
+ and more text
12
+ EOF
13
+ filter = ChangelogFilter.FromString(string)
14
+ assert(filter.changelog.length == 1,
15
+ 'Filter should contain one changelog entry.')
16
+ assert(filter.changelog[0].lstrip == log_entry,
17
+ 'Filtered changelog did not contain test entry.')
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require_relative '../lib/tag_list'
3
+
4
+ class TestTagList < Test::Unit::TestCase
5
+ def test_list_is_enclosed
6
+ tags = TagList.new
7
+ assert(tags.list[0] == 'HEAD',
8
+ 'First element in list should be HEAD')
9
+ assert(tags.list[-1].length == 40,
10
+ 'Last element in list should be SHA-1 hash')
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require_relative '../lib/tag_list'
3
+
4
+ class TestTagList < Test::Unit::TestCase
5
+ def test_list_is_enclosed
6
+ tags = TagList.new
7
+ assert(tags.list[0] == 'HEAd',
8
+ 'First element in list should be HEAD')
9
+ assert(tags.list[-1].length == 40,
10
+ 'Last element in list should be Sha-1 hash')
11
+ end
12
+ end
metadata CHANGED
@@ -1,29 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: create_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Kraus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem-man
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ronn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: aruba
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
- - - ">="
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
18
60
  - !ruby/object:Gem::Version
19
- version: '0'
61
+ version: 0.8.7
20
62
  type: :development
21
63
  prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
- - - ">="
66
+ - - "~>"
25
67
  - !ruby/object:Gem::Version
26
- version: '0'
68
+ version: 0.8.7
27
69
  description: "\t\tRuby program with command-line interface that creates a changelog
28
70
  from log\n\t\tlines in a git repository that can be read and understood by end users.\n"
29
71
  email: krada@gmx.net
@@ -36,10 +78,31 @@ files:
36
78
  - README.md
37
79
  - bin/ccl
38
80
  - bin/ccl~
81
+ - features/changelog_only_recent_changes.feature
82
+ - features/changelog_only_recent_changes.feature~
83
+ - features/changelog_without_recent_changes.feature
84
+ - features/changelog_without_recent_changes.feature~
85
+ - features/commandline.feature~
86
+ - features/complete_changelog.feature
87
+ - features/complete_changelog.feature~
88
+ - features/create_changelog.feature~
89
+ - features/decorate_output.feature
90
+ - features/decorate_output.feature~
91
+ - features/prepare_release.feature~
92
+ - features/step_definitions/git_steps.rb
93
+ - features/step_definitions/git_steps.rb~
94
+ - features/step_definitions/stdout_steps.rb
95
+ - features/step_definitions/stdout_steps.rb~
96
+ - features/support/assertions.rb
97
+ - features/support/assertions.rb~
98
+ - features/support/env.rb
99
+ - features/support/env.rb~
39
100
  - lib/array.rb
101
+ - lib/array.rb~
40
102
  - lib/changelog.rb
41
103
  - lib/changelog.rb~
42
104
  - lib/changelog_filter.rb
105
+ - lib/changelog_filter.rb~
43
106
  - lib/commit_changelog.rb
44
107
  - lib/commit_changelog.rb~
45
108
  - lib/git.rb
@@ -50,12 +113,16 @@ files:
50
113
  - lib/tag_list.rb~
51
114
  - lib/version.rb
52
115
  - lib/version.rb~
116
+ - test/test_changelog_filter.rb
117
+ - test/test_changelog_filter.rb~
118
+ - test/test_tag_list.rb
119
+ - test/test_tag_list.rb~
53
120
  homepage: https://github.com/bovender/create-changelog
54
121
  licenses:
55
122
  - Apache License version 2
56
123
  metadata: {}
57
124
  post_install_message: |
58
- create_changelog version 1.3.0 has been installed.
125
+ create_changelog version 1.3.1 has been installed.
59
126
  For usage information, type ccl -h
60
127
  rdoc_options: []
61
128
  require_paths: