step-up 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -2
- data/lib/step-up/cli.rb +207 -128
- data/lib/step-up/driver/git.rb +4 -3
- data/lib/step-up/git_extensions.rb +1 -1
- data/lib/step-up/ranged_notes.rb +10 -4
- data/spec/lib/step-up/driver/git_spec.rb +2 -2
- metadata +5 -5
data/README.md
CHANGED
@@ -37,7 +37,7 @@ The format of the version is totally customizable through **.stepuprc** which we
|
|
37
37
|
|
38
38
|
### Creating new version
|
39
39
|
|
40
|
-
stepup version create --level LEVEL_NAME
|
40
|
+
stepup version create [--level LEVEL_NAME]
|
41
41
|
|
42
42
|
where **LEVEL_NAME**
|
43
43
|
|
@@ -65,6 +65,28 @@ The versioning increment is based on the last version tag found in the repositor
|
|
65
65
|
stepup changelog
|
66
66
|
|
67
67
|
## StepUp beyond basics
|
68
|
+
|
69
|
+
### Working with notes
|
70
|
+
|
71
|
+
With StepUp we are able to attach additional comments on existing commit objects.
|
72
|
+
The great goal of this Gem is giving to developers an easy way to manage these notes.
|
73
|
+
The note was created with the following command:
|
74
|
+
|
75
|
+
$ stepup notes add --section bugfixes -m "support for old installations"
|
76
|
+
|
77
|
+
Still with this example we can check the created note with the following command:
|
78
|
+
|
79
|
+
$ stepup notes
|
80
|
+
---
|
81
|
+
Bugfixes:
|
82
|
+
|
83
|
+
- support for old installations
|
84
|
+
|
85
|
+
The command above fetches the entire commit history, gets each note and organizes them in sections.
|
86
|
+
Found notes are displayed as a big changelog message.
|
87
|
+
|
88
|
+
### Creating rich changelogs
|
89
|
+
|
68
90
|
***Comming soon***
|
69
91
|
|
70
92
|
## Project
|
@@ -78,4 +100,4 @@ The versioning increment is based on the last version tag found in the repositor
|
|
78
100
|
* [Marcelo Manzan](https://github.com/kawamanza)
|
79
101
|
|
80
102
|
## Collaborators
|
81
|
-
* [Lucas Fais](https://github.com/lucasfais)
|
103
|
+
* [Lucas Fais](https://github.com/lucasfais)
|
data/lib/step-up/cli.rb
CHANGED
@@ -27,111 +27,18 @@ module StepUp
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
desc "init", "
|
30
|
+
desc "init", "Prepare your project to use stepup"
|
31
31
|
method_options :update => :boolean
|
32
|
+
method_options :gemfile => :boolean
|
33
|
+
method_options :version_file_support => :boolean
|
32
34
|
def init
|
33
|
-
|
34
|
-
|
35
|
-
if options[:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
say_status :skip, "Creating .stepuprc", :yellow
|
42
|
-
end
|
43
|
-
# Changing Gemfile
|
44
|
-
if File.exists?("Gemfile")
|
45
|
-
gem_file = File.read("Gemfile")
|
46
|
-
if gem_file =~ /\bstep-up\b/
|
47
|
-
regex = /^(\s*gem\s+(?:'step-up'|"step-up")\s*,\s*['"])((?:~>|=>|=)\s*.*?)(['"])/
|
48
|
-
if gem_file =~ regex && ! $2.end_with?(StepUp::VERSION)
|
49
|
-
say_status :update, "Updating dependency to step-up on Gemfile", :green
|
50
|
-
File.open("Gemfile", "w") do |f|
|
51
|
-
f.write gem_file.gsub(regex, '\1~> '+StepUp::VERSION+'\3')
|
52
|
-
end
|
53
|
-
else
|
54
|
-
say_status :skip, "Adding dependency to step-up on Gemfile", :yellow
|
55
|
-
end
|
56
|
-
else
|
57
|
-
say_status :update, "Adding dependency to step-up on Gemfile", :green
|
58
|
-
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Gemfile')))
|
59
|
-
stepup_dependency = template_render(content)
|
60
|
-
File.open("Gemfile", "w") do |f|
|
61
|
-
f.write gem_file
|
62
|
-
f.write "\n" unless gem_file.end_with?("\n")
|
63
|
-
f.write stepup_dependency
|
64
|
-
end
|
65
|
-
end
|
66
|
-
else
|
67
|
-
say_status :skip, "Gemfile not found", :yellow
|
68
|
-
end
|
69
|
-
# Creating lib/version.rb
|
70
|
-
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'lib', 'version.rb')))
|
71
|
-
new_version_rb = template_render(content)
|
72
|
-
Dir.mkdir('lib') unless File.exists?('lib')
|
73
|
-
if File.exists?("lib/version.rb")
|
74
|
-
version_rb = File.read("lib/version.rb")
|
75
|
-
if version_rb =~ /\bStepUp\b/
|
76
|
-
say_status :skip, "Creating lib/version.rb", :yellow
|
77
|
-
else
|
78
|
-
say_status :update, "Appending to lib/version.rb", :green
|
79
|
-
File.open("lib/version.rb", "w") do |f|
|
80
|
-
f.write version_rb
|
81
|
-
f.write "\n" unless version_rb.end_with?("\n")
|
82
|
-
f.write new_version_rb
|
83
|
-
end
|
84
|
-
end
|
85
|
-
else
|
86
|
-
say_status :create, "Creating lib/version.rb", :green
|
87
|
-
File.open("lib/version.rb", "w") do |f|
|
88
|
-
f.write new_version_rb
|
89
|
-
end
|
90
|
-
end
|
91
|
-
# Updating Rakefile
|
92
|
-
if File.exists?("Rakefile")
|
93
|
-
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Rakefile')))
|
94
|
-
content = template_render(content)
|
95
|
-
if File.exists?("lib/tasks/versioning.rake") && File.read("lib/tasks/versioning.rake") =~ /\bstep-up\b/
|
96
|
-
content = File.read("lib/tasks/versioning.rake")
|
97
|
-
say_status :remove, "Removing lib/tasks/versioning.rake", :blue
|
98
|
-
`rm lib/tasks/versioning.rake`
|
99
|
-
end
|
100
|
-
rake_file = File.read("Rakefile")
|
101
|
-
if rake_file =~ /\bstep-up\b/
|
102
|
-
say_status :skip, "Appending to Rakefile", :yellow
|
103
|
-
else
|
104
|
-
say_status :update, "Appending to Rakefile", :green
|
105
|
-
File.open("Rakefile", "w") do |f|
|
106
|
-
f.write rake_file
|
107
|
-
f.write "\n" unless rake_file.end_with?("\n")
|
108
|
-
f.write content
|
109
|
-
end
|
110
|
-
end
|
111
|
-
else
|
112
|
-
say_status :ignore, "Ignoring creation of lib/tasks/versioning.rake", :yellow
|
113
|
-
end
|
114
|
-
# Updating Capfile
|
115
|
-
if File.exists?("Capfile") && File.exists?("Rakefile")
|
116
|
-
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Capfile')))
|
117
|
-
content = template_render(content)
|
118
|
-
cap_file = File.read("Capfile")
|
119
|
-
if cap_file =~ /\bstepup\b/
|
120
|
-
say_status :skip, "Appending to Capfile", :yellow
|
121
|
-
else
|
122
|
-
say_status :update, "Appending to Capfile", :green
|
123
|
-
File.open("Capfile", "w") do |f|
|
124
|
-
f.write cap_file
|
125
|
-
f.write "\n" unless cap_file.end_with?("\n")
|
126
|
-
f.write content
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
# Appending .gitignore
|
131
|
-
unless File.exists?(".gitignore") && File.read(".gitignore") =~ /^#{gsub_params['version_file']}$/
|
132
|
-
run "echo #{gsub_params['version_file']} >> .gitignore"
|
133
|
-
else
|
134
|
-
say_status :skip, "Adding #{gsub_params['version_file']} to .gitignore", :yellow
|
35
|
+
init_create_stepuprc
|
36
|
+
init_update_gemfile if options[:gemfile]
|
37
|
+
if options[:version_file_support]
|
38
|
+
init_update_version_helper
|
39
|
+
init_update_rakefile
|
40
|
+
init_update_capfile
|
41
|
+
init_update_gitignore
|
135
42
|
end
|
136
43
|
end
|
137
44
|
|
@@ -150,8 +57,9 @@ module StepUp
|
|
150
57
|
end
|
151
58
|
|
152
59
|
desc "notes ACTION [base_object] [OPTIONS]", "show notes for the next version"
|
153
|
-
method_options :clean => :boolean, :steps => :boolean, :"-m" => :string, :since => :string
|
60
|
+
method_options :clean => :boolean, :steps => :boolean, :"-m" => :string, :since => :string, :after => :string, :upto => :string
|
154
61
|
method_options :fetch => :boolean
|
62
|
+
method_options %w[section -s] => :string
|
155
63
|
def notes(action = "show", commit_base = nil)
|
156
64
|
unless %w[show add remove help].include?(action)
|
157
65
|
commit_base ||= action
|
@@ -162,6 +70,7 @@ module StepUp
|
|
162
70
|
check_notes_config && send("notes_#{action}")
|
163
71
|
else
|
164
72
|
puts "invalid action: #{action}"
|
73
|
+
exit(1)
|
165
74
|
end
|
166
75
|
end
|
167
76
|
|
@@ -200,12 +109,29 @@ module StepUp
|
|
200
109
|
end
|
201
110
|
|
202
111
|
def notes_show
|
112
|
+
if options[:since] && options[:after]
|
113
|
+
puts "conflict of options: --since and --after cannot be used together\n"
|
114
|
+
exit(1)
|
115
|
+
end
|
116
|
+
|
117
|
+
initial_tag = options[:since] || options[:after]
|
118
|
+
if initial_tag && options[:upto] && initial_tag > options[:upto]
|
119
|
+
puts "conflict of options: --since value #{initial_tag} is greater than --after value #{options[:upto]}\n"
|
120
|
+
exit(1)
|
121
|
+
end
|
122
|
+
|
203
123
|
message = []
|
204
|
-
|
205
|
-
message_header = "Showing notes
|
206
|
-
|
124
|
+
if initial_tag || options[:upto]
|
125
|
+
message_header = "Showing notes "
|
126
|
+
if initial_tag
|
127
|
+
option = options[:since] ? "since" : "after"
|
128
|
+
message_header << "#{option} #{ initial_tag } "
|
129
|
+
end
|
130
|
+
message_header << "up to #{ options[:upto] } " if options[:upto]
|
131
|
+
message_header << "(including notes of tags: #{ ranged_notes.scoped_tags.join(", ")})" if ranged_notes.scoped_tags.any?
|
207
132
|
message << message_header
|
208
133
|
end
|
134
|
+
|
209
135
|
message << "---"
|
210
136
|
message << get_notes
|
211
137
|
puts message.join("\n")
|
@@ -217,25 +143,46 @@ module StepUp
|
|
217
143
|
sections = notes.keys
|
218
144
|
if sections.empty?
|
219
145
|
puts "No notes found"
|
220
|
-
|
146
|
+
exit(1)
|
147
|
+
end
|
148
|
+
section = options[:section]
|
149
|
+
if section.nil?
|
221
150
|
if sections.size > 1
|
222
151
|
section = choose(sections, "Which section you want to remove notes?")
|
223
|
-
return unless sections.include?(section)
|
224
152
|
else
|
225
153
|
section = sections.first
|
226
154
|
end
|
227
|
-
steps = driver.steps_to_remove_notes(section, ranged_notes.last_commit)
|
228
|
-
print_or_run(steps, options[:steps])
|
229
155
|
end
|
156
|
+
unless sections.include?(section)
|
157
|
+
puts "Aborting due to invalid section"
|
158
|
+
exit(1)
|
159
|
+
end
|
160
|
+
steps = driver.steps_to_remove_notes(section, ranged_notes.last_commit)
|
161
|
+
print_or_run(steps, options[:steps])
|
230
162
|
end
|
231
163
|
|
232
164
|
def notes_add
|
233
165
|
message = options[:m]
|
234
166
|
message = nil if options[:m] =~ /^(|m)$/
|
235
|
-
|
167
|
+
|
168
|
+
unless message
|
169
|
+
last_commit = driver.commit_history(commit_object, 1, :with_messages => true).first
|
170
|
+
message = last_commit.last if last_commit
|
171
|
+
message << <<-TEXT
|
172
|
+
|
173
|
+
|
174
|
+
# Please enter the note message for your changes. Lines starting
|
175
|
+
# with '#' will be ignored, and an empty message aborts the operation.
|
176
|
+
TEXT
|
177
|
+
message = edit_message(driver.class::NOTE_MESSAGE_FILE_PATH, message)
|
178
|
+
end
|
179
|
+
|
236
180
|
unless message.empty?
|
237
|
-
section = choose(CONFIG.notes_sections.names, "Choose a section to add the note:")
|
238
|
-
|
181
|
+
section = options[:section] || choose(CONFIG.notes_sections.names, "Choose a section to add the note:")
|
182
|
+
if section.nil? || ! CONFIG.notes_sections.names.include?(section)
|
183
|
+
puts "Aborting due to invalid section"
|
184
|
+
exit(1)
|
185
|
+
end
|
239
186
|
steps = driver.steps_for_add_notes(section, message, commit_object)
|
240
187
|
print_or_run(steps, options[:steps])
|
241
188
|
end
|
@@ -257,12 +204,6 @@ module StepUp
|
|
257
204
|
def version_create
|
258
205
|
level = options[:level] || "auto"
|
259
206
|
message = get_notes(true, get_custom_message)
|
260
|
-
message = edit_message(driver.class::VERSION_MESSAGE_FILE_PATH, message) unless options[:'no-editor']
|
261
|
-
|
262
|
-
if message.strip.empty?
|
263
|
-
puts "\ninvalid version message: too short"
|
264
|
-
exit(1)
|
265
|
-
end
|
266
207
|
|
267
208
|
if level == "auto" && CONFIG.versioning["auto_increment"].is_a?(Hash)
|
268
209
|
detached_notes = driver.cached_detached_notes_as_hash(commit_object || "HEAD")
|
@@ -275,6 +216,21 @@ module StepUp
|
|
275
216
|
end
|
276
217
|
|
277
218
|
if version_levels.include? level
|
219
|
+
unless options[:'no-editor']
|
220
|
+
message << <<-TEXT
|
221
|
+
|
222
|
+
|
223
|
+
# Please enter the log message for your tag. Lines starting
|
224
|
+
# with '#' will be ignored, and an empty message aborts the operation.
|
225
|
+
# You are about to increase the '#{level}' version level.
|
226
|
+
TEXT
|
227
|
+
message = edit_message(driver.class::VERSION_MESSAGE_FILE_PATH, message)
|
228
|
+
end
|
229
|
+
|
230
|
+
if message.strip.empty?
|
231
|
+
puts "Aborting due to empty log message"
|
232
|
+
exit(1)
|
233
|
+
end
|
278
234
|
steps = driver.steps_to_increase_version(level, commit_object || "HEAD", message)
|
279
235
|
print_or_run(steps, options[:steps])
|
280
236
|
else
|
@@ -283,6 +239,122 @@ module StepUp
|
|
283
239
|
end
|
284
240
|
end
|
285
241
|
|
242
|
+
|
243
|
+
def init_create_stepuprc
|
244
|
+
content = File.read(File.expand_path("../config/step-up.yml", __FILE__))
|
245
|
+
if options[:update] || ! File.exists?(".stepuprc")
|
246
|
+
say_status File.exists?(".stepuprc") ? :update : :create, ".stepuprc", :green
|
247
|
+
File.open(".stepuprc", "w") do |f|
|
248
|
+
f.write content
|
249
|
+
end
|
250
|
+
else
|
251
|
+
say_status :skip, "Creating .stepuprc", :yellow
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def init_update_gemfile
|
256
|
+
if File.exists?("Gemfile")
|
257
|
+
gem_file = File.read("Gemfile")
|
258
|
+
if gem_file =~ /\bstep-up\b/
|
259
|
+
regex = /^(\s*gem\s+(?:'step-up'|"step-up")\s*,\s*['"])((?:~>|=>|=)\s*.*?)(['"])/
|
260
|
+
if gem_file =~ regex && ! $2.end_with?(StepUp::VERSION)
|
261
|
+
say_status :update, "Updating dependency to step-up on Gemfile", :green
|
262
|
+
File.open("Gemfile", "w") do |f|
|
263
|
+
f.write gem_file.gsub(regex, '\1~> '+StepUp::VERSION+'\3')
|
264
|
+
end
|
265
|
+
else
|
266
|
+
say_status :skip, "Adding dependency to step-up on Gemfile", :yellow
|
267
|
+
end
|
268
|
+
else
|
269
|
+
say_status :update, "Adding dependency to step-up on Gemfile", :green
|
270
|
+
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Gemfile')))
|
271
|
+
stepup_dependency = template_render(content)
|
272
|
+
File.open("Gemfile", "w") do |f|
|
273
|
+
f.write gem_file
|
274
|
+
f.write "\n" unless gem_file.end_with?("\n")
|
275
|
+
f.write stepup_dependency
|
276
|
+
end
|
277
|
+
end
|
278
|
+
else
|
279
|
+
say_status :skip, "Gemfile not found", :yellow
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def init_update_version_helper
|
284
|
+
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'lib', 'version.rb')))
|
285
|
+
new_version_rb = template_render(content)
|
286
|
+
Dir.mkdir('lib') unless File.exists?('lib')
|
287
|
+
if File.exists?("lib/version.rb")
|
288
|
+
version_rb = File.read("lib/version.rb")
|
289
|
+
if version_rb =~ /\bStepUp\b/
|
290
|
+
say_status :skip, "Creating lib/version.rb", :yellow
|
291
|
+
else
|
292
|
+
say_status :update, "Appending to lib/version.rb", :green
|
293
|
+
File.open("lib/version.rb", "w") do |f|
|
294
|
+
f.write version_rb
|
295
|
+
f.write "\n" unless version_rb.end_with?("\n")
|
296
|
+
f.write new_version_rb
|
297
|
+
end
|
298
|
+
end
|
299
|
+
else
|
300
|
+
say_status :create, "Creating lib/version.rb", :green
|
301
|
+
File.open("lib/version.rb", "w") do |f|
|
302
|
+
f.write new_version_rb
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def init_update_rakefile
|
308
|
+
if File.exists?("Rakefile")
|
309
|
+
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Rakefile')))
|
310
|
+
content = template_render(content)
|
311
|
+
if File.exists?("lib/tasks/versioning.rake") && File.read("lib/tasks/versioning.rake") =~ /\bstep-up\b/
|
312
|
+
content = File.read("lib/tasks/versioning.rake")
|
313
|
+
say_status :remove, "Removing lib/tasks/versioning.rake", :blue
|
314
|
+
`rm lib/tasks/versioning.rake`
|
315
|
+
end
|
316
|
+
rake_file = File.read("Rakefile")
|
317
|
+
if rake_file =~ /\bstep-up\b/
|
318
|
+
say_status :skip, "Appending to Rakefile", :yellow
|
319
|
+
else
|
320
|
+
say_status :update, "Appending to Rakefile", :green
|
321
|
+
File.open("Rakefile", "w") do |f|
|
322
|
+
f.write rake_file
|
323
|
+
f.write "\n" unless rake_file.end_with?("\n")
|
324
|
+
f.write content
|
325
|
+
end
|
326
|
+
end
|
327
|
+
else
|
328
|
+
say_status :ignore, "Ignoring creation of lib/tasks/versioning.rake", :yellow
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
def init_update_capfile
|
333
|
+
if File.exists?("Capfile") && File.exists?("Rakefile")
|
334
|
+
content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Capfile')))
|
335
|
+
content = template_render(content)
|
336
|
+
cap_file = File.read("Capfile")
|
337
|
+
if cap_file =~ /\bstepup\b/
|
338
|
+
say_status :skip, "Appending to Capfile", :yellow
|
339
|
+
else
|
340
|
+
say_status :update, "Appending to Capfile", :green
|
341
|
+
File.open("Capfile", "w") do |f|
|
342
|
+
f.write cap_file
|
343
|
+
f.write "\n" unless cap_file.end_with?("\n")
|
344
|
+
f.write content
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def init_update_gitignore
|
351
|
+
unless File.exists?(".gitignore") && File.read(".gitignore") =~ /^#{gsub_params['version_file']}$/
|
352
|
+
run "echo #{gsub_params['version_file']} >> .gitignore"
|
353
|
+
else
|
354
|
+
say_status :skip, "Adding #{gsub_params['version_file']} to .gitignore", :yellow
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
286
358
|
private
|
287
359
|
|
288
360
|
def edit_message(temp_file, initial_content)
|
@@ -294,7 +366,7 @@ module StepUp
|
|
294
366
|
else
|
295
367
|
`#{ editor } #{ temp_file } && wait $!`
|
296
368
|
end
|
297
|
-
File.read(temp_file).rstrip
|
369
|
+
File.read(temp_file).gsub(/^\#.*/m, '').rstrip
|
298
370
|
end
|
299
371
|
end
|
300
372
|
|
@@ -305,22 +377,29 @@ module StepUp
|
|
305
377
|
|
306
378
|
def ranged_notes
|
307
379
|
unless defined? @ranged_notes
|
308
|
-
initial_tag = options[:since] || driver.cached_last_version_tag(commit_object || "HEAD")
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
initial_tag =
|
380
|
+
initial_tag = options[:since] || options[:after] || driver.cached_last_version_tag(commit_object || "HEAD")
|
381
|
+
final_tag = options[:upto] || commit_object || "HEAD"
|
382
|
+
|
383
|
+
if options[:upto] && !(options[:since] || options[:after])
|
384
|
+
initial_tag = driver.all_version_tags.last
|
313
385
|
end
|
314
|
-
|
386
|
+
|
387
|
+
initial_tag = sanitize_tag_version(initial_tag)
|
388
|
+
final_tag = sanitize_tag_version(final_tag)
|
389
|
+
@ranged_notes = StepUp::RangedNotes.new(driver, initial_tag, final_tag, :exclude_initial_tag_notes => options[:after])
|
315
390
|
end
|
316
391
|
@ranged_notes
|
317
392
|
end
|
318
393
|
|
394
|
+
def sanitize_tag_version(tag)
|
395
|
+
tag =~ /[1-9]/ ? tag.gsub(/\+\d*$/, '') : nil
|
396
|
+
end
|
397
|
+
|
319
398
|
def get_notes(clean = options[:clean], custom_message = nil)
|
320
399
|
notes_options = {}
|
321
400
|
notes_options[:mode] = :with_objects unless clean
|
322
401
|
notes_options[:custom_message] = custom_message
|
323
|
-
notes_hash = (options[:since].nil? ? driver.cached_detached_notes_as_hash(commit_object || "HEAD") : ranged_notes.all_notes.as_hash)
|
402
|
+
notes_hash = (options[:since].nil? && options[:after].nil? ? driver.cached_detached_notes_as_hash(commit_object || "HEAD") : ranged_notes.all_notes.as_hash)
|
324
403
|
notes_hash.to_changelog(notes_options)
|
325
404
|
end
|
326
405
|
|
data/lib/step-up/driver/git.rb
CHANGED
@@ -2,6 +2,7 @@ module StepUp
|
|
2
2
|
module Driver
|
3
3
|
class Git < Base
|
4
4
|
VERSION_MESSAGE_FILE_PATH = ".git/TAG_EDITMSG"
|
5
|
+
NOTE_MESSAGE_FILE_PATH = ".git/NOTE_EDITMSG"
|
5
6
|
|
6
7
|
include GitExtensions::Notes
|
7
8
|
|
@@ -68,8 +69,8 @@ module StepUp
|
|
68
69
|
notes = cached_detached_notes_as_hash(commit_base)
|
69
70
|
commands = []
|
70
71
|
commands << "git fetch"
|
71
|
-
commands << "git tag -a -m \"#{ (message || notes.to_changelog).gsub(/([\$\\"])/, '\\\\\1') }\" #{ new_tag } #{ commit_base }"
|
72
|
-
commands << "git push
|
72
|
+
commands << "git tag -a -m \"#{ (message || notes.to_changelog).gsub(/([\$\\"`])/, '\\\\\1') }\" #{ new_tag } #{ commit_base }"
|
73
|
+
commands << "git push #{cached_fetched_remotes("notes").first} refs/tags/#{new_tag}"
|
73
74
|
commands + steps_for_archiving_notes(notes, new_tag)
|
74
75
|
end
|
75
76
|
|
@@ -102,7 +103,7 @@ module StepUp
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def editor_name
|
105
|
-
ENV["EDITOR"] || `git config core.editor`.chomp
|
106
|
+
ENV["GIT_EDITOR"] || ENV["EDITOR"] || `git config core.editor`.chomp
|
106
107
|
end
|
107
108
|
|
108
109
|
def zero_version(commit_base = "HEAD", count_commits = false)
|
@@ -15,7 +15,7 @@ module StepUp
|
|
15
15
|
def steps_for_add_notes(section, message, commit_base = nil)
|
16
16
|
commands = []
|
17
17
|
commands << "git fetch"
|
18
|
-
commands << "git notes --ref=#{ section } add -m \"#{ message.gsub(/([
|
18
|
+
commands << "git notes --ref=#{ section } add -m \"#{ message.gsub(/([\$\\"`])/, '\\\\\1') }\" #{ commit_base }"
|
19
19
|
commands << "git push #{ notes_remote } refs/notes/#{ section }"
|
20
20
|
commands
|
21
21
|
end
|
data/lib/step-up/ranged_notes.rb
CHANGED
@@ -5,7 +5,8 @@ module StepUp
|
|
5
5
|
|
6
6
|
attr_reader :driver, :first_commit, :last_commit
|
7
7
|
|
8
|
-
def initialize(driver, first_commit = nil, last_commit = "HEAD")
|
8
|
+
def initialize(driver, first_commit = nil, last_commit = "HEAD", options={})
|
9
|
+
@include_initial_tag_notes = !options[:exclude_initial_tag_notes]
|
9
10
|
@driver = driver
|
10
11
|
@last_commit = driver.commit_history(last_commit, 1).first
|
11
12
|
first_commit = driver.commit_history(first_commit, 1).first unless first_commit.nil?
|
@@ -43,9 +44,10 @@ module StepUp
|
|
43
44
|
object = driver.commit_history(version_tag, 1).first
|
44
45
|
tags << version_tag if commits.include?(object)
|
45
46
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
if !tags.empty? && include_initial_tag_notes?
|
48
|
+
initial_tag_version_position = all_version_tags.index(tags.last).next
|
49
|
+
initial_tag_version = all_version_tags[initial_tag_version_position]
|
50
|
+
tags << initial_tag_version if initial_tag_version
|
49
51
|
end
|
50
52
|
end
|
51
53
|
@scoped_tags = tags
|
@@ -124,6 +126,10 @@ module StepUp
|
|
124
126
|
notes
|
125
127
|
end
|
126
128
|
|
129
|
+
def include_initial_tag_notes?
|
130
|
+
@include_initial_tag_notes
|
131
|
+
end
|
132
|
+
|
127
133
|
end
|
128
134
|
|
129
135
|
module NotesHash
|
@@ -117,7 +117,7 @@ describe StepUp::Driver::Git do
|
|
117
117
|
|
118
118
|
- sorting tags according to the mask parser" v0.1.0 f4cfcc2
|
119
119
|
|
120
|
-
git push
|
120
|
+
git push origin refs/tags/v0.1.0
|
121
121
|
|
122
122
|
git notes --ref=test_changes remove 8299243c7dac8f27c3572424a348a7f83ef0ce28
|
123
123
|
|
@@ -156,7 +156,7 @@ describe StepUp::Driver::Git do
|
|
156
156
|
|
157
157
|
- sorting tags according to the mask parser" v0.1.0 f4cfcc2
|
158
158
|
|
159
|
-
git push
|
159
|
+
git push origin refs/tags/v0.1.0
|
160
160
|
|
161
161
|
git notes --ref=test_versioning add -m "available on v0.1.0" 8299243c7dac8f27c3572424a348a7f83ef0ce28
|
162
162
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: step-up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcelo Manzan
|
@@ -16,8 +16,8 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
20
|
-
default_executable:
|
19
|
+
date: 2011-04-28 00:00:00 -03:00
|
20
|
+
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: thor
|