capistrano-gitflow 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d000bf44f50e77b3dbea01aabc5e3bd14d0cbf2
4
+ data.tar.gz: 6c4f309adee905011a3334d0884aac076b143bab
5
+ SHA512:
6
+ metadata.gz: 564c7e7815e3b5e1081aac04648af129f3e86a17cdcc32ac10c7354088d030f702c7ebbe1ec06a107172e9d49062a5951e5dc5ce58b503e04a7550c3768a62a4
7
+ data.tar.gz: ccc62ab240bbfdd691f053690618d7ede6eef579a7ee84b6ae872fd2847e975bcc15dabd7433d877dfb35769b82668811c97aba1f915898a2651e163d4b52cda
data/.gitignore ADDED
@@ -0,0 +1,76 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # For TextMate
19
+ *.tmproj
20
+ tmtags
21
+
22
+ # For emacs:
23
+ *~
24
+ \#*
25
+ .\#*
26
+
27
+ # For vim:
28
+ *.swp
29
+
30
+ # For redcar:
31
+ .redcar
32
+
33
+ # For rubinius:
34
+ *.rbc
35
+ /nbproject/private/
36
+
37
+ /tmp/
38
+
39
+
40
+ # Logs and databases #
41
+ ######################
42
+ *.log
43
+ *.sql
44
+ *.sqlite
45
+
46
+ # OS generated files #
47
+ ######################
48
+ *~
49
+ .DS_Store
50
+ .DS_Store?
51
+ ._*
52
+ .Spotlight-V100
53
+ .Trashes
54
+ Icon?
55
+ ehthumbs.db
56
+ Thumbs.db
57
+ .rvmrc
58
+ s.rbx/
59
+ .bundle/
60
+ *.gem
61
+ .idea/
62
+ .rvmrc
63
+ *.swp
64
+ log/*.log
65
+ pkg/
66
+ spec/dummy/db/*.sqlite3
67
+ spec/dummy/log/*.log
68
+ spec/dummy/tmp/
69
+ gemfiles
70
+ coverage
71
+ tags
72
+ /nbproject/
73
+ /.git-rewrite/
74
+ .rbenv-version
75
+ .ruby-version
76
+ Gemfile.lock
data/README.rdoc CHANGED
@@ -10,17 +10,18 @@ Gitflow simply adds some tagging/logging/workflow magic.
10
10
  # AFTER
11
11
  $ cap deploy
12
12
  # 'master' goes to staging; tag staging-YYYY-MM-DD.X created
13
+
13
14
  $ cap production deploy
14
15
  # deploys latest staging tag, or if last tag is a production tag then that, to production
15
- # for specifying the tag by hand add `-s tag=staging-YYYY-MM-DD-X-user-description`
16
+ # displays a commit log of what will be pushed to production, requests confirmation before deploying
16
17
  # tag 'staging-YYYY-MM-DD-X' goes to production
17
18
  # tag 'production-YYYY-MM-DD-X' created; points to staging-YYYY-MM-DD-X
18
19
 
19
20
  # BONUS
20
- cap gitflow:commit_log
21
+ $ cap gitflow:commit_log
21
22
  # displays a commit log pushed to staging
22
- # ... alternatively, if you're using GitHub, will open a page using branch compare
23
- cap production gitflow:log_log
23
+
24
+ $ cap production gitflow:commit_log
24
25
  # displays a commit log of what will be pushed to production
25
26
 
26
27
  == INSTALLATION
@@ -34,6 +35,8 @@ Then update config/deploy.rb
34
35
  require 'capistrano/ext/multistage'
35
36
  require 'capistrano/gitflow' # needs to come after multistage
36
37
 
38
+ More info at: http://rubygems.org/gems/capistrano-gitflow
39
+
37
40
  == DETAILS
38
41
 
39
42
  After experimenting with several workflows for deployment in git, I've finally found one I really like.
@@ -56,12 +59,15 @@ gitflow will automatically:
56
59
 
57
60
  === PUSH TO PRODUCTION:
58
61
 
59
- Whenever you want to push code to production, you must specify the staging tag you wish to promote to production:
62
+ Whenever you want to push code to production, just do:
60
63
 
61
- cap production deploy -s tag=staging-2009-09-08.2
64
+ cap production deploy
62
65
 
63
66
  gitflow will automatically:
64
67
 
68
+ * determine the last staging tag created, show a commit log of last-production-tag..last-staging-tag
69
+ * (alternatively, specify the tag to push to production via `-s tag=staging-YYYY-MM-DD-X-user-description`
70
+ * prompt for confirmation of deploy
65
71
  * alias the staging tag to a production tag like: production-2008-09-08.2
66
72
  * configure multistage to use that tag for the deploy
67
73
  * push the code and tags to the remote "origin"
@@ -74,4 +80,32 @@ gitflow will automatically:
74
80
 
75
81
  == CREDIT
76
82
 
77
- Originally forked from Alan Pinstein's git_deployment repo. Gemified and hacked by Josh Nichols. There wasn't really a license originally, so...
83
+ Originally created by Alan Pinstein.
84
+
85
+ Gemified and hacked by Josh Nichols.
86
+
87
+ == LICENSE
88
+
89
+ MIT licensed.
90
+
91
+ Copyright (c) 2009-2011 Alan Pinstein <apinstein@mac.com>
92
+
93
+ Copyright (c) 2010-2011 Josh Nichols
94
+
95
+ Permission is hereby granted, free of charge, to any person obtaining a copy
96
+ of this software and associated documentation files (the "Software"), to deal
97
+ in the Software without restriction, including without limitation the rights
98
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
+ copies of the Software, and to permit persons to whom the Software is
100
+ furnished to do so, subject to the following conditions:
101
+
102
+ The above copyright notice and this permission notice shall be included in
103
+ all copies or substantial portions of the Software.
104
+
105
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
106
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
107
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
108
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
109
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
110
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
111
+ THE SOFTWARE.
@@ -3,44 +3,32 @@
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
+ require File.expand_path("../lib/capistrano/gitflow/version", __FILE__)
7
+
6
8
  Gem::Specification.new do |s|
7
9
  s.name = %q{capistrano-gitflow}
8
- s.version = "1.4.3"
9
-
10
+ s.version = CapistranoGitFlow.gem_version
11
+
10
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
13
  s.authors = ["Joshua Nichols"]
12
- s.date = %q{2011-04-07}
14
+ s.date =%q{2011-04-07}
13
15
  s.description = %q{Capistrano recipe for a deployment workflow based on git tags}
14
16
  s.email = %q{josh@technicalpickles.com}
15
17
  s.extra_rdoc_files = [
16
18
  "README.rdoc"
17
19
  ]
18
- s.files = [
19
- ".document",
20
- "README.rdoc",
21
- "Rakefile",
22
- "VERSION",
23
- "capistrano-gitflow.gemspec",
24
- "lib/capistrano/gitflow.rb",
25
- "lib/capistrano/gitflow/natcmp.rb",
26
- "recipes/gitflow_recipes.rb",
27
- "spec/gitflow_spec.rb",
28
- "spec/spec.opts",
29
- "spec/spec_helper.rb"
30
- ]
20
+ s.files = `git ls-files`.split("\n")
21
+
31
22
  s.homepage = %q{http://github.com/technicalpickles/capistrano-gitflow}
32
23
  s.require_paths = ["lib"]
33
24
  s.rubygems_version = %q{1.3.7}
34
25
  s.summary = %q{Capistrano recipe for a deployment workflow based on git tags}
35
- s.test_files = [
36
- "spec/gitflow_spec.rb",
37
- "spec/spec_helper.rb"
38
- ]
39
-
26
+ s.test_files =s.files.grep(/^(spec)/)
27
+
40
28
  if s.respond_to? :specification_version then
41
29
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
30
  s.specification_version = 3
43
-
31
+
44
32
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
33
  s.add_runtime_dependency(%q<capistrano>, [">= 0"])
46
34
  s.add_runtime_dependency(%q<stringex>, [">= 0"])
@@ -1,196 +1,14 @@
1
- require 'capistrano'
2
- require 'capistrano/gitflow/natcmp'
1
+ # require 'capistrano'
3
2
  require 'stringex'
3
+ Gem.find_files('capistrano/gitflow/helpers/**/*.rb').each { |path| require path }
4
+ require 'capistrano/version'
4
5
 
