morhekil-capistrano-deepmodules 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +27 -0
- data/capistrano-deepmodules.gemspec +21 -0
- data/lib/capistrano/deepmodules.rb +68 -0
- metadata +55 -0
data/README
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
This plugin allows your Capistrano to deploy git repositories those have
|
2
|
+
multiple-level nested submodules in them.
|
3
|
+
|
4
|
+
By default Capistrano issues git submodule init && git submodule update
|
5
|
+
commands only at the repository root, those initializion first-level
|
6
|
+
submodules. But if those submodules has their own submodules, your application
|
7
|
+
will fail as they will stay uninitialized. This plugin fixes it and
|
8
|
+
automatically checks for all included submodules (and their submodules, and
|
9
|
+
their, etc) and initializes them, too.
|
10
|
+
|
11
|
+
Usage is very simple - just install this gem and add following requirement to
|
12
|
+
your deployment scenario:
|
13
|
+
|
14
|
+
require 'capistrano/deepmodules'
|
15
|
+
|
16
|
+
Also make sure that you're using remote cache to deploy your code as current
|
17
|
+
only remote cache strategy is supported:
|
18
|
+
|
19
|
+
set :deploy_via, :remote_cache
|
20
|
+
|
21
|
+
I see no reason not to use it, especially on large codebases with a lot of
|
22
|
+
submodules, so currently this plugin does not support other strategies. If
|
23
|
+
you need such support - drop me a note and I'll if it's plausible.
|
24
|
+
|
25
|
+
And you don't need to set :git_enable_submodules parameter in your scenario -
|
26
|
+
it doesn't affect operations if this plugin as it pays no attention to it.
|
27
|
+
If you want to disable submodules - just comment out 'require' line.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'capistrano-deepmodules'
|
3
|
+
s.version = "0.1"
|
4
|
+
s.date = "2008-10-28"
|
5
|
+
s.summary = "Capistrano plugin to deploy Git repos with nested submodules."
|
6
|
+
s.description = %{This plugin allows you to easily deploy git repositories with
|
7
|
+
submodules nested at more then one level.%}
|
8
|
+
s.has_rdoc = false
|
9
|
+
|
10
|
+
s.files = ['lib/capistrano/deepmodules.rb',
|
11
|
+
'capistrano-deepmodules.gemspec',
|
12
|
+
'README'
|
13
|
+
]
|
14
|
+
|
15
|
+
s.require_path = 'lib'
|
16
|
+
|
17
|
+
s.author = "Oleg Ivanov"
|
18
|
+
s.email = "morhekil@morhekil.net"
|
19
|
+
s.homepage = "http://speakmy.name"
|
20
|
+
s.rubyforge_project = 'capistrano-deepmodules'
|
21
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'capistrano/recipes/deploy/scm/git'
|
2
|
+
require 'capistrano/recipes/deploy/strategy/remote_cache'
|
3
|
+
|
4
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
5
|
+
abort "capistrano/deepmodules requires Capistrano 2"
|
6
|
+
end
|
7
|
+
|
8
|
+
module Capistrano
|
9
|
+
module Deploy
|
10
|
+
|
11
|
+
module SCM
|
12
|
+
class Git < Base
|
13
|
+
|
14
|
+
# Simple interface to submodule commands
|
15
|
+
def submodule(subcmd)
|
16
|
+
"#{command} submodule #{subcmd}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
module Strategy
|
24
|
+
|
25
|
+
class RemoteCache < Remote
|
26
|
+
# Executes the SCM command for this strategy and writes the REVISION
|
27
|
+
# mark file to each host.
|
28
|
+
# We're overriding default deploy! method to inject a call to deep
|
29
|
+
# update the nested modules
|
30
|
+
def deploy!
|
31
|
+
update_repository_cache
|
32
|
+
update_submodules(repository_cache)
|
33
|
+
copy_repository_cache
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# Inits and updates submodules in the repository at the path given
|
39
|
+
# via the argument, then recursively descends into all found
|
40
|
+
# submodule and updated them and all their down-levels, too
|
41
|
+
def update_submodules(dir)
|
42
|
+
logger.trace "updating submodule at #{dir}"
|
43
|
+
|
44
|
+
submodules = Array.new
|
45
|
+
run("cd #{dir} && #{source.submodule('status')}") do |state, stream, text|
|
46
|
+
# parsing the output of "git submodule status" command
|
47
|
+
# and collecting paths of all submodules into an array
|
48
|
+
submodules = text.split(/\n/).collect do |submodule|
|
49
|
+
$~[1] if submodule.rstrip =~ /.\w{40} ([^()]+)($| \(.*\)$)/
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if submodules.size > 0 then
|
54
|
+
# init and update submodules if they were found
|
55
|
+
scm_run("cd #{dir} && "+
|
56
|
+
"#{source.submodule('init')} && "+
|
57
|
+
"#{source.submodule('update')} "
|
58
|
+
)
|
59
|
+
# and descend into them to repeat the process recursively
|
60
|
+
submodules.each { |submodule| update_submodules("#{dir}/#{submodule}") }
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: morhekil-capistrano-deepmodules
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleg Ivanov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This plugin allows you to easily deploy git repositories with submodules nested at more then one level.%
|
17
|
+
email: morhekil@morhekil.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/capistrano/deepmodules.rb
|
26
|
+
- capistrano-deepmodules.gemspec
|
27
|
+
- README
|
28
|
+
has_rdoc: false
|
29
|
+
homepage: http://speakmy.name
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project: capistrano-deepmodules
|
50
|
+
rubygems_version: 1.2.0
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: Capistrano plugin to deploy Git repos with nested submodules.
|
54
|
+
test_files: []
|
55
|
+
|