step-up 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/.stepuprc CHANGED
@@ -22,10 +22,9 @@ notes:
22
22
  label: "Deploy steps:"
23
23
  tag: "deploy_step"
24
24
  versioning:
25
- version_mask: "v0.0.0.9.rc9"
25
+ version_mask: "v0.0.0.9"
26
26
  version_levels:
27
27
  - major
28
28
  - minor
29
- - tiny
30
29
  - patch
31
- - rc
30
+ - tiny
data/lib/step-up/cli.rb CHANGED
@@ -35,24 +35,19 @@ module StepUp
35
35
  else
36
36
  say_status :skip, "Creating .stepuprc", :yellow
37
37
  end
38
- # add entry to .git/config
39
- remotes_with_notes = driver.fetched_remotes('notes')
40
- unfetched_remotes = driver.fetched_remotes - remotes_with_notes
41
- unless remotes_with_notes.any? || unfetched_remotes.empty?
42
- if unfetched_remotes.size > 1
43
- remote = choose(unfetched_remotes, "Which remote would you like to fetch notes?")
44
- return unless unfetched_remotes.include?(remote)
45
- else
46
- remote = unfetched_remotes.first
47
- end
48
- cmds = ["git config --add remote.#{ remote }.fetch +refs/notes/*:refs/notes/*"]
49
- print_or_run(cmds, false)
50
- end
51
38
  # Changing Gemfile
52
39
  if File.exists?("Gemfile")
53
40
  gem_file = File.read("Gemfile")
54
41
  if gem_file =~ /\bstep-up\b/
