gitscape 1.5.7 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gitscape CHANGED
@@ -71,6 +71,8 @@ else
71
71
  Gitscape::Base.new.release_start options
72
72
  when "release_finish"
73
73
  Gitscape::Base.new.release_finish options
74
+ when "tag_cleanup"
75
+ Gitscape::Base.new.tag_cleanup options
74
76
  else
75
77
  puts "Unknown command: #{command_name}"
76
78
  end
data/lib/gitscape/base.rb CHANGED
@@ -81,7 +81,7 @@ class Gitscape::Base
81
81
  puts `git checkout live`
82
82
  puts `git pull origin`
83
83
 
84
- if hotfix_branch.length == 0
84
+ if hotfix_branch.to_s.length == 0
85
85
  exception_message = "*** Improper Usage ***\nExpected Usage: hotfix_start <hotfix_name> [--[no-]push]"
86
86
  raise exception_message
87
87
  end
@@ -93,11 +93,11 @@ class Gitscape::Base
93
93
  puts `git push origin #{hotfix_branch}` if options[:push]
94
94
  end
95
95
 
96
- def hotfix_finish hotfix_branch=nil, options={:env_depth=>:staging, :push=>true, :update_env=>true}
96
+ def hotfix_finish hotfix_branch=nil, options={:env_depth=>:staging, :push=>true, :update_env=>false}
97
97
  # option defaults
98
98
  options[:env_depth] = :staging if options[:env_depth].nil?
99
99
  options[:push] = true if options[:push].nil?
100
- options[:update_env] = true if options[:update_env].nil?
100
+ options[:update_env] = false if options[:update_env].nil?
101
101
 
102
102
  usage_string = "expected usage: hotfix_finish [<hotfix_branch>]
103
103
  hotfix_branch: the name of the hotfix branch to finish.
@@ -292,6 +292,26 @@ class Gitscape::Base
292
292
  puts `git push origin master`
293
293
  end
294
294
  end
295
+
296
+ def tag_cleanup options={:push => true}
297
+ # Handle default options
298
+ options[:push] = true if options[:push].nil?
299
+
300
+ # Do a fetch in order to ensure we have all the latest tags
301
+ `git fetch`
302
+
303
+ # Select which tags to keep.
304
+ # We currently keep tags which fulfill any of the following
305
+ # 1. starts with 'service/'
306
+ # 2. starts with 'rollback-to/' or 'live/', and has an iteration number >= the live_iteration number - 3
307
+ tags = `git tag`.split "\n"
308
+ tags_to_delete = tags.select { |tag| !(!/^service\//.match(tag).nil? || /^(?:live|rollback-to)\/i(\d+)/.match(tag).to_a[1].to_i >= live_iteration - 3) }
309
+
310
+ puts "Deleting the following tags.\nThese changes #{options[:push] ? "will" : "will not"} be pushed to origin.\n"
311
+
312
+ tags_to_delete.each { |tag| puts `git tag -d #{tag}` }
313
+ tags_to_delete.each { |tag| puts `git push origin :refs/tags/#{tag}` } if options[:push]
314
+ end
295
315
 
296
316
  # Returns true if the supplied Git commit hash or reference exists
297
317
  def self.commit_exists?(commit_id)
@@ -1,3 +1,3 @@
1
1
  module Gitscape
2
- VERSION = '1.5.7'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 5
8
- - 7
9
- version: 1.5.7
7
+ - 6
8
+ - 1
9
+ version: 1.6.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jon Botelho
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-17 00:00:00 -04:00
18
+ date: 2013-05-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency