bump 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +17 -5
  3. data/bin/bump +2 -0
  4. data/lib/bump.rb +25 -9
  5. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4cc77e3ae46a84602fc8c584624d77b69a44ef4e
4
- data.tar.gz: a8a1fad7cc8f4f3db749556b81f1c51c168aaaa0
2
+ SHA256:
3
+ metadata.gz: edcda9c3ea370efa0927b59c72718d997c204026139349f9c3ed8a5d62b688d8
4
+ data.tar.gz: c866f3dd937aad196d1bc1204115698f4f28ebc027abdca2ea07ded1ede4ef3d
5
5
  SHA512:
6
- metadata.gz: e170caed9096057c8826562869cfd62b30b6cb25577b601242e17e3e603d620ddd5f43890cb7e47aa506719d2d198d13c18d581cfeaa21053c75757c3247d575
7
- data.tar.gz: 48323ff4e45dd6d626781b7251402376c5821cb14f8bcb3ed5b9c8cf198f0af6893c69c3356ff26fdece50e6466e247069022fbcc79db85e71223951595d976a
6
+ metadata.gz: d911a104915b66431136fece97b24853b039bddde41f30839a95d104647280e108f567da9359f2740b37d625ad81941a4fbf64a5e9c8914475bb95b86e21ecff
7
+ data.tar.gz: 2ca0ed62d336d9db203a7ee864498e14e8eab70316179ae92649803a426d2a6f75f1349a9c5d5ecf5ccb9b9431004f7a05d2b7edbb854512f2ea62408c682632
data/README.md CHANGED
@@ -17,7 +17,7 @@ A gem to bump versions of gems and chef-cookbooks.
17
17
 
18
18
  bump current
19
19
 
20
- > Current version: 0.1.2
20
+ > 0.1.2
21
21
 
22
22
  ### Bump (major, minor, patch, pre)
23
23
 
@@ -29,13 +29,13 @@ A gem to bump versions of gems and chef-cookbooks.
29
29
 
30
30
  bump show-next patch
31
31
 
32
- > Next patch version: 0.1.3
32
+ > 0.1.3
33
33
 
34
34
  ### Show version file path
35
35
 
36
36
  bump file
37
37
 
38
- > Version file path: lib/foo/version.rb
38
+ > lib/foo/version.rb
39
39
 
40
40
  ## Options
41
41
 
@@ -66,7 +66,7 @@ Do not run `bundle` command after bumping.
66
66
 
67
67
  Bump the version in additional files.
68
68
 
69
- bump patch --reaplace-in Readme.md
69
+ bump patch --replace-in Readme.md
70
70
 
71
71
  ### `--commit-message [MSG], -m [MSG]`
72
72
 
@@ -80,7 +80,7 @@ or
80
80
 
81
81
  ### `--changelog`
82
82
 
83
- Update `CHANGELOG.md` when bumping.
83
+ Updates `CHANGELOG.md` when bumping.
84
84
  This requires a heading (starting with `##`) that includes the previous version and a heading above that, for example:
85
85
 
86
86
  ```markdown
@@ -91,6 +91,16 @@ This requires a heading (starting with `##`) that includes the previous version
91
91
  - Added foo
92
92
  ```
93
93
 
94
+ ### `--edit-changelog`
95
+
96
+ Updates CHANGELOG.md when bumping (see above), and
97
+ opens the changelog in an editor specified in `$EDITOR` (or `vi`),
98
+ then waits for the editor to be closed and continues.
99
+
100
+ ```bash
101
+ EDITOR="subl -n -w" bump patch --edit-changelog
102
+ ```
103
+
94
104
  ## Rake
95
105
 
96
106
  ```ruby
@@ -106,6 +116,8 @@ require "bump/tasks"
106
116
  #
107
117
  # Maintain changelog:
108
118
  # Bump.changelog = true
