milestoner 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c9069703d542f4240535b561b66d0281abedfc1
4
- data.tar.gz: fffc9ae8af389de2d28c4f87385d3f288172fff9
3
+ metadata.gz: 9aa59dc5b98238b6b0f20689142e7926443d0fd8
4
+ data.tar.gz: 87653a11e6ecf0f2f74f605188ebe20ac63c1ab7
5
5
  SHA512:
6
- metadata.gz: 078922346541fb99108b8be870d5ac926d2b338ebfa5b7524d546d5cf76fec806e0443fd10a7ef5dc3c162e894c48fac4c6123f8b05165406f3c149eb467e549
7
- data.tar.gz: bf20f9b2b67ba672cb89e1a9b8fee361d53ffa1621990d173024633b08d456705ed51cc60b401857a4326d101d0f38aeddc20c83dc57d6c9cc3e0a60506a3445
6
+ metadata.gz: 38595bb8f085651035d26b5440cd86e1656a4b35acdfaf7e8ab788cd7cca5a7047cf8813d16fba0eabc4f59756fcb17903254bad7541d33903204a8a90ab2f49
7
+ data.tar.gz: ccdf5a94d6b5189cfc2555e1bab248fcbe0bb9ad1869f3ba015518ce12e43e2b2bc6ca1911a8d31434f986c68f33c8898dc1dbc7e14a0db273e19b3bd5b09f5d
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -33,7 +33,7 @@ A command line interface for releasing Git repository milestones.
33
33
 
34
34
  # Features
35
35
 
