minicap 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -1
- data/lib/minicap.rb +59 -57
- metadata +3 -3
data/README.md
CHANGED
@@ -15,7 +15,13 @@ Minicap also has two features that the stock deployment recipes lack;
|
|
15
15
|
|
16
16
|
## Using Minicap
|
17
17
|
|
18
|
-
|
18
|
+
To use minicap, your project's `Capfile` should look like
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'minicap'
|
22
|
+
load 'config/deploy'
|
23
|
+
|
24
|
+
Copy the contents of minicap's `examples/deploy.rb` as a jumping off point for your project's `deploy.rb`.
|
19
25
|
|
20
26
|
## Coming soon
|
21
27
|
|
data/lib/minicap.rb
CHANGED
@@ -1,71 +1,73 @@
|
|
1
|
-
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
require 'capistrano/recipes/deploy/scm'
|
2
3
|
|
3
|
-
default_run_options[:pty] = true # Needed for debian based servers
|
4
|
-
set :ssh_options, {:forward_agent => true}
|
4
|
+
default_run_options[:pty] = true # Needed for debian based servers
|
5
|
+
set :ssh_options, {:forward_agent => true}
|
5
6
|
|
6
|
-
namespace :deploy do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
namespace :deploy do
|
8
|
+
desc "Set up the deployment structure"
|
9
|
+
task :setup, :except => { :no_release => true } do
|
10
|
+
run "mkdir -p #{deploy_to}"
|
11
|
+
run_gregarious "[ -d #{deploy_to}/.git ] || git clone -q #{repository} #{deploy_to}"
|
12
|
+
unversioned_dirs.each { |d| run "mkdir -p #{deploy_to + '/' + d}" } if exists? :unversioned_dirs
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
desc "Update the deployed code"
|
16
|
+
task :default, :except => { :no_release => true } do
|
17
|
+
fetch
|
18
|
+
deploy.check_yr_head if fetch(:pedantic_remote, false) && branch !~ /HEAD/
|
19
|
+
update_code
|
20
|
+
orphans if fetch(:look_for_orphans, false)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
desc "Fetches the latest from the repo"
|
24
|
+
task :fetch do
|
25
|
+
run_gregarious "cd #{deploy_to} ; git fetch -q origin"
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
desc "Aborts if remote's HEAD is different than ours"
|
29
|
+
task :check_yr_head do
|
30
|
+
remote = capture("cd #{deploy_to} ; git show-ref origin/#{branch}").split[0]
|
31
|
+
local = `git show-ref #{branch}`.split[0]
|
32
|
+
abort "It looks like you haven't pushed your changes yet. Aborting
|
33
|
+
Your HEAD is #{local[0,7]}
|
34
|
+
Their HEAD is #{remote[0,7]}" if local != remote
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
desc "Does a git reset to get the repo looking like branch"
|
38
|
+
task :update_code do
|
39
|
+
run "cd #{deploy_to} ; git reset --hard origin/#{branch}"
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
desc "Reports back on remote files that didn't come from git, or aren't ignored by git"
|
43
|
+
task :orphans do
|
44
|
+
orphans = capture "cd #{deploy_to} ; git ls-files -o"
|
45
|
+
unless orphans.empty?
|
46
|
+
logger.important <<-EOF
|
47
|
+
The following files are present in the deployment, and are unaccounted for
|
48
|
+
You may want to manually slay them, or else add them to .gitignore
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
#{orphans}
|
51
|
+
EOF
|
52
|
+
end
|
51
53
|
end
|
52
|
-
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
desc "Rollback a single commit"
|
56
|
+
task :rollback, :except => { :no_release => true } do
|
57
|
+
set :branch, "HEAD^"
|
58
|
+
default
|
59
|
+
end
|
58
60
|
end
|
59
|
-
end
|
60
61
|
|
61
|
-
#
|
62
|
-
# Runs the given command via cap's wrapper, which handles things like ssh host
|
63
|
-
# key messages, passphrase prompts, and the like
|
64
|
-
#
|
65
|
-
def run_gregarious(cmd)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
#
|
63
|
+
# Runs the given command via cap's wrapper, which handles things like ssh host
|
64
|
+
# key messages, passphrase prompts, and the like
|
65
|
+
#
|
66
|
+
def run_gregarious(cmd)
|
67
|
+
run cmd do |ch,stream,text|
|
68
|
+
ch[:state] ||= { :channel => ch }
|
69
|
+
output = Capistrano::Deploy::SCM.new(:git, self).handle_data(ch[:state], stream, text)
|
70
|
+
ch.send_data(output) if output
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minicap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.1
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mat Trudel
|