55
- say_status :skip, "Adding dependency to step-up on Gemfile", :yellow
42
+ regex = /^(\s*gem\s+(?:'step-up'|"step-up")\s*,\s*['"])((?:~>|=>|=)\s*.*?)(['"])/
43
+ if gem_file =~ regex && ! $2.end_with?(StepUp::VERSION)
44
+ say_status :update, "Updating dependency to step-up on Gemfile", :green
45
+ File.open("Gemfile", "w") do |f|
46
+ f.write gem_file.gsub(regex, '\1~> '+StepUp::VERSION+'\3')
47
+ end
48
+ else
49
+ say_status :skip, "Adding dependency to step-up on Gemfile", :yellow
50
+ end
56
51
  else
57
52
  say_status :update, "Adding dependency to step-up on Gemfile", :green
58
53
  content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Gemfile')))
@@ -88,16 +83,43 @@ module StepUp
88
83
  f.write new_version_rb
89
84
  end
90
85
  end
91
- # Creating lib/tasks/versioning.rake
92
- if File.exists?("lib/tasks/versioning.rake")
93
- say_status :skip, "Creating lib/tasks/versioning.rake", :yellow
86
+ # Updating Rakefile
87
+ if File.exists?("Rakefile")
88
+ content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Rakefile')))
89
+ content = template_render(content)
90
+ if File.exists?("lib/tasks/versioning.rake") && File.read("lib/tasks/versioning.rake") =~ /\bstep-up\b/
91
+ content = File.read("lib/tasks/versioning.rake")
92
+ say_status :remove, "Removing lib/tasks/versioning.rake", :blue
93
+ `rm lib/tasks/versioning.rake`
94
+ end
95
+ rake_file = File.read("Rakefile")
96
+ if rake_file =~ /\bstep-up\b/
97
+ say_status :skip, "Appending to Rakefile", :yellow
98
+ else
99
+ say_status :update, "Appending to Rakefile", :green
100
+ File.open("Rakefile", "w") do |f|
101
+ f.write rake_file
102
+ f.write "\n" unless rake_file.end_with?("\n")
103
+ f.write content
104
+ end
105
+ end
94
106
  else
95
- say_status :create, "Creating lib/tasks/versioning.rake", :green
96
- content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'lib', 'tasks', 'versioning.rake')))
107
+ say_status :ignore, "Ignoring creation of lib/tasks/versioning.rake", :yellow
108
+ end
109
+ # Updating Capfile
110
+ if File.exists?("Capfile") && File.exists?("Rakefile")
111
+ content = File.read(File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates', 'default', 'Capfile')))
97
112
  content = template_render(content)
98
- Dir.mkdir('lib/tasks') unless File.exists?('lib/tasks')
99
- File.open("lib/tasks/versioning.rake", "w") do |f|
100
- f.write content
113
+ cap_file = File.read("Capfile")
114
+ if cap_file =~ /\bstepup\b/
115
+ say_status :skip, "Appending to Capfile", :yellow
116
+ else
117
+ say_status :update, "Appending to Capfile", :green
118
+ File.open("Capfile", "w") do |f|
119
+ f.write cap_file
120
+ f.write "\n" unless cap_file.end_with?("\n")
121
+ f.write content
122
+ end
101
123
  end
102
124
  end
103
125
  # Appending .gitignore
@@ -130,7 +152,7 @@ module StepUp
130
152
  action = "show"
131
153
  end
132
154
  if self.respond_to?("notes_#{action}")
133
- send("notes_#{action}", commit_base)
155
+ check_notes_config && send("notes_#{action}", commit_base)
134
156
  else
135
157
  puts "invalid action: #{action}"
136
158
  end
@@ -335,6 +357,24 @@ module StepUp
335
357
  exit(1) unless status
336
358
  end
337
359
  end
360
+
361
+ def check_notes_config
362
+ remotes_with_notes = driver.fetched_remotes('notes')
363
+ unfetched_remotes = driver.fetched_remotes - remotes_with_notes
364
+ unless remotes_with_notes.any? || unfetched_remotes.empty?
365
+ answer = raw_ask("To perform this operation you need some additional fetch instruction on your git-config file.\nMay stepup add the missing instruction for you? [yes/no]:")
366
+ return false unless answer == "yes"
367
+ if unfetched_remotes.size > 1
368
+ remote = choose(unfetched_remotes, "Which remote would you like to fetch notes?")
369
+ return false unless unfetched_remotes.include?(remote)
370
+ else
371
+ remote = unfetched_remotes.first
372
+ end
373
+ cmds = ["git config --add remote.#{remote}.fetch +refs/notes/*:refs/notes/*", "git fetch #{remote}"]
374
+ print_or_run(cmds, false)
375
+ end
376
+ true
377
+ end
338
378
 
339
379
  def get_custom_message
340
380
  message = options[:message]
@@ -1,7 +1,7 @@
1
1
  notes:
2
2
  after_versioned:
3
- strategy: "remove"
4
- #strategy: "keep"
3
+ #strategy: "remove"
4
+ strategy: "keep"
5
5
  section: "versioning"
6
6
  changelog_message: "available on {version}"
7
7
  sections:
@@ -0,0 +1,8 @@
1
+
2
+ after "deploy:update_code" , "stepup:version_file"
3
+ namespace :stepup do
4
+ desc "[internal] Creates tempfile {{version_file}}"
5
+ task :version_file do
6
+ run %(cd #{current_release};rake stepup:version_file)
7
+ end
8
+ end
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcelo Manzan
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-04 00:00:00 -02:00
19
+ date: 2011-02-10 00:00:00 -02:00
20
20
  default_executable: stepup
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -87,8 +87,9 @@ files:
87
87
  - lib/step-up/parser/version_mask.rb
88
88
  - lib/step-up/ranged_notes.rb
89
89
  - lib/step-up/version.rb
90
+ - templates/default/Capfile
90
91
  - templates/default/Gemfile
91
- - templates/default/lib/tasks/versioning.rake
92
+ - templates/default/Rakefile
92
93
  - templates/default/lib/version.rb
93
94
  - spec/lib/config_spec.rb
94
95
  - spec/lib/step-up/driver/git_spec.rb