Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 6 commits
  • 5 files changed
  • 0 comments
  • 1 contributor
Mar 15, 2012
Jason Petersen Add .rvmrc file
Get this thing contained within rvm.

cr: nobody
81839a1
Jason Petersen Fix rampant injection vulnerabilities, whitespace
I shudder to think what a branch name of `;rm -rf /` could have done…

cr: nobody
cb74904
Jason Petersen Remove hardcoded tag annotation, clean up tag name
The tag names are now `staging_yyyy-mm-dd.release` instead of the
longer names we had before.

cr: nobody
4aa27c7
Jason Petersen Add zero-padding of serial number
Final tweak.

cr: nobody
049a3a9
Jason Petersen Version bump to 2.0.0 76e73bd
Jason Petersen Bump version to 2.0.0 to reflect new name scheme
This is backwards incompatible, so bumping major version.

cr: nobody
bd38ee1
55 .rvmrc
... ... @@ -0,0 +1,55 @@
  1 +#!/usr/bin/env bash
  2 +
  3 +# This is an RVM Project .rvmrc file, used to automatically load the ruby
  4 +# development environment upon cd'ing into the directory
  5 +
  6 +# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
  7 +environment_id="ruby-1.9.2-p290@capistrano-gitflow"
  8 +
  9 +#
  10 +# Uncomment following line if you want options to be set only for given project.
  11 +#
  12 +# PROJECT_JRUBY_OPTS=( --1.9 )
  13 +
  14 +#
  15 +# First we attempt to load the desired environment directly from the environment
  16 +# file. This is very fast and efficient compared to running through the entire
  17 +# CLI and selector. If you want feedback on which environment was used then
  18 +# insert the word 'use' after --create as this triggers verbose mode.
  19 +#
  20 +if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
  21 + && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
  22 +then
  23 + \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
  24 +
  25 + if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
  26 + then
  27 + . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
  28 + fi
  29 +else
  30 + # If the environment file has not yet been created, use the RVM CLI to select.
  31 + if ! rvm --create "$environment_id"
  32 + then
  33 + echo "Failed to create RVM environment '${environment_id}'."
  34 + exit 1
  35 + fi
  36 +fi
  37 +
  38 +#
  39 +# If you use an RVM gemset file to install a list of gems (*.gems), you can have
  40 +# it be automatically loaded. Uncomment the following and adjust the filename if
  41 +# necessary.
  42 +#
  43 +# filename=".gems"
  44 +# if [[ -s "$filename" ]]
  45 +# then
  46 +# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
  47 +# fi
  48 +
  49 +# If you use bundler, this might be useful to you:
  50 +# if command -v bundle && [[ -s Gemfile ]]
  51 +# then
  52 +# bundle
  53 +# fi
  54 +
  55 +
6 Rakefile
@@ -7,9 +7,9 @@ begin
7 7 gem.name = "capistrano-gitflow"
8 8 gem.summary = %Q{Capistrano recipe for a deployment workflow based on git tags }
9 9 gem.description = %Q{Capistrano recipe for a deployment workflow based on git tags}
10   - gem.email = "josh@technicalpickles.com"
11   - gem.homepage = "http://github.com/technicalpickles/capistrano-gitflow"
12   - gem.authors = ["Joshua Nichols"]
  10 + gem.email = "jpetersen@bluekai.com"
  11 + gem.homepage = "http://github.com/BlueKai/capistrano-gitflow"
  12 + gem.authors = ["Jason Petersen"]
13 13 gem.add_dependency "capistrano"
14 14 gem.add_dependency "stringex"
15 15 gem.add_development_dependency "rspec", ">= 1.2.9"
2  VERSION
... ... @@ -1 +1 @@
1   -1.4.3
  1 +2.0.0
20 capistrano-gitflow.gemspec
@@ -5,18 +5,19 @@
5 5
6 6 Gem::Specification.new do |s|
7 7 s.name = %q{capistrano-gitflow}
8   - s.version = "1.4.3"
  8 + s.version = "2.0.0"
9 9
10 10 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11   - s.authors = ["Joshua Nichols"]
12   - s.date = %q{2011-04-07}
  11 + s.authors = [%q{Jason Petersen}]
  12 + s.date = %q{2012-03-15}
13 13 s.description = %q{Capistrano recipe for a deployment workflow based on git tags}
14   - s.email = %q{josh@technicalpickles.com}
  14 + s.email = %q{jpetersen@bluekai.com}
15 15 s.extra_rdoc_files = [
16 16 "README.rdoc"
17 17 ]
18 18 s.files = [
19 19 ".document",
  20 + ".rvmrc",
20 21 "README.rdoc",
21 22 "Rakefile",
22 23 "VERSION",
@@ -28,17 +29,12 @@ Gem::Specification.new do |s|
28 29 "spec/spec.opts",
29 30 "spec/spec_helper.rb"
30 31 ]
31   - s.homepage = %q{http://github.com/technicalpickles/capistrano-gitflow}
32   - s.require_paths = ["lib"]
33   - s.rubygems_version = %q{1.3.7}
  32 + s.homepage = %q{http://github.com/BlueKai/capistrano-gitflow}
  33 + s.require_paths = [%q{lib}]
  34 + s.rubygems_version = %q{1.8.6}
34 35 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 36
40 37 if s.respond_to? :specification_version then
41   - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42 38 s.specification_version = 3
43 39
44 40 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64 lib/capistrano/gitflow.rb
@@ -24,26 +24,25 @@ def last_tag_matching(pattern)
24 24 end
25 25
26 26 def last_staging_tag()
27   - last_tag_matching('staging-*')
  27 + last_tag_matching('staging_*')
28 28 end
29 29
30 30 def next_staging_tag
31 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 32
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]*)/
  33 + last_staging_tag = last_tag_matching("staging_#{hwhen}.*")
  34 + new_tag_serial = if last_staging_tag && last_staging_tag =~ /staging_\d{4}-\d{2}-\d{2}\.(\d*)/
37 35 $1.to_i + 1
38 36 else
39   - 1
  37 + 0
40 38 end
  39 + new_tag_serial = "%02i" % new_tag_serial
41 40
42   - "#{stage}-#{hwhen}-#{new_tag_serial}-#{who}-#{what}"
  41 + "#{stage}_#{hwhen}.#{new_tag_serial}"
43 42 end
44 43
45 44 def last_production_tag()
46   - last_tag_matching('production-*')
  45 + last_tag_matching('production_*')
47 46 end
48 47
49 48 def using_git?
@@ -54,7 +53,7 @@ def using_git?
54 53 if using_git?
55 54 set :local_branch, `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`.gsub(/\* /, '').chomp
56 55 set :local_sha, `git log --pretty=format:%H HEAD -1`.chomp
57   - set :origin_sha, `git log --pretty=format:%H #{local_branch} -1`
  56 + set :origin_sha, `git log --pretty=format:%H '#{local_branch}' -1`
58 57 unless local_sha == origin_sha
59 58 abort """
60 59 Your #{local_branch} branch is not up to date with origin/#{local_branch}.
@@ -76,9 +75,9 @@ def using_git?
76 75 `git fetch`
77 76
78 77 if respond_to?("tag_#{stage}")
79   - send "tag_#{stage}"
  78 + send "tag_#{stage}"
80 79
81   - system "git push --tags origin #{local_branch}"
  80 + system 'git', 'push', '--tags', 'origin', local_branch
82 81 if $? != 0
83 82 abort "git push failed"
84 83 end
@@ -98,7 +97,7 @@ def using_git?
98 97
99 98 # no idea how to properly test for an optional cap argument a la '-s tag=x'
100 99 to_tag = capistrano_configuration[:tag]
101   - to_tag ||= begin
  100 + to_tag ||= begin
102 101 puts "Calculating 'end' tag for :commit_log for '#{stage}'"
103 102 to_tag = if stage == :production
104 103 last_staging_tag
@@ -110,25 +109,26 @@ def using_git?
110 109 end
111 110
112 111
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'}"
  112 + cmd_ary = if `git config remote.origin.url` =~ /git@github.com:(.*)\/(.*).git/
  113 + ['open',
  114 + "https://github.com/#{$1}/#{$2}/compare/#{from_tag}...#{to_tag || 'master'}"]
115 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}"
  116 + log_cmd = if ENV['git_log_command'] && ENV['git_log_command'].strip != ''
  117 + ENV['git_log_command']
  118 + else
  119 + 'log'
  120 + end
  121 + ['git', log_cmd, "#{fromTag}..#{toTag}"]
122 122 end
123   - puts command
124   - system command
  123 + puts cmd_ary.join(' ')
  124 + system *cmd_ary
125 125 end
126 126
127 127 desc "Mark the current code as a staging/qa release"
128 128 task :tag_staging do
129 129 current_sha = `git log --pretty=format:%H HEAD -1`
130 130 last_staging_tag_sha = if last_staging_tag
131   - `git log --pretty=format:%H #{last_staging_tag} -1`
  131 + `git log --pretty=format:%H '#{last_staging_tag}' -1`
132 132 end
133 133
134 134 if last_staging_tag_sha == current_sha
@@ -137,25 +137,25 @@ def using_git?
137 137 else
138 138 new_staging_tag = next_staging_tag
139 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}"
  140 + system 'git', 'tag', '-a', new_staging_tag
141 141 end
142 142
143 143 set :branch, new_staging_tag
144 144 end
145 145
146   - desc "Push the approved tag to production. Pass in tag to deploy with '-s tag=staging-YYYY-MM-DD-X-feature'."
  146 + desc "Push the approved tag to production'."
147 147 task :tag_production do
148   - promote_to_production_tag = capistrano_configuration[:tag] || last_staging_tag
  148 + promote_to_production_tag = last_staging_tag
149 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'"
  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 152 end
153 153 unless last_tag_matching(promote_to_production_tag)
154 154 abort "Staging tag #{promote_to_production_tag} does not exist."
155 155 end
156 156
157   - promote_to_production_tag =~ /^staging-(.*)$/
158   - new_production_tag = "production-#{$1}"
  157 + promote_to_production_tag =~ /^staging_(.*)$/
  158 + new_production_tag = "production_#{$1}"
159 159
160 160 if new_production_tag == last_production_tag
161 161 puts "Not re-tagging #{last_production_tag} because it already exists"
@@ -170,7 +170,7 @@ def using_git?
170 170 exit(1) unless really_deploy =~ /^[Yy]$/
171 171 end
172 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}"
  173 + system 'git', 'tag', '-a', new_production_tag, promote_to_production_tag
174 174 end
175 175
176 176 set :branch, new_production_tag
@@ -184,9 +184,7 @@ def using_git?
184 184 end
185 185 end
186 186 end
187   -
188 187 end
189   -
190 188 end
191 189 end
192 190 end

No commit comments for this range

Something went wrong with that request. Please try again.