capistrano-git-external 0.1

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.
@@ -0,0 +1,5 @@
1
+ require 'capistrano/recipes/deploy/scm/git'
2
+ require 'capistrano_git_external/git_patch'
3
+
4
+ Capistrano::Deploy::SCM::Git.send(:include, CapistranoGitExternal::GitPatch)
5
+
@@ -0,0 +1,44 @@
1
+ module CapistranoGitExternal
2
+ module GitPatch
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ base.send(:include, InstanceMethods)
6
+
7
+ base.class_eval do
8
+ alias_method :checkout_without_externals, :checkout
9
+ alias_method :checkout, :checkout_with_externals
10
+
11
+ alias_method :sync_without_externals, :sync
12
+ alias_method :sync, :sync_with_externals
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ end
18
+
19
+ module InstanceMethods
20
+ def add_git_external_commands(method_name, revision, destination)
21
+ git = command
22
+ execute = []
23
+
24
+ execute << self.send(method_name, revision, destination)
25
+
26
+ if variable(:git_enable_externals)
27
+ execute << "#{git} external init"
28
+ execute << "#{git} external update"
29
+ end
30
+
31
+ execute.join(" && ")
32
+ end
33
+
34
+ def checkout_with_externals(revision, destination)
35
+ add_git_external_commands(:checkout_without_externals, revision, destination)
36
+ end
37
+
38
+ def sync_with_externals(revision, destination)
39
+ add_git_external_commands(:sync_without_externals, revision, destination)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'capistrano_git_external'
3
+ require 'test/unit'
4
+
5
+ class GitPatchTest < Test::Unit::TestCase
6
+ class TestSCM < Capistrano::Deploy::SCM::Git
7
+ default_command "git"
8
+ end
9
+
10
+ def setup
11
+ @config = {}
12
+
13
+ @source = TestSCM.new(@config)
14
+ end
15
+
16
+ def test_checkout_without_externals
17
+ @config[:repository] = "git@somehost.com:project.git"
18
+ dest = "/var/www"
19
+ rev = 'c2d9e79'
20
+
21
+ assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest)
22
+ end
23
+
24
+ def test_checkout_with_externals
25
+ @config[:git_enable_externals] = 1
26
+ @config[:repository] = "git@somehost.com:project.git"
27
+ dest = "/var/www"
28
+ rev = 'c2d9e79'
29
+
30
+ assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git external init && git external update", @source.checkout(rev, dest)
31
+ end
32
+
33
+ def test_sync_without_externals
34
+ dest = "/var/www"
35
+ rev = 'c2d9e79'
36
+ assert_equal "cd #{dest} && git fetch -q origin && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest)
37
+ end
38
+
39
+ def test_sync_with_externals
40
+ @config[:git_enable_externals] = 1
41
+ dest = "/var/www"
42
+ rev = 'c2d9e79'
43
+ assert_equal "cd #{dest} && git fetch -q origin && git reset -q --hard #{rev} && git clean -q -d -x -f && git external init && git external update", @source.sync(rev, dest)
44
+ end
45
+ end
46
+
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-git-external
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Daniel Cestari
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-21 00:00:00 -04:30
18
+ default_executable:
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: 61
29
+ segments:
30
+ - 2
31
+ - 5
32
+ - 19
33
+ version: 2.5.19
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Git External commands need to be run on every deploy before the update_code task, this extension allows the user to activate this functionality
37
+ email:
38
+ - dcestari@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/capistrano-git-external/git-patch.rb
47
+ - lib/capistrano-git-external.rb
48
+ - test/git_patch_test.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/dcestari/capistrano-git-external
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Capistrano patch for using git external
83
+ test_files:
84
+ - test/git_patch_test.rb