36
- - Ensures [Semantic Versioning](http://semver.org) of Git repository tags:
36
+ - Uses [Versionaire](https://github.com/bkuhlmann/versionaire) for [Semantic Versioning](http://semver.org).
37
37
  - Format: `v<major>.<minor>.<maintenance>`.
38
38
  - Example: `v0.1.0`.
39
39
  - Ensures Git commits since last tag (or initialization of repository) are included within each Git tag message.
@@ -52,7 +52,7 @@ A command line interface for releasing Git repository milestones.
52
52
 
53
53
  # Screencasts
54
54
 
55
- [![asciicast](https://asciinema.org/a/26561.png)](https://asciinema.org/a/26561)
55
+ [![asciicast](https://asciinema.org/a/41207.png)](https://asciinema.org/a/41207)
56
56
 
57
57
  # Requirements
58
58
 
@@ -80,19 +80,23 @@ For an insecure install, type the following (not recommended):
80
80
 
81
81
  From the command line, type: `milestoner help`
82
82
 
83
+ milestoner -C, [--commits] # Show commits for next milestone.
83
84
  milestoner -P, [--publish=PUBLISH] # Tag and push milestone to remote repository.
84
- milestoner -c, [--commits] # Show commits for next milestone.
85
- milestoner -e, [--edit] # Edit Milestoner settings in default editor.
85
+ milestoner -c, [--config] # Show/manage gem configuration.
86
86
  milestoner -h, [--help=HELP] # Show this message or get help for a command.
87
87
  milestoner -p, [--push] # Push local tag to remote repository.
88
88
  milestoner -t, [--tag=TAG] # Tag local repository with new version.
89
- milestoner -v, [--version] # Show Milestoner version.
89
+ milestoner -v, [--version] # Show gem version.
90
90
 
91
- For tag options, type: `milestoner help tag`
91
+ For config options, type: `milestoner help --config`
92
+
93
+ -e, [--edit], [--no-edit] # Edit gem configuration.
94
+
95
+ For tag options, type: `milestoner help --tag`
92
96
 
93
97
  -s, [--sign], [--no-sign] # Sign tag with GPG key.
94
98
 
95
- For publish options, type: `milestoner help publish`
99
+ For publish options, type: `milestoner help --publish`
96
100
 
97
101
  -s, [--sign], [--no-sign] # Sign tag with GPG key.
98
102
 
@@ -121,7 +125,7 @@ no inheritance when local *and* global settings exist at the same time.
121
125
 
122
126
  The `.milestonerrc` uses the following default settings:
123
127
 
124
- :version: ""
128
+ :version: "0.1.0"
125
129
  :git_commit_prefixes:
126
130
  - Fixed
127
131
  - Added
@@ -132,10 +136,9 @@ The `.milestonerrc` uses the following default settings:
132
136
 
133
137
  Each `.milestonerrc` setting can be configured as follows:
134
138
 
135
- - `version`: By default it is left blank so you'll be prompted by the CLI. However, it can be nice to bump this version
136
- prior to each release and have the current version checked into source code at a per project level. The version, if
137
- set, will be used to tag the repository. If the version is a duplicate, an error will be thrown. When supplying a
138
- version, use this format: `<major>.<minor>.<maintenance>`. Example: `0.1.0`.
139
+ - `version`: Useful if desired to have the current version checked into source code per project. The version, if set,
140
+ will be used to tag the repository. If the version is a duplicate, an error will be thrown. When supplying a version,
141
+ it *must* be semantic: `<major>.<minor>.<maintenance>`. Example: `0.1.0`.
139
142
  - `git_commit_prefixes`: Should the default prefixes not be desired, you can define Git commit prefixes that match your
140
143
  style. *NOTE: Prefix order is important with the first prefix defined taking precedence over the second and so forth.*
141
144
  Special characters are allowed for prefixes but should be enclosed in quotes if used. To disable prefix usage
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "milestoner/aids/git"
4
3
  require "milestoner/errors/base"
5
4
  require "milestoner/errors/configuration"
6
5
  require "milestoner/errors/duplicate_tag"
7
6
  require "milestoner/errors/git"
8
7
  require "milestoner/errors/version"
9
8
  require "milestoner/configuration"
9
+ require "milestoner/git"
10
10
  require "milestoner/identity"
11
11
  require "milestoner/publisher"
12
12
  require "milestoner/pusher"
@@ -22,12 +22,12 @@ module Milestoner
22
22
  @publisher = Publisher.new tagger: tagger, pusher: pusher
23
23
  end
24
24
 
25
- desc "-c, [--commits]", "Show commits for next milestone."
26
- map %w(-c --commits) => :commits
25
+ desc "-C, [--commits]", "Show commits for next milestone."
26
+ map %w(-C --commits) => :commits
27
27
  def commits
28
28
  tagger.commit_list.each { |commit| say commit }
29
- rescue Errors::Base => base_error
30
- error base_error.message
29
+ rescue StandardError => exception
30
+ error exception.message
31
31
  end
32
32
 
33
33
  desc "-t, [--tag=TAG]", "Tag local repository with new version."
@@ -36,8 +36,8 @@ module Milestoner
36
36
  def tag version = configuration.settings[:version]
37
37
  tagger.create version, sign: sign_tag?(options[:sign])
38
38
  say "Repository tagged: #{tagger.version_label}."
39
- rescue Errors::Base => base_error
40
- error base_error.message
39
+ rescue StandardError => exception
40
+ error exception.message
41
41
  end
42
42
 
43
43
  desc "-p, [--push]", "Push local tag to remote repository."
@@ -45,8 +45,8 @@ module Milestoner
45
45
  def push
46
46
  pusher.push
47
47
  info "Tags pushed to remote repository."
48
- rescue Errors::Base => base_error
49
- error base_error.message
48
+ rescue StandardError => exception
49
+ error exception.message
50
50
  end
51
51
 
52
52
  desc "-P, [--publish=PUBLISH]", "Tag and push milestone to remote repository."
@@ -56,18 +56,22 @@ module Milestoner
56
56
  publisher.publish version, sign: sign_tag?(options[:sign])
57
57
  info "Repository tagged and pushed: #{tagger.version_label}."
58
58
  info "Milestone published!"
59
- rescue Errors::Base => base_error
60
- error base_error.message
59
+ rescue StandardError => exception
60
+ error exception.message
61
61
  end
62
62
 
63
- desc "-e, [--edit]", "Edit #{Identity.label} settings in default editor."
64
- map %w(-e --edit) => :edit
65
- def edit
66
- info "Editing: #{configuration.computed_file_path}..."
67
- `#{editor} #{configuration.computed_file_path}`
63
+ desc "-c, [--config]", "Show/manage gem configuration."
64
+ map %w(-c --config) => :config
65
+ method_option :edit, aliases: "-e", desc: "Edit gem configuration.", type: :boolean, default: false
66
+ def config
67
+ if options[:edit]
68
+ `#{editor} #{configuration.computed_file_path}`
69
+ else
70
+ print_config_info
71
+ end
68
72
  end
69
73
 
70
- desc "-v, [--version]", "Show #{Identity.label} version."
74
+ desc "-v, [--version]", "Show gem version."
71
75
  map %w(-v --version) => :version
72
76
  def version
73
77
  say Identity.version_label
@@ -85,7 +89,7 @@ module Milestoner
85
89
 
86
90
  def defaults
87
91
  {
88
- version: "",
92
+ version: "0.1.0",
89
93
  git_commit_prefixes: %w(Fixed Added Updated Removed Refactored),
90
94
  git_tag_sign: false
91
95
  }
@@ -94,5 +98,13 @@ module Milestoner
94
98
  def sign_tag? sign
95
99
  sign | configuration.settings[:git_tag_sign]
96
100
  end
101
+
102
+ def print_config_info
103
+ case
104
+ when configuration.local? then say("Use local configuration: #{configuration.computed_file_path}.")
105
+ when configuration.global? then say("Using global configuration: #{configuration.computed_file_path}.")
106
+ else say("Global and local gem configuration not defined, using defaults instead.")
107
+ end
108
+ end
97
109
  end
98
110
  end
@@ -16,6 +16,14 @@ module Milestoner
16
16
  File.join ENV["HOME"], file_name
17
17
  end
18
18
 
19
+ def global?
20
+ File.exist? global_file_path
21
+ end
22
+
23
+ def local?
24
+ File.exist? local_file_path
25
+ end
26
+
19
27
  def computed_file_path
20
28
  File.exist?(local_file_path) ? local_file_path : global_file_path
21
29
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Milestoner
4
+ # A lightweight Git wrapper.
5
+ class Git
6
+ def supported?
7
+ File.exist? File.join(Dir.pwd, ".git")
8
+ end
9
+
10
+ def commits?
11
+ system "git log > /dev/null 2>&1"
12
+ end
13
+
14
+ def remote?
15
+ system "git config remote.origin.url"
16
+ end
17
+ end
18
+ end
@@ -12,7 +12,7 @@ module Milestoner
12
12
  end
13
13
 
14
14
  def self.version
15
- "2.2.0"
15
+ "3.0.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -3,20 +3,19 @@
3
3
  module Milestoner
4
4
  # Handles publishing of Git tags to remote repository.
5
5
  class Pusher
6
- include Aids::Git
7
-
8
- def initialize kernel: Kernel
9
- @kernel = kernel
6
+ def initialize git: Git.new, shell: Kernel
7
+ @git = git
8
+ @shell = shell
10
9
  end
11
10
 
12
11
  def push
13
- fail(Errors::Git) unless git_supported?
14
- fail(Errors::Git, "Git remote repository is not configured.") unless git_remote?
15
- kernel.system "git push --tags"
12
+ fail(Errors::Git) unless git.supported?
13
+ fail(Errors::Git, "Git remote repository not configured.") unless git.remote?
14
+ fail(Errors::Git, "Git tags could not be pushed to remote repository.") unless shell.system("git push --tags")
16
15
  end
17
16
 
18
17
  private
19
18
 
20
- attr_reader :kernel
19
+ attr_reader :git, :shell
21
20
  end
22
21
  end
@@ -1,29 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "forwardable"
3
4
  require "open3"
5
+ require "versionaire"
4
6
 
5
7
  module Milestoner
6
8
  # Handles the tagging of a project repository.
7
9
  class Tagger
8
- include Aids::Git
10
+ extend Forwardable
9
11
 
10
- attr_reader :version_number, :commit_prefixes
12
+ attr_reader :version, :commit_prefixes
11
13
 
12
- def self.version_regex
13
- /\A\d+\.\d+\.\d+\z/
14
- end
14
+ def_delegator :version, :label, :version_label
15
15
 
16
- def initialize version = nil, commit_prefixes: []
17
- @version_number = version
16
+ def initialize version = "0.1.0", commit_prefixes: [], git: Git.new
17
+ @version = Versionaire::Version version
18
18
  @commit_prefixes = commit_prefixes
19
- end
20
-
21
- def version_label
22
- "v#{version_number}"
23
- end
24
-
25
- def version_message
26
- "Version #{version_number}."
19
+ @git = git
27
20
  end
28
21
 
29
22
  def commit_prefix_regex
@@ -32,18 +25,18 @@ module Milestoner
32
25
  end
33
26
 
34
27
  def tagged?
35
- fail(Errors::Git) unless git_supported?
28
+ fail(Errors::Git) unless git.supported?
36
29
  response = `git tag`
37
30
  !(response.nil? || response.empty?)
38
31
  end
39
32
 
40
33
  def duplicate?
41
- fail(Errors::Git) unless git_supported?
42
- system "git rev-parse #{version_label} > /dev/null 2>&1"
34
+ fail(Errors::Git) unless git.supported?
35
+ system "git rev-parse #{version.label} > /dev/null 2>&1"
43
36
  end
44
37
 
45
38
  def commits
46
- fail(Errors::Git) unless git_supported?
39
+ fail(Errors::Git) unless git.supported?
47
40
  groups = build_commit_prefix_groups
48
41
  group_by_commit_prefix! groups
49
42
  sort_by_commit_prefix! groups
@@ -54,32 +47,23 @@ module Milestoner
54
47
  commits.map { |commit| "- #{commit}" }
55
48
  end
56
49
 
57
- def create version = version_number, sign: false
58
- @version_number = validate_version version
59
- fail(Errors::Git) unless git_supported?
60
- fail(Errors::Git, "Unable to tag without commits.") unless git_commits?
61
- fail(Errors::DuplicateTag, "Duplicate tag exists: #{version_label}.") if duplicate?
62
- create_tag sign: sign
63
- end
64
-
65
- def delete version = version_number
66
- @version_number = validate_version version
67
- fail(Errors::Git) unless git_supported?
68
- Open3.capture3 "git tag --delete #{version_label}" if duplicate?
50
+ def create raw_version = version, sign: false
51
+ @version = Versionaire::Version raw_version
52
+ fail(Errors::Git) unless git.supported?
53
+ fail(Errors::Git, "Unable to tag without commits.") unless git.commits?
54
+ fail(Errors::DuplicateTag, "Duplicate tag exists: #{version.label}.") if duplicate?
55
+ git_tag sign: sign
69
56
  end
70
57
 
71
- def destroy
72
- warn "[DEPRECATION]: #destroy is deprecated, use #delete instead."
73
- delete
58
+ def delete raw_version = version
59
+ @version = Versionaire::Version raw_version
60
+ fail(Errors::Git) unless git.supported?
61
+ Open3.capture3 "git tag --delete #{version.label}" if duplicate?
74
62
  end
75
63
 
76
64
  private
77
65
 
78
- def validate_version version
79
- message = "Invalid version: #{version}. Use: <major>.<minor>.<maintenance>."
80
- fail(Errors::Version, message) unless version.match(self.class.version_regex)
81
- version
82
- end
66
+ attr_reader :git
83
67
 
84
68
  def raw_commits
85
69
  log_command = "git log --oneline --no-merges --format='%s'"
@@ -110,20 +94,20 @@ module Milestoner
110
94
  groups.each { |_, values| values.sort! }
111
95
  end
112
96
 
113
- def tag_message
114
- %(#{version_message}\n\n#{commit_list.join "\n"}\n\n)
97
+ def git_message
98
+ %(Version #{version}.\n\n#{commit_list.join "\n"}\n\n)
115
99
  end
116
100
 
117
- def tag_options message_file, sign: false
118
- options = %(--sign --annotate "#{version_label}" --cleanup verbatim --file "#{message_file.path}")
101
+ def git_options message_file, sign: false
102
+ options = %(--sign --annotate "#{version.label}" --cleanup verbatim --file "#{message_file.path}")
119
103
  return options.gsub("--sign ", "") unless sign
120
104
  options
121
105
  end
122
106
 
123
- def create_tag sign: false
107
+ def git_tag sign: false
124
108
  message_file = Tempfile.new Identity.name
125
- File.open(message_file, "w") { |file| file.write tag_message }
126
- `git tag #{tag_options message_file, sign: sign}`
109
+ File.open(message_file, "w") { |file| file.write git_message }
110
+ `git tag #{git_options message_file, sign: sign}`
127
111
  ensure
128
112
  message_file.close
129
113
  message_file.unlink
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milestoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -30,7 +30,7 @@ cert_chain:
30
30
  aSif+qBc6oHD7EQWPF5cZkzkIURuwNwPBngZGxIKaMAgRhjGFXzUMAaq++r59cS9
31
31
  xTfQ4k6fglKEgpnLAXiKdo2c8Ym+X4rIKFfedQ==
32
32
  -----END CERTIFICATE-----
33
- date: 2016-03-14 00:00:00.000000000 Z
33
+ date: 2016-04-04 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: thor
@@ -60,6 +60,20 @@ dependencies:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: versionaire
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.1'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.1'
63
77
  - !ruby/object:Gem::Dependency
64
78
  name: rake
65
79
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +186,62 @@ dependencies:
172
186
  - - ">="
173
187
  - !ruby/object:Gem::Version
174
188
  version: '0'
189
+ - !ruby/object:Gem::Dependency
190
+ name: bond
191
+ requirement: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ type: :development
197
+ prerelease: false
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ - !ruby/object:Gem::Dependency
204
+ name: wirb
205
+ requirement: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ type: :development
211
+ prerelease: false
212
+ version_requirements: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ - !ruby/object:Gem::Dependency
218
+ name: hirb
219
+ requirement: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ">="
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ type: :development
225
+ prerelease: false
226
+ version_requirements: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ - !ruby/object:Gem::Dependency
232
+ name: awesome_print
233
+ requirement: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ type: :development
239
+ prerelease: false
240
+ version_requirements: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - ">="
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
175
245
  - !ruby/object:Gem::Dependency
176
246
  name: rspec
177
247
  requirement: !ruby/object:Gem::Requirement
@@ -312,7 +382,6 @@ files:
312
382
  - README.md
313
383
  - bin/milestoner
314
384
  - lib/milestoner.rb
315
- - lib/milestoner/aids/git.rb
316
385
  - lib/milestoner/cli.rb
317
386
  - lib/milestoner/configuration.rb
318
387
  - lib/milestoner/errors/base.rb
@@ -320,6 +389,7 @@ files:
320
389
  - lib/milestoner/errors/duplicate_tag.rb
321
390
  - lib/milestoner/errors/git.rb
322
391
  - lib/milestoner/errors/version.rb
392
+ - lib/milestoner/git.rb
323
393
  - lib/milestoner/identity.rb
324
394
  - lib/milestoner/publisher.rb
325
395
  - lib/milestoner/pusher.rb
@@ -347,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
347
417
  version: '0'
348
418
  requirements: []
349
419
  rubyforge_project:
350
- rubygems_version: 2.6.1
420
+ rubygems_version: 2.6.2
351
421
  signing_key:
352
422
  specification_version: 4
353
423
  summary: A command line interface for releasing Git repository milestones.
metadata.gz.sig CHANGED
Binary file
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Milestoner
4
- module Aids
5
- # Augments an object with Git support.
6
- module Git
7
- def git_supported?
8
- File.exist? File.join(Dir.pwd, ".git")
9
- end
10
-
11
- def git_commits?
12
- system "git log > /dev/null 2>&1"
13
- end
14
-
15
- def git_remote?
16
- system "git config remote.origin.url"
17
- end
18
- end
19
- end
20
- end