5
- module Capistrano
6
- class Gitflow
7
- def self.load_into(capistrano_configuration)
8
- capistrano_configuration.load do
9
- before "deploy:update_code", "gitflow:calculate_tag"
10
- before "gitflow:calculate_tag", "gitflow:verify_up_to_date"
6
+ self.extend CapistranoGitFlow::Helper
7
+ include CapistranoGitFlow::Helper
11
8
 
12
- namespace :gitflow do
13
- def last_tag_matching(pattern)
14
- matching_tags = `git tag -l '#{pattern}'`.split
15
- matching_tags.sort! do |a,b|
16
- String.natcmp(b, a, true)
17
- end
18
9
 
19
- last_tag = if matching_tags.length > 0
20
- matching_tags[0]
21
- else
22
- nil
23
- end
24
- end
25
-
26
- def last_staging_tag()
27
- last_tag_matching('staging-*')
28
- end
29
-
30
- def next_staging_tag
31
- hwhen = Date.today.to_s
32
- who = `whoami`.chomp.to_url
33
- what = Capistrano::CLI.ui.ask("What does this release introduce? (this will be normalized and used in the tag for this release) ").to_url
34
-
35
- last_staging_tag = last_tag_matching("staging-#{hwhen}-*")
36
- new_tag_serial = if last_staging_tag && last_staging_tag =~ /staging-[0-9]{4}-[0-9]{2}-[0-9]{2}\-([0-9]*)/
37
- $1.to_i + 1
38
- else
39
- 1
40
- end
41
-
42
- "#{stage}-#{hwhen}-#{new_tag_serial}-#{who}-#{what}"
43
- end
44
-
45
- def last_production_tag()
46
- last_tag_matching('production-*')
47
- end
48
-
49
- def using_git?
50
- fetch(:scm, :git).to_sym == :git
51
- end
52
-
53
- task :verify_up_to_date do
54
- if using_git?
55
- set :local_branch, `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`.gsub(/\* /, '').chomp
56
- set :local_sha, `git log --pretty=format:%H HEAD -1`.chomp
57
- set :origin_sha, `git log --pretty=format:%H #{local_branch} -1`
58
- unless local_sha == origin_sha
59
- abort """
60
- Your #{local_branch} branch is not up to date with origin/#{local_branch}.
61
- Please make sure you have pulled and pushed all code before deploying:
62
-
63
- git pull origin #{local_branch}
64
- # run tests, etc
65
- git push origin #{local_branch}
66
-
67
- """
68
- end
69
- end
70
- end
71
-
72
- desc "Calculate the tag to deploy"
73
- task :calculate_tag do
74
- if using_git?
75
- # make sure we have any other deployment tags that have been pushed by others so our auto-increment code doesn't create conflicting tags
76
- `git fetch`
77
-
78
- if respond_to?("tag_#{stage}")
79
- send "tag_#{stage}"
80
-
81
- system "git push --tags origin #{local_branch}"
82
- if $? != 0
83
- abort "git push failed"
84
- end
85
- end
86
- end
87
- end
88
-
89
- desc "Show log between most recent staging tag (or given tag=XXX) and last production release."
90
- task :commit_log do
91
- from_tag = if stage == :production
92
- last_production_tag
93
- elsif stage == :staging
94
- last_staging_tag
95
- else
96
- abort "Unsupported stage #{stage}"
97
- end
98
-
99
- # no idea how to properly test for an optional cap argument a la '-s tag=x'
100
- to_tag = capistrano_configuration[:tag]
101
- to_tag ||= begin
102
- puts "Calculating 'end' tag for :commit_log for '#{stage}'"
103
- to_tag = if stage == :production
104
- last_staging_tag
105
- elsif stage == :staging
106
- 'master'
107
- else
108
- abort "Unsupported stage #{stage}"
109
- end
110
- end
111
-
112
-
113
- command = if `git config remote.origin.url` =~ /git@github.com:(.*)\/(.*).git/
114
- "open https://github.com/#{$1}/#{$2}/compare/#{from_tag}...#{to_tag || 'master'}"
115
- else
116
- log_subcommand = if ENV['git_log_command'] && ENV['git_log_command'].strip != ''
117
- ENV['git_log_command']
118
- else
119
- 'log'
120
- end
121
- "git #{log_subcommand} #{fromTag}..#{toTag}"
122
- end
123
- puts command
124
- system command
125
- end
126
-
127
- desc "Mark the current code as a staging/qa release"
128
- task :tag_staging do
129
- current_sha = `git log --pretty=format:%H HEAD -1`
130
- last_staging_tag_sha = if last_staging_tag
131
- `git log --pretty=format:%H #{last_staging_tag} -1`
132
- end
133
-
134
- if last_staging_tag_sha == current_sha
135
- puts "Not re-tagging staging because latest tag (#{last_staging_tag}) already points to HEAD"
136
- new_staging_tag = last_staging_tag
137
- else
138
- new_staging_tag = next_staging_tag
139
- puts "Tagging current branch for deployment to staging as '#{new_staging_tag}'"
140
- system "git tag -a -m 'tagging current code for deployment to staging' #{new_staging_tag}"
141
- end
142
-
143
- set :branch, new_staging_tag
144
- end
145
-
146
- desc "Push the approved tag to production. Pass in tag to deploy with '-s tag=staging-YYYY-MM-DD-X-feature'."
147
- task :tag_production do
148
- promote_to_production_tag = capistrano_configuration[:tag] || last_staging_tag
149
-
150
- unless promote_to_production_tag && promote_to_production_tag =~ /staging-.*/
151
- abort "Couldn't find a staging tag to deploy; use '-s tag=staging-YYYY-MM-DD.X'"
152
- end
153
- unless last_tag_matching(promote_to_production_tag)
154
- abort "Staging tag #{promote_to_production_tag} does not exist."
155
- end
156
-
157
- promote_to_production_tag =~ /^staging-(.*)$/
158
- new_production_tag = "production-#{$1}"
159
-
160
- if new_production_tag == last_production_tag
161
- puts "Not re-tagging #{last_production_tag} because it already exists"
162
- really_deploy = Capistrano::CLI.ui.ask("Do you really want to deploy #{last_production_tag}? [y/N]").to_url
163
-
164
- exit(1) unless really_deploy =~ /^[Yy]$/
165
- else
166
- puts "Preparing to promote staging tag '#{promote_to_production_tag}' to '#{new_production_tag}'"
167
- unless capistrano_configuration[:tag]
168
- really_deploy = Capistrano::CLI.ui.ask("Do you really want to deploy #{new_production_tag}? [y/N]").to_url
169
-
170
- exit(1) unless really_deploy =~ /^[Yy]$/
171
- end
172
- puts "Promoting staging tag #{promote_to_production_tag} to production as '#{new_production_tag}'"
173
- system "git tag -a -m 'tagging current code for deployment to production' #{new_production_tag} #{promote_to_production_tag}"
174
- end
175
-
176
- set :branch, new_production_tag
177
- end
178
- end
179
-
180
- namespace :deploy do
181
- namespace :pending do
182
- task :compare do
183
- gitflow.commit_log
184
- end
185
- end
186
- end
187
-
188
- end
189
-
190
- end
191
- end
192
- end
193
-
194
- if Capistrano::Configuration.instance
195
- Capistrano::Gitflow.load_into(Capistrano::Configuration.instance)
10
+ if gitflow_using_cap3?
11
+ require File.join(File.dirname(__FILE__), 'tasks', 'gitflow')
12
+ else
13
+ require File.join(File.dirname(__FILE__), 'gitflow','legacy', 'gitflow')
196
14
  end
