gitscape 1.5 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gitscape/base.rb CHANGED
@@ -44,7 +44,7 @@ class Gitscape::Base
44
44
  end
45
45
 
46
46
  def live_iteration
47
- toRet = `git branch -a --merged live`.split("\n").select{|b| /release\/i(\d+)$/.match b}.map{|b| b.scan(/release\/i(\d+)$/).flatten[0].to_i}.sort.last
47
+ toRet = `git branch -a --merged origin/live`.split("\n").select{|b| /release\/i(\d+)$/.match b}.map{|b| b.scan(/release\/i(\d+)$/).flatten[0].to_i}.sort.last
48
48
  toRet
49
49
  end
50
50
 
@@ -147,7 +147,11 @@ class Gitscape::Base
147
147
  `git checkout #{previous_branch}`
148
148
  end
149
149
 
150
- def release_start
150
+ def release_start options={:push=>true, :update_env=>true}
151
+ # Handle default options
152
+ options[:push] = true if options[:push].nil?
153
+ options[:update_env] = true if options[:update_env].nil?
154
+
151
155
  # Switch to master branch
152
156
  puts `git checkout master`
153
157
  puts `git pull origin master`
@@ -155,47 +159,47 @@ class Gitscape::Base
155
159
  # Check that the working copy is clean
156
160
  exit 1 unless git_working_copy_is_clean
157
161
 
158
- # Figure out the previous and new version numbers
159
- version_file = File.new("version", "r")
160
- previous_version_number = version_file.read.delete("i").to_i
161
- new_version_number = previous_version_number + 1
162
-
163
- # Get the new release_branch_name
164
- release_branch_name = "i#{new_version_number}"
162
+ new_version_number = live_iteration + 1
163
+ release_branch_name = "release/i#{new_version_number}"
165
164
 
166
165
  # Cut the branch
167
- puts `git checkout -b "release/#{release_branch_name}" master`
166
+ puts `git checkout -b "#{release_branch_name}" master`
168
167
  exit 1 unless $?.exitstatus == 0
169
168
 
170
169
  # Bump the version number
171
- `echo "#{release_branch_name}" > ./version`
170
+ `echo "#i{new_version_number}" > ./version`
172
171
  exit 1 unless $?.exitstatus == 0
173
172
 
174
173
  # Commit the bump
175
- puts `git commit -a -m "Begin #{release_branch_name} release candidate"`
174
+ puts `git commit -a -m "Begin i#{new_version_number} release candidate"`
176
175
  exit 1 unless $?.exitstatus == 0
176
+
177
+ # Push to origin
178
+ if options[:push]
179
+ puts `git push origin -u "#{release_branch_name}"`
180
+ exit 1 unless $?.exitstatus == 0
181
+ end
177
182
 
178
183
  # Update qa to the new commit
179
- puts `git push origin "release/#{release_branch_name}:qa"`
180
- exit 1 unless $?.exitstatus == 0
181
-
182
- # Push to origin
183
- puts `git push origin -u "release/#{release_branch_name}"`
184
- exit 1 unless $?.exitstatus == 0
184
+ if options[:update_env]
185
+ puts `git push origin "#{release_branch_name}:qa"`
186
+ exit 1 unless $?.exitstatus == 0
187
+ end
185
188
  end
186
189
 
187
- def release_finish new_version_number=0
190
+ def release_finish options={:push=>true, :update_env=>true}
191
+ # Handle default options
192
+ options[:push] = true if options[:push].nil?
193
+ options[:update_env] = true if options[:update_env].nil?
194
+
188
195
  # Check if the working copy is clean, if not, exit
189
196
  exit 1 unless git_working_copy_is_clean
190
197
 
191
198
  # Get the right release_branch_name to merge
192
- current_version_number = new_version_number - 1
193
- if new_version_number == 0
194
- current_version_number = live_iteration
195
- new_version_number = current_version_number + 1
196
- end
197
- release_branch_name = "release/i#{new_version_number}"
198
- release_branch = @repo.branch release_branch_name
199
+ current_version_number = live_iteration
200
+ new_version_number = current_version_number + 1
201
+
202
+ release_branch = "release/i#{new_version_number}"
199
203
 
200
204
  # Fetch in order to have the latest branch revisions
201
205
 
@@ -206,7 +210,7 @@ class Gitscape::Base
206
210
  branch_revisions = Hash[ branches.map {|branch| [branch["name"], branch["revision"]] } ]
207
211
 
208
212
  # Check if the required branches in sync
209
- required_synced_branches = [[release_branch_name, "remotes/origin/qa"]]
213
+ required_synced_branches = [[release_branch, "remotes/origin/qa"]]
210
214
  required_synced_branches.each do |branch_pair|
211
215
  if branch_revisions[ branch_pair[0] ] != branch_revisions[ branch_pair[0] ]
212
216
  puts "*** ERROR: The #{branch_pair[0]} branch is not the same as the #{branch_pair[1]} branch.
@@ -216,8 +220,8 @@ class Gitscape::Base
216
220
  end
217
221
 
218
222
  # Checkout release branch
219
- puts `git checkout #{release_branch_name}`
220
- puts `git pull origin #{release_branch_name}`
223
+ puts `git checkout #{release_branch}`
224
+ puts `git pull origin #{release_branch}`
221
225
 
222
226
  # Checkout live
223
227
  puts `git checkout live`
@@ -229,12 +233,12 @@ class Gitscape::Base
229
233
  merge_options = "--no-ff -s recursive -Xignore-space-change"
230
234
 
231
235
  # Merge the release branch into live
232
- puts `git merge #{merge_options} #{release_branch_name}`
236
+ puts `git merge #{merge_options} #{release_branch}`
233
237
 
234
238
  # Error and conflict checking
235
239
  if !$?.success? then exit 4 end
236
240
  if git_has_conflicts then
237
- puts "Merge conflicts when pulling #{release_branch_name} into live"
241
+ puts "Merge conflicts when pulling #{release_branch} into live"
238
242
  puts "Please bother Xavier if you see this message :)"
239
243
  exit 2
240
244
  end
@@ -254,12 +258,12 @@ class Gitscape::Base
254
258
  # Merge the release branch into master
255
259
  puts `git checkout master`
256
260
  puts `git pull origin master`
257
- puts `git merge #{merge_options} #{release_branch_name}`
261
+ puts `git merge #{merge_options} #{release_branch}`
258
262
 
259
263
  # Error and conflict checking
260
264
  if !$?.success? then exit 4 end
261
265
  if git_has_conflicts then
262
- puts "Merge conflicts when pulling #{release_branch_name} into master"
266
+ puts "Merge conflicts when pulling #{release_branch} into master"
263
267
  puts "Please bother Xavier if you see this message :)"
264
268
  exit 2
265
269
  end
@@ -276,9 +280,11 @@ class Gitscape::Base
276
280
  puts `git tag -d rollback-to/i#{current_version_number}`
277
281
  exit 4
278
282
  end
279
-
280
- puts `git push origin live --tags`
281
- puts `git push origin master`
283
+
284
+ if options[:push] && options[:update_env]
285
+ puts `git push origin live --tags`
286
+ puts `git push origin master`
287
+ end
282
288
  end
283
289
 
284
290
  # Returns true if the supplied Git commit hash or reference exists
@@ -1,3 +1,3 @@
1
1
  module Gitscape
2
- VERSION = '1.5'
2
+ VERSION = '1.5.1'
3
3
  end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- version: "1.5"
8
+ - 1
9
+ version: 1.5.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Jon Botelho
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2013-04-01 00:00:00 -04:00
18
+ date: 2013-04-02 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency