capflow 0.6.4
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.
- data/.document +5 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +68 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/capflow.gemspec +91 -0
- data/features/capflow.feature +6 -0
- data/features/step_definitions/capflow_steps.rb +0 -0
- data/features/support/env.rb +15 -0
- data/lib/capflow.rb +3 -0
- data/lib/capistrano/capflow.rb +197 -0
- data/lib/capistrano/helpers/capflow_helper.rb +62 -0
- data/lib/railtie.rb +10 -0
- data/lib/tasks/capflow.rake +35 -0
- data/recipes/capflow_recipes.rb +1 -0
- data/test/helper.rb +20 -0
- data/test/test_capflow.rb +6 -0
- data/test/test_capflow_helpers.rb +109 -0
- metadata +257 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem 'capistrano'
|
6
|
+
gem 'stringex'
|
7
|
+
gem 'versionomy'
|
8
|
+
gem 'rainbow'
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "shoulda", "~> 3.0.0.beta2"
|
13
|
+
gem 'active_support'
|
14
|
+
gem 'i18n'
|
15
|
+
gem 'minitest-rg'
|
16
|
+
gem "cucumber", ">= 0"
|
17
|
+
gem "bundler"
|
18
|
+
gem "jeweler", "~> 1.6.4"
|
19
|
+
gem "rcov", ">= 0"
|
20
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Spencer Markowski
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= capflow
|
2
|
+
|
3
|
+
Capflow provides Gitflow integration with Capistrano, without unessecary restrictions to the deploy process. Our goal with capflow was to improve on capistrano-gitflow by allowing you to tag a staging release (or not tag a staging release),
|
4
|
+
deploy from the HEAD of whatever branch you are on (feature, develop, hotfix, etc), and deploy to production from bonafide gitflow release tags.
|
5
|
+
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
You can use the most recent capflow gem by adding it to your Gemfile:
|
9
|
+
|
10
|
+
gem 'capflow'
|
11
|
+
|
12
|
+
Or install it the old-fashioned way:
|
13
|
+
|
14
|
+
gem install capflow
|
15
|
+
|
16
|
+
|
17
|
+
== Capistrano Setup
|
18
|
+
|
19
|
+
You'll need to require the capflow recipe in deploy.rb:
|
20
|
+
|
21
|
+
require 'capistrano/ext/multistage'
|
22
|
+
require 'capistrano/capflow'
|
23
|
+
|
24
|
+
That's all you need. Capflow will set the :branch variable and allow you deploy from any tag, branch or release whenever you wish.
|
25
|
+
|
26
|
+
== Optional Setup
|
27
|
+
|
28
|
+
If you're using the gitflow binary https://github.com/nvie/gitflow , capflow provides a nice helper to initialize your project using our favorite defaults:
|
29
|
+
|
30
|
+
rake gitflow:prepare
|
31
|
+
|
32
|
+
This will attempt to create a develop branch if one doesn't exist locally or remotely, track it and add the following defaults:
|
33
|
+
|
34
|
+
gitflow.branch.master = master
|
35
|
+
gitflow.branch.develop = develop
|
36
|
+
gtiflow.prefix.versiontag = v
|
37
|
+
|
38
|
+
=== Deploy to staging
|
39
|
+
|
40
|
+
To deploy what you're currently working on to staging:
|
41
|
+
|
42
|
+
cap staging deploy
|
43
|
+
|
44
|
+
Capflow will ask if you'd like to tag the release. The tag will include the date, who is deploying and a message. You will then be able to specify that tag as what you'd like to deploy.
|
45
|
+
|
46
|
+
=== Deploy to production
|
47
|
+
|
48
|
+
After you've finished a release branch, capflow will show you all the available releases to deploy from:
|
49
|
+
|
50
|
+
cap production deploy
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
== Contributing to capflow
|
55
|
+
|
56
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
57
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
58
|
+
* Fork the project
|
59
|
+
* Start a feature/bugfix branch
|
60
|
+
* Commit and push until you are happy with your contribution
|
61
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
62
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
63
|
+
|
64
|
+
== Copyright
|
65
|
+
|
66
|
+
Copyright (c) 2011 Spencer Markowski (The Able Few, LLC). See LICENSE.txt for
|
67
|
+
further details.
|
68
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "capflow"
|
18
|
+
gem.homepage = "http://github.com/esmarkowski/capflow"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Gitflow enabled capistrano}
|
21
|
+
gem.description = %Q{An unrestictive way to deploy using gitflow and capistrano}
|
22
|
+
gem.email = "spencer@theablefew.com"
|
23
|
+
gem.authors = ["Spencer Markowski"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
require 'cucumber/rake/task'
|
44
|
+
Cucumber::Rake::Task.new(:features)
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.6.4
|
data/capflow.gemspec
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "capflow"
|
8
|
+
s.version = "0.6.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Spencer Markowski"]
|
12
|
+
s.date = "2013-03-07"
|
13
|
+
s.description = "An unrestictive way to deploy using gitflow and capistrano"
|
14
|
+
s.email = "spencer@theablefew.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"capflow.gemspec",
|
27
|
+
"features/capflow.feature",
|
28
|
+
"features/step_definitions/capflow_steps.rb",
|
29
|
+
"features/support/env.rb",
|
30
|
+
"lib/capflow.rb",
|
31
|
+
"lib/capistrano/capflow.rb",
|
32
|
+
"lib/capistrano/helpers/capflow_helper.rb",
|
33
|
+
"lib/railtie.rb",
|
34
|
+
"lib/tasks/capflow.rake",
|
35
|
+
"recipes/capflow_recipes.rb",
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/test_capflow.rb",
|
38
|
+
"test/test_capflow_helpers.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/esmarkowski/capflow"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = "1.8.24"
|
44
|
+
s.summary = "Gitflow enabled capistrano"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<stringex>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<versionomy>, [">= 0"])
|
53
|
+
s.add_runtime_dependency(%q<rainbow>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<shoulda>, ["~> 3.0.0.beta2"])
|
55
|
+
s.add_development_dependency(%q<active_support>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<i18n>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<minitest-rg>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
64
|
+
s.add_dependency(%q<stringex>, [">= 0"])
|
65
|
+
s.add_dependency(%q<versionomy>, [">= 0"])
|
66
|
+
s.add_dependency(%q<rainbow>, [">= 0"])
|
67
|
+
s.add_dependency(%q<shoulda>, ["~> 3.0.0.beta2"])
|
68
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
69
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
70
|
+
s.add_dependency(%q<minitest-rg>, [">= 0"])
|
71
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
72
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
74
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
78
|
+
s.add_dependency(%q<stringex>, [">= 0"])
|
79
|
+
s.add_dependency(%q<versionomy>, [">= 0"])
|
80
|
+
s.add_dependency(%q<rainbow>, [">= 0"])
|
81
|
+
s.add_dependency(%q<shoulda>, ["~> 3.0.0.beta2"])
|
82
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
83
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
84
|
+
s.add_dependency(%q<minitest-rg>, [">= 0"])
|
85
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
86
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
87
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
88
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
begin
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
$stderr.puts e.message
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
7
|
+
exit e.status_code
|
8
|
+
end
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
+
require 'capflow'
|
12
|
+
|
13
|
+
require 'test/unit/assertions'
|
14
|
+
|
15
|
+
World(Test::Unit::Assertions)
|
data/lib/capflow.rb
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/helpers/capflow_helper'
|
3
|
+
require 'versionomy'
|
4
|
+
require 'stringex'
|
5
|
+
require 'rainbow'
|
6
|
+
|
7
|
+
module Capistrano
|
8
|
+
class Capflow
|
9
|
+
trap("SIGINT") { puts "Leaving Capflow!".color(:red); exit }
|
10
|
+
# I gave up for now, since namespace can't call include
|
11
|
+
# include Capistrano::Helpers::CapflowHelper
|
12
|
+
def self.load_into(capistrano_configuration)
|
13
|
+
|
14
|
+
capistrano_configuration.load do
|
15
|
+
before "deploy:update_code", "capflow:calculate_tag"
|
16
|
+
before "capflow:calculate_tag", "capflow:verify_up_to_date"
|
17
|
+
|
18
|
+
namespace :capflow do
|
19
|
+
|
20
|
+
def who
|
21
|
+
identity = (`git config user.name` || `whoami`)
|
22
|
+
identity.chomp.to_url
|
23
|
+
end
|
24
|
+
|
25
|
+
def tags
|
26
|
+
`git tag`.split("\n").compact
|
27
|
+
end
|
28
|
+
|
29
|
+
def non_release_tags
|
30
|
+
tags - releases
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_branch
|
34
|
+
branches.select{|b| b =~ /^\*\s/}.first.gsub(/^\*\s/,"")
|
35
|
+
end
|
36
|
+
|
37
|
+
def branches
|
38
|
+
`git branch --no-color`.split("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
def version_tag_prefix
|
42
|
+
`git config gitflow.prefix.versiontag`.split("\n").first
|
43
|
+
end
|
44
|
+
|
45
|
+
def releases
|
46
|
+
tags.select{|t| t =~ /^#{version_tag_prefix}(\d+)/}.collect{|version| Versionomy.parse(version) }.sort
|
47
|
+
end
|
48
|
+
|
49
|
+
def latest_release
|
50
|
+
releases.reverse.first.to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def available_tags
|
54
|
+
Capistrano::CLI.ui.say "Available Tags:"
|
55
|
+
Capistrano::CLI.ui.say "#{non_release_tags.join("\n")}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def available_releases
|
59
|
+
Capistrano::CLI.ui.say "\nAvailable Releases:".color :green
|
60
|
+
Capistrano::CLI.ui.say "#{releases.sort.reverse.join("\n")}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def banner
|
64
|
+
|
65
|
+
<<-BANNER
|
66
|
+
\nCapflow for Gitflow
|
67
|
+
,-------------.
|
68
|
+
(o) _ __ _____ )--.
|
69
|
+
`-------------' )
|
70
|
+
( /
|
71
|
+
`---'
|
72
|
+
BANNER
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
def deploy_from
|
78
|
+
puts banner
|
79
|
+
if stage == :production
|
80
|
+
available_releases
|
81
|
+
from_destination = Capistrano::CLI.ui.ask("\nRelease to deploy:".color(:yellow).bright) do |q|
|
82
|
+
q.default = latest_release
|
83
|
+
end
|
84
|
+
else
|
85
|
+
create_tag = Capistrano::CLI.ui.agree("Do you want to tag deployment? [y/N]".color(:yellow)) do |q|
|
86
|
+
q.default = 'N'
|
87
|
+
end
|
88
|
+
return next_tag if create_tag
|
89
|
+
available_tags
|
90
|
+
from_destination = Capistrano::CLI.ui.ask "\nBranch, tag or release to deploy:".color(:yellow).bright do |q|
|
91
|
+
q.default = current_branch
|
92
|
+
end
|
93
|
+
end
|
94
|
+
return from_destination
|
95
|
+
end
|
96
|
+
|
97
|
+
def next_tag
|
98
|
+
hwhen = Date.today.to_s
|
99
|
+
what = Capistrano::CLI.ui.ask("What does this release introduce? (this will be normalized and used in the tag for this release)".color(:yellow)).to_url
|
100
|
+
new_staging_tag = "#{hwhen}-#{who}-#{what}"
|
101
|
+
puts "Tagging current branch for deployment to staging as '#{new_staging_tag}'".color(:green)
|
102
|
+
system "git tag -a -m 'tagging current code for deployment to staging' #{new_staging_tag}"
|
103
|
+
return new_staging_tag
|
104
|
+
end
|
105
|
+
|
106
|
+
def using_git?
|
107
|
+
fetch(:scm, :git).to_sym == :git
|
108
|
+
end
|
109
|
+
|
110
|
+
task :verify_up_to_date do
|
111
|
+
if using_git?
|
112
|
+
set :local_branch, `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`.gsub(/\* /, '').chomp
|
113
|
+
set :local_sha, `git log --pretty=format:%H HEAD -1`.chomp
|
114
|
+
set :origin_sha, `git log --pretty=format:%H #{local_branch} -1`
|
115
|
+
unless local_sha == origin_sha
|
116
|
+
abort """
|
117
|
+
Your #{local_branch} branch is not up to date with origin/#{local_branch}.
|
118
|
+
Please make sure you have pulled and pushed all code before deploying:
|
119
|
+
|
120
|
+
git pull origin #{local_branch}
|
121
|
+
# run tests, etc
|
122
|
+
git push origin #{local_branch}
|
123
|
+
|
124
|
+
"""
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
desc "Calculate the tag to deploy"
|
130
|
+
task :calculate_tag do
|
131
|
+
if using_git?
|
132
|
+
# make sure we have any other deployment tags that have been pushed by others so our auto-increment code doesn't create conflicting tags
|
133
|
+
`git fetch`
|
134
|
+
if stage == :production
|
135
|
+
tag_production
|
136
|
+
else
|
137
|
+
tag_staging
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
system "git push --tags origin #{local_branch}"
|
142
|
+
if $? != 0
|
143
|
+
abort "git push failed"
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
desc "Mark the current code as a staging/qa release"
|
150
|
+
task :tag_staging do
|
151
|
+
#current_sha = `git log --pretty=format:%H HEAD -1`
|
152
|
+
#last_staging_tag_sha = if last_staging_tag
|
153
|
+
# `git log --pretty=format:%H #{last_staging_tag} -1`
|
154
|
+
# end
|
155
|
+
|
156
|
+
#if last_staging_tag_sha == current_sha
|
157
|
+
# puts "Not re-tagging staging because latest tag (#{last_staging_tag}) already points to HEAD"
|
158
|
+
# new_staging_tag = last_staging_tag
|
159
|
+
#else
|
160
|
+
#
|
161
|
+
staging_destination = deploy_from
|
162
|
+
|
163
|
+
#end
|
164
|
+
|
165
|
+
set :branch, staging_destination
|
166
|
+
end
|
167
|
+
|
168
|
+
desc "Push the approved tag to production. Pass in tag to deploy with '-s tag=staging-YYYY-MM-DD-X-feature'."
|
169
|
+
task :tag_production do
|
170
|
+
|
171
|
+
production_destination = deploy_from
|
172
|
+
|
173
|
+
really_deploy = Capistrano::CLI.ui.ask("Do you really want to deploy #{production_destination}? [y/N]").to_url
|
174
|
+
|
175
|
+
exit(1) unless really_deploy =~ /^[Yy]$/
|
176
|
+
|
177
|
+
set :branch, production_destination
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
namespace :deploy do
|
182
|
+
namespace :pending do
|
183
|
+
task :compare do
|
184
|
+
#gitflow.commit_log
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
if Capistrano::Configuration.instance
|
196
|
+
Capistrano::Capflow.load_into(Capistrano::Configuration.instance)
|
197
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Helpers
|
3
|
+
module CapflowHelper
|
4
|
+
|
5
|
+
def who
|
6
|
+
identity = (`git config user.name` || `whoami`)
|
7
|
+
identity.chomp.to_url
|
8
|
+
end
|
9
|
+
|
10
|
+
def tags
|
11
|
+
`git tag`.split("\n").compact
|
12
|
+
end
|
13
|
+
|
14
|
+
def non_release_tags
|
15
|
+
tags - releases
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_branch
|
19
|
+
branches.select{|b| b =~ /^\*\s/}.first.gsub(/^\*\s/,"")
|
20
|
+
end
|
21
|
+
|
22
|
+
def branches
|
23
|
+
`git branch --no-color`.split("\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
def version_tag_prefix
|
27
|
+
`git config gitflow.prefix.versiontag`.split("\n").first
|
28
|
+
end
|
29
|
+
|
30
|
+
def releases
|
31
|
+
tags.select{|t| t =~ /^#{version_tag_prefix}(\d+)/}
|
32
|
+
end
|
33
|
+
|
34
|
+
def latest_release
|
35
|
+
releases.sort{|x,y| x.split(version_tag_prefix).last <=> y.split(version_tag_prefix).last}.last
|
36
|
+
end
|
37
|
+
|
38
|
+
def available_tags
|
39
|
+
Capistrano::CLI.ui.say "Available Tags:"
|
40
|
+
Capistrano::CLI.ui.say "#{non_release_tags.join("\n")}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def available_releases
|
44
|
+
Capistrano::CLI.ui.say "\nAvailable Releases:"
|
45
|
+
Capistrano::CLI.ui.say "#{releases.join("\n")}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def banner
|
49
|
+
|
50
|
+
<<-BANNER
|
51
|
+
\nCapflow for Gitflow
|
52
|
+
,-------------.
|
53
|
+
(o) _ __ _____ )--.
|
54
|
+
`-------------' )
|
55
|
+
( /
|
56
|
+
`---'
|
57
|
+
BANNER
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/railtie.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
namespace :gitflow do
|
2
|
+
desc 'Gitflow setup for use with capflow'
|
3
|
+
task :prepare do
|
4
|
+
if (`git branch -r --no-color` =~ /develop/).nil?
|
5
|
+
#doesn't exist remotely
|
6
|
+
puts "Creating Develop Branch"
|
7
|
+
`git push origin origin:refs/heads/develop`
|
8
|
+
`git fetch origin`
|
9
|
+
`git checkout --track -b develop origin/develop`
|
10
|
+
else
|
11
|
+
if (`git branch --no-color` =~ /develop/).nil?
|
12
|
+
puts "Tracking Remote Develop Branch"
|
13
|
+
#doesn't exist locally but exists remotely
|
14
|
+
`git checkout --track -B develop origin/develop`
|
15
|
+
end
|
16
|
+
end
|
17
|
+
`git flow init -df`
|
18
|
+
`git config gitflow.branch.develop "develop"`
|
19
|
+
`git config gitflow.branch.master "master"`
|
20
|
+
`git config gitflow.prefix.versiontag "v"`
|
21
|
+
`git config gitflow.prefix.feature "feature/"`
|
22
|
+
`git config gitflow.prefix.release "release/"`
|
23
|
+
`git config gitflow.prefix.hotfix "hotfix/"`
|
24
|
+
`git config gitflow.prefix.support "support/"`
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :capflow do
|
31
|
+
desc "Show available releases"
|
32
|
+
task :releases do
|
33
|
+
puts `git tag`.split("\n").compact.collect{|version| Versionomy.parse(version)}.sort.reverse
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
data/test/helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
require 'minitest-rg'
|
13
|
+
require 'active_support/core_ext'
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
require 'capistrano/capflow'
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestCapflowHelpers < Test::Unit::TestCase
|
4
|
+
context "when intialized" do
|
5
|
+
setup do
|
6
|
+
class HelperMethods
|
7
|
+
include Capistrano::Helpers::CapflowHelper
|
8
|
+
end
|
9
|
+
|
10
|
+
@test_class = HelperMethods.new
|
11
|
+
|
12
|
+
end
|
13
|
+
context "tags" do
|
14
|
+
|
15
|
+
|
16
|
+
should "respond_to who" do
|
17
|
+
assert_respond_to @test_class, :who
|
18
|
+
end
|
19
|
+
|
20
|
+
should "not be blank" do
|
21
|
+
puts "\ncurrent user: #{@test_class.who}"
|
22
|
+
assert_equal false, @test_class.who.blank?
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'tags should be an Array' do
|
26
|
+
puts "\nall tags: #{@test_class.tags}"
|
27
|
+
assert @test_class.tags.kind_of?(Array)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
context "then non-release tags" do
|
33
|
+
|
34
|
+
should "respond_to non_release_tags" do
|
35
|
+
assert_respond_to @test_class, :non_release_tags
|
36
|
+
end
|
37
|
+
|
38
|
+
should "return an Array" do
|
39
|
+
assert @test_class.non_release_tags.kind_of?(Array)
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'should be test-non-release-tag' do
|
43
|
+
assert_equal 'test-non-release-tag', @test_class.non_release_tags.last
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "branches" do
|
49
|
+
|
50
|
+
should "respond_to :branches" do
|
51
|
+
assert_respond_to @test_class, :branches
|
52
|
+
end
|
53
|
+
|
54
|
+
should 'not be blank' do
|
55
|
+
assert_equal false, @test_class.branches.empty?
|
56
|
+
end
|
57
|
+
|
58
|
+
should "respond to :current_branch" do
|
59
|
+
assert_respond_to @test_class, :current_branch
|
60
|
+
end
|
61
|
+
|
62
|
+
should "show the current branch" do
|
63
|
+
puts "\ncurrent branch: #{@test_class.current_branch}"
|
64
|
+
assert_equal "develop", @test_class.current_branch
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
context "version tag prefix" do
|
70
|
+
|
71
|
+
should "respond_to version_tag_prefix" do
|
72
|
+
assert_respond_to @test_class, :version_tag_prefix
|
73
|
+
end
|
74
|
+
|
75
|
+
should "be 'v'" do
|
76
|
+
assert_equal "v", @test_class.version_tag_prefix
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
context "releases" do
|
82
|
+
|
83
|
+
should "respond to releases" do
|
84
|
+
assert_respond_to @test_class, :releases
|
85
|
+
end
|
86
|
+
|
87
|
+
should "only begin with the version tag prefix" do
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
should 'display all available releases' do
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
should 'display latest release' do
|
96
|
+
assert_equal 'v1.4.1', @test_class.latest_release
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
should 'display banner' do
|
102
|
+
puts @test_class.banner
|
103
|
+
assert_nothing_raised do
|
104
|
+
@test_class.banner
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
metadata
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capflow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Spencer Markowski
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-03-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: capistrano
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: stringex
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: versionomy
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rainbow
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: shoulda
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 2327717285
|
85
|
+
segments:
|
86
|
+
- 3
|
87
|
+
- 0
|
88
|
+
- 0
|
89
|
+
- beta
|
90
|
+
- 2
|
91
|
+
version: 3.0.0.beta2
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: active_support
|
96
|
+
prerelease: false
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
type: :development
|
107
|
+
version_requirements: *id006
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
name: i18n
|
110
|
+
prerelease: false
|
111
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
type: :development
|
121
|
+
version_requirements: *id007
|
122
|
+
- !ruby/object:Gem::Dependency
|
123
|
+
name: minitest-rg
|
124
|
+
prerelease: false
|
125
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
type: :development
|
135
|
+
version_requirements: *id008
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: cucumber
|
138
|
+
prerelease: false
|
139
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
type: :development
|
149
|
+
version_requirements: *id009
|
150
|
+
- !ruby/object:Gem::Dependency
|
151
|
+
name: bundler
|
152
|
+
prerelease: false
|
153
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 3
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
version: "0"
|
162
|
+
type: :development
|
163
|
+
version_requirements: *id010
|
164
|
+
- !ruby/object:Gem::Dependency
|
165
|
+
name: jeweler
|
166
|
+
prerelease: false
|
167
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ~>
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 7
|
173
|
+
segments:
|
174
|
+
- 1
|
175
|
+
- 6
|
176
|
+
- 4
|
177
|
+
version: 1.6.4
|
178
|
+
type: :development
|
179
|
+
version_requirements: *id011
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
name: rcov
|
182
|
+
prerelease: false
|
183
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
184
|
+
none: false
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
hash: 3
|
189
|
+
segments:
|
190
|
+
- 0
|
191
|
+
version: "0"
|
192
|
+
type: :development
|
193
|
+
version_requirements: *id012
|
194
|
+
description: An unrestictive way to deploy using gitflow and capistrano
|
195
|
+
email: spencer@theablefew.com
|
196
|
+
executables: []
|
197
|
+
|
198
|
+
extensions: []
|
199
|
+
|
200
|
+
extra_rdoc_files:
|
201
|
+
- LICENSE.txt
|
202
|
+
- README.rdoc
|
203
|
+
files:
|
204
|
+
- .document
|
205
|
+
- Gemfile
|
206
|
+
- LICENSE.txt
|
207
|
+
- README.rdoc
|
208
|
+
- Rakefile
|
209
|
+
- VERSION
|
210
|
+
- capflow.gemspec
|
211
|
+
- features/capflow.feature
|
212
|
+
- features/step_definitions/capflow_steps.rb
|
213
|
+
- features/support/env.rb
|
214
|
+
- lib/capflow.rb
|
215
|
+
- lib/capistrano/capflow.rb
|
216
|
+
- lib/capistrano/helpers/capflow_helper.rb
|
217
|
+
- lib/railtie.rb
|
218
|
+
- lib/tasks/capflow.rake
|
219
|
+
- recipes/capflow_recipes.rb
|
220
|
+
- test/helper.rb
|
221
|
+
- test/test_capflow.rb
|
222
|
+
- test/test_capflow_helpers.rb
|
223
|
+
homepage: http://github.com/esmarkowski/capflow
|
224
|
+
licenses:
|
225
|
+
- MIT
|
226
|
+
post_install_message:
|
227
|
+
rdoc_options: []
|
228
|
+
|
229
|
+
require_paths:
|
230
|
+
- lib
|
231
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
232
|
+
none: false
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
hash: 3
|
237
|
+
segments:
|
238
|
+
- 0
|
239
|
+
version: "0"
|
240
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
|
+
none: false
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
hash: 3
|
246
|
+
segments:
|
247
|
+
- 0
|
248
|
+
version: "0"
|
249
|
+
requirements: []
|
250
|
+
|
251
|
+
rubyforge_project:
|
252
|
+
rubygems_version: 1.8.24
|
253
|
+
signing_key:
|
254
|
+
specification_version: 3
|
255
|
+
summary: Gitflow enabled capistrano
|
256
|
+
test_files: []
|
257
|
+
|