@@ -0,0 +1,218 @@
1
+ module CapistranoGitFlow
2
+ module Helper
3
+
4
+
5
+ def gitflow_stage
6
+ original_stage = fetch(:stage)
7
+ original_stage.to_s.include?(":") ? original_stage.split(':').reverse[0] : original_stage
8
+ end
9
+
10
+ def gitflow_using_cap3?
11
+ defined?(Capistrano::VERSION) && Capistrano::VERSION.to_s.split('.').first.to_i >= 3
12
+ end
13
+
14
+ def gitflow_callbacks
15
+ if gitflow_using_cap3?
16
+ before "deploy", "gitflow:verify_up_to_date"
17
+ else
18
+ before "deploy:update_code", "gitflow:verify_up_to_date"
19
+ end
20
+ after "gitflow:verify_up_to_date", "gitflow:calculate_tag"
21
+ end
22
+
23
+ def gitflow_find_task(name)
24
+ defined?(::Rake) ? ::Rake::Task[name] : exists?(name)
25
+ rescue
26
+ nil
27
+ end
28
+
29
+ def gitflow_execute_task(name)
30
+ defined?(::Rake) ? gitflow_find_task(name).invoke : find_and_execute_task(name)
31
+ end
32
+
33
+ def gitflow_capistrano_tag
34
+ defined?(capistrano_configuration) ? capistrano_configuration[:tag] : ENV['TAG']
35
+ end
36
+
37
+ def gitflow_last_tag_matching(pattern)
38
+ # search for most recent (chronologically) tag matching the passed pattern, then get the name of that tag.
39
+ last_tag = `git describe --exact-match --tags --match='#{pattern}' $(git log --tags='#{pattern}*' -n1 --pretty='%h')`.chomp
40
+ last_tag == '' ? nil : last_tag
41
+ end
42
+
43
+ def gitflow_last_staging_tag
44
+ gitflow_last_tag_matching('staging-*')
45
+ end
46
+
47
+ def gitflow_ask_confirm(message)
48
+ if gitflow_using_cap3?
49
+ $stdout.print "#{message}"
50
+ $stdin.gets.to_s.chomp
51
+ else
52
+ Capistrano::CLI.ui.ask("#{message}")
53
+ end
54
+ end
55
+
56
+ def gitflow_next_staging_tag
57
+ hwhen = Date.today.to_s
58
+ who = `whoami`.chomp.to_url
59
+ what = gitflow_ask_confirm("What does this release introduce? (this will be normalized and used in the tag for this release) ")
60
+
61
+ abort "No tag has been provided: #{what.inspect}" if what == ''
62
+
63
+ last_staging_tag = gitflow_last_tag_matching("staging-#{hwhen}-*")
64
+ new_tag_serial = if last_staging_tag && last_staging_tag =~ /staging-[0-9]{4}-[0-9]{2}-[0-9]{2}\-([0-9]*)/
65
+ $1.to_i + 1
66
+ else
67
+ 1
68
+ end
69
+
70
+ "#{gitflow_stage}-#{hwhen}-#{new_tag_serial}-#{who}-#{what.to_url}"
71
+ end
72
+
73
+ def gitflow_last_production_tag()
74
+ gitflow_last_tag_matching('production-*')
75
+ end
76
+
77
+ def gitflow_using_git?
78
+ fetch(:scm, :git).to_sym == :git
79
+ end
80
+
81
+
82
+ def gitflow_verify_up_to_date
83
+ if gitflow_using_git?
84
+ set :local_branch, `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`.gsub(/\* /, '').chomp
85
+ set :local_sha, `git log --pretty=format:%H HEAD -1`.chomp
86
+ set :origin_sha, `git log --pretty=format:%H #{fetch(:local_branch)} -1`
87
+ unless fetch(:local_sha) == fetch(:origin_sha)
88
+ abort """
89
+ Your #{fetch(:local_branch)} branch is not up to date with origin/#{fetch(:local_branch)}.
90
+ Please make sure you have pulled and pushed all code before deploying:
91
+
92
+ git pull origin #{fetch(:local_branch)}
93
+ # run tests, etc
94
+ git push origin #{fetch(:local_branch)}
95
+
96
+ """
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+
103
+ def gitflow_calculate_tag
104
+ if gitflow_using_git?
105
+ # make sure we have any other deployment tags that have been pushed by others so our auto-increment code doesn't create conflicting tags
106
+ `git fetch`
107
+ rake_task_name = "gitflow:tag_#{gitflow_stage}"
108
+ if !gitflow_find_task(rake_task_name).nil?
109
+ gitflow_execute_task(rake_task_name)
110
+
111
+ system "git push --tags origin #{fetch(:local_branch)}"
112
+ if $? != 0
113
+ abort "git push failed"
114
+ end
115
+ else
116
+ puts "Will deploy tag: #{fetch(:local_branch)}"
117
+ set :branch, fetch(:local_branch)
118
+ end
119
+ end
120
+ end
121
+
122
+ def gitflow_commit_log
123
+ from_tag = if gitflow_stage.to_s == 'production'
124
+ gitflow_last_production_tag
125
+ elsif gitflow_stage.to_s == 'staging'
126
+ gitflow_last_staging_tag
127
+ else
128
+ abort "Unsupported stage #{gitflow_stage}"
129
+ end
130
+
131
+ # no idea how to properly test for an optional cap argument a la '-s tag=x'
132
+ to_tag = gitflow_capistrano_tag
133
+ to_tag ||= begin
134
+ puts "Calculating 'end' tag for :commit_log for '#{gitflow_stage}'"
135
+ to_tag = if gitflow_stage.to_s == 'production'
136
+ gitflow_last_staging_tag
137
+ elsif gitflow_stage.to_s == 'staging'
138
+ 'master'
139
+ else
140
+ abort "Unsupported stage #{gitflow_stage}"
141
+ end
142
+ end
143
+
144
+
145
+
146
+ # use custom compare command if set
147
+ if ENV['git_log_command'] && ENV['git_log_command'].strip != ''
148
+ command = "git #{ENV['git_log_command']} #{from_tag}..#{to_tag}"
149
+ else
150
+ # default compare command
151
+ # be awesome for github
152
+ if `git config remote.origin.url` =~ /git@github.com:(.*)\/(.*).git/
153
+ command = "open https://github.com/#{$1}/#{$2}/compare/#{from_tag}...#{to_tag}"
154
+ else
155
+ command = "git log #{from_tag}..#{to_tag}"
156
+ end
157
+ end
158
+ puts "Displaying commits from #{from_tag} to #{to_tag} via:\n#{command}"
159
+ system command
160
+
161
+ puts ""
162
+ end
163
+
164
+
165
+ def gitflow_tag_staging
166
+ current_sha = `git log --pretty=format:%H HEAD -1`
167
+ last_staging_tag_sha = if gitflow_last_staging_tag
168
+ `git log --pretty=format:%H #{gitflow_last_staging_tag} -1`
169
+ end
170
+
171
+ if last_staging_tag_sha == current_sha
172
+ puts "Not re-tagging staging because latest tag (#{gitflow_last_staging_tag}) already points to HEAD"
173
+ new_staging_tag = gitflow_last_staging_tag
174
+ else
175
+ new_staging_tag = gitflow_next_staging_tag
176
+ puts "Tagging current branch for deployment to staging as '#{new_staging_tag}'"
177
+ system "git tag -a -m 'tagging current code for deployment to staging' #{new_staging_tag}"
178
+ end
179
+
180
+ set :branch, new_staging_tag
181
+ end
182
+
183
+
184
+ def gitflow_tag_production
185
+ promote_to_production_tag = gitflow_capistrano_tag || gitflow_last_staging_tag
186
+
187
+ unless promote_to_production_tag && promote_to_production_tag =~ /staging-.*/
188
+ abort "Couldn't find a staging tag to deploy; use '-s tag=staging-YYYY-MM-DD.X'"
189
+ end
190
+ unless gitflow_last_tag_matching(promote_to_production_tag)
191
+ abort "Staging tag #{promote_to_production_tag} does not exist."
192
+ end
193
+
194
+ promote_to_production_tag =~ /^staging-(.*)$/
195
+ new_production_tag = "production-#{$1}"
196
+
197
+ if new_production_tag == gitflow_last_production_tag
198
+ puts "Not re-tagging #{last_production_tag} because it already exists"
199
+ really_deploy = gitflow_ask_confirm("Do you really want to deploy #{last_production_tag}? [y/N]")
200
+
201
+ exit(1) unless really_deploy.to_url =~ /^[Yy]$/
202
+ else
203
+ puts "Preparing to promote staging tag '#{promote_to_production_tag}' to '#{new_production_tag}'"
204
+ gitflow_commit_log
205
+ unless gitflow_capistrano_tag
206
+ really_deploy = gitflow_ask_confirm("Do you really want to deploy #{new_production_tag}? [y/N]")
207
+
208
+ exit(1) unless really_deploy.to_url =~ /^[Yy]$/
209
+ end
210
+ puts "Promoting staging tag #{promote_to_production_tag} to production as '#{new_production_tag}'"
211
+ system "git tag -a -m 'tagging current code for deployment to production' #{new_production_tag} #{promote_to_production_tag}"
212
+ end
213
+
214
+ set :branch, new_production_tag
215
+ end
216
+
217
+ end
218
+ end
@@ -0,0 +1,13 @@
1
+ require 'capistrano'
2
+
3
+ module Capistrano
4
+ class Gitflow
5
+ def self.load_into(capistrano_configuration)
6
+ capistrano_configuration.load File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'tasks', 'gitflow.rb')
7
+ end
8
+ end
9
+ end
10
+
11
+ if Capistrano::Configuration.instance
12
+ Capistrano::Gitflow.load_into(Capistrano::Configuration.instance)
13
+ end
@@ -0,0 +1,14 @@
1
+ module CapistranoGitFlow # Returns the version of the currently loaded Rails as a <tt>Gem::Version</tt>
2
+ def self.gem_version
3
+ Gem::Version.new CapistranoGitFlow::VERSION::STRING
4
+ end
5
+
6
+ module VERSION
7
+ MAJOR = 1
8
+ MINOR = 5
9
+ TINY = 0
10
+ PRE = nil
11
+
12
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+
2
+ namespace :gitflow do
3
+
4
+ task :verify_up_to_date do
5
+ gitflow_verify_up_to_date
6
+ end
7
+
8
+ desc "Calculate the tag to deploy"
9
+ task :calculate_tag do
10
+ gitflow_calculate_tag
11
+ end
12
+
13
+ desc "Show log between most recent staging tag (or given tag=XXX) and last production release."
14
+ task :commit_log do
15
+ gitflow_commit_log
16
+ end
17
+
18
+ desc "Mark the current code as a staging/qa release"
19
+ task :tag_staging do
20
+ gitflow_tag_staging
21
+ end
22
+
23
+ desc "Push the approved tag to production. Pass in tag to deploy with '-s tag=staging-YYYY-MM-DD-X-feature'."
24
+ task :tag_production do
25
+ gitflow_tag_production
26
+ end
27
+
28
+ gitflow_callbacks unless defined?(Sinatra)
29
+ end
30
+
31
+ namespace :deploy do
32
+ namespace :pending do
33
+ task :compare do
34
+ gitflow_execute_task("gitflow:commit_log")
35
+ end
36
+ end
37
+ end
38
+
metadata CHANGED
@@ -1,121 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capistrano-gitflow
3
- version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 4
9
- - 3
10
- version: 1.4.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Joshua Nichols
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-04-07 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2011-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: capistrano
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
27
17
  - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