119
+ # Opens the changelog in an editor when bumping
120
+ # Bump.changelog = :editor
109
121
  ```
110
122
 
111
123
  rake bump:current # display current version
data/bin/bump CHANGED
@@ -28,6 +28,8 @@ OptionParser.new do |opts|
28
28
  opts.on("--tag-prefix TAG_PREFIX", "Prefix the tag with this string, ex. 'v'") { |tag_prefix| options[:tag_prefix] = tag_prefix }
29
29
  opts.on("--replace-in FILE", String, "Replace old version with the new version additionally in this file") { |f| (options[:replace_in] ||= []) << f }
30
30
  opts.on("--changelog", "Update CHANGELOG.md") { options[:changelog] = true }
31
+ opts.on("--edit-changelog", "Use $EDITOR to open changelog before committing, e.g. 'subl -n -w' or 'nano'.") { options[:changelog] = :editor }
32
+ opts.on("--value-only", "Do not prefix the output with any descriptive text") { options[:value_only] = true }
31
33
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
32
34
  end.parse!
33
35
 
@@ -43,14 +43,14 @@ module Bump
43
43
 
44
44
  bump_set(options[:version], options)
45
45
  when "current"
46
- ["Current version: #{current}", 0]
46
+ [current, 0]
47
47
  when "show-next"
48
48
  increment = options[:increment]
49
49
  raise InvalidIncrementError unless BUMPS.include?(increment)
50
50
 
51
51
  [next_version(increment), 0]
52
52
  when "file"
53
- ["Version file path: #{file}", 0]
53
+ [file, 0]
54
54
  else
55
55
  raise InvalidOptionError
56
56
  end
@@ -145,6 +145,8 @@ module Bump
145
145
  error = bump_changelog(log, next_version)
146
146
  return [error, 1] if error
147
147
 
148
+ open_changelog(log) if options[:changelog] == :editor
149
+
148
150
  git_add log if options[:commit]
149
151
  end
150
152
 
@@ -152,12 +154,21 @@ module Bump
152
154
  commit next_version, options if options[:commit]
153
155
 
154
156
  # tell user the result
155
- ["Bump version #{current} to #{next_version}", 0]
157
+ [next_version, 0]
158
+ end
159
+
160
+ def open_changelog(log)
161
+ editor = ENV['EDITOR'] || "vi"
162
+ system "#{editor} #{log}"
156
163
  end
157
164
 
158
165
  def bundler_with_clean_env(&block)
159
166
  if defined?(Bundler)
160
- Bundler.with_clean_env(&block)
167
+ if Bundler.respond_to?(:with_unbundled_env)
168
+ Bundler.with_unbundled_env(&block)
169
+ else
170
+ Bundler.with_clean_env(&block)
171
+ end
161
172
  else
162
173
  yield
163
174
  end
@@ -177,16 +188,21 @@ module Bump
177
188
  def bump_changelog(file, current)
178
189
  parts = File.read(file).split(/(^##+.*)/) # headlines and their content
179
190
  prev_index = parts.index { |p| p =~ /(^##+.*(\d+\.\d+\.\d+(\.[a-z]+)?).*)/ } # position of previous version
180
- return "Unable to find previous version" unless prev_index
191
+ return "Unable to find previous version in CHANGELOG.md" unless prev_index
181
192
 
182
193
  # reuse the same style by just swapping the numbers
183
- new_heading = "\n" + parts[prev_index].sub($2, current)
184
-
194
+ new_heading = parts[prev_index].sub($2, current)
185
195
  # add current date if previous heading used that
186
196
  new_heading.sub!(/\d\d\d\d-\d\d-\d\d/, Time.now.strftime('%Y-%m-%d'))
187
197
 
188
- # put our new heading underneath the "Next" heading, which should be above the last version
189
- parts.insert prev_index - 1, new_heading
198
+ if prev_index < 2
199
+ # previous version is first '##' element (no '## Next' present), add line feed after version to avoid
200
+ # '## v1.0.1## v1.0.0'
201
+ parts.insert prev_index - 1, new_heading + "\n"
202
+ else
203
+ # put our new heading underneath the "Next" heading, which should be above the last version
204
+ parts.insert prev_index - 1, "\n" + new_heading
205
+ end
190
206
 
191
207
  File.write file, parts.join("")
192
208
  nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Marcilhacy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description:
69
+ description:
70
70
  email: g.marcilhacy@gmail.com
71
71
  executables:
72
72
  - bump
@@ -81,7 +81,7 @@ homepage: https://github.com/gregorym/bump
81
81
  licenses:
82
82
  - MIT
83
83
  metadata: {}
84
- post_install_message:
84
+ post_install_message:
85
85
  rdoc_options: []
86
86
  require_paths:
87
87
  - lib
@@ -96,9 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubyforge_project:
100
- rubygems_version: 2.4.5.1
101
- signing_key:
99
+ rubygems_version: 3.1.2
100
+ signing_key:
102
101
  specification_version: 4
103
102
  summary: Bump your gem version file
104
103
  test_files: []