33
20
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: stringex
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
41
24
  - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: stringex
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
47
34
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
55
38
  - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 13
58
- segments:
59
- - 1
60
- - 2
61
- - 9
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
62
47
  version: 1.2.9
63
48
  type: :development
64
- version_requirements: *id003
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.9
65
55
  description: Capistrano recipe for a deployment workflow based on git tags
66
56
  email: josh@technicalpickles.com
67
57
  executables: []
68
-
69
58
  extensions: []
70
-
71
- extra_rdoc_files:
59
+ extra_rdoc_files:
72
60
  - README.rdoc
73
- files:
74
- - .document
61
+ files:
62
+ - ".document"
63
+ - ".gitignore"
75
64
  - README.rdoc
76
65
  - Rakefile
77
- - VERSION
78
66
  - capistrano-gitflow.gemspec
79
67
  - lib/capistrano/gitflow.rb
80
- - lib/capistrano/gitflow/natcmp.rb
68
+ - lib/capistrano/gitflow/helpers/helper.rb
69
+ - lib/capistrano/gitflow/helpers/natcmp.rb
70
+ - lib/capistrano/gitflow/legacy/gitflow.rb
71
+ - lib/capistrano/gitflow/version.rb
72
+ - lib/capistrano/tasks/gitflow.rb
81
73
  - recipes/gitflow_recipes.rb
82
74
  - spec/gitflow_spec.rb
83
75
  - spec/spec.opts
84
76
  - spec/spec_helper.rb
85
- has_rdoc: true
86
77
  homepage: http://github.com/technicalpickles/capistrano-gitflow
87
78
  licenses: []
88
-
79
+ metadata: {}
89
80
  post_install_message:
90
81
  rdoc_options: []
91
-
92
- require_paths:
82
+ require_paths:
93
83
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
97
86
  - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
106
91
  - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
112
94
  requirements: []
113
-
114
95
  rubyforge_project:
115
- rubygems_version: 1.3.7
96
+ rubygems_version: 2.4.8
116
97
  signing_key:
117
98
  specification_version: 3
118
99
  summary: Capistrano recipe for a deployment workflow based on git tags
119
- test_files:
100
+ test_files:
120
101
  - spec/gitflow_spec.rb
102
+ - spec/spec.opts
121
103
  - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.4.3