capistrano-git-with-submodules 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8d3bdb9ce8029c090cd6851555cdb860d3e2913
4
- data.tar.gz: 50bd07a4cd3f69653f3ef74c82a50e45721caa85
3
+ metadata.gz: 471b27ace6a52dcfda49776f81b91002cc1d2304
4
+ data.tar.gz: 6b2f499bbb3906e63a6ba71474fd433017217a60
5
5
  SHA512:
6
- metadata.gz: 15cd88d438ac84b1da7c6239eccca2fe236735d7eefa733ed2cb9bb0074aaddcc40358f598d73e3c2cebe043e3741e409b848a9ae3697c713203d262fc119a41
7
- data.tar.gz: bf3b61b5f39597ab902b0ce2d76d3a0dd55eef11ab034d4e857a198baf954111de62643df06652f7c2d605eae2eb06d83c5469db8a3221f104f3c89ac3a53309
6
+ metadata.gz: c9f588b21d46c69cc6731e5e3c8a858ea5f92c3771e7da061de694da4b5a12039cba25f44869d87a3fc76dd8c6f13f52eee75276ea5ccb76accbb26332686406
7
+ data.tar.gz: 3cdd46ac00260897ea79b4c9bdc023e0ba7df13ac95b5e787062e4cc30244821a681503fa7f17e7fdb15a3695d2480cf153f97e25adfb2371e09eda5b7db932a
data/README.md CHANGED
@@ -8,7 +8,7 @@ For Capistrano 3.0-3.6 use old [capistrano-git-submodule-strategy](https://githu
8
8
 
9
9
  ####Gemfile
10
10
  ```ruby
11
- gem 'capistrano-git-with-submodules', '~> 0.1', :github => 'ekho/capistrano-git-with-submodules'
11
+ gem 'capistrano-git-with-submodules', '~> 1.1', :github => 'ekho/capistrano-git-with-submodules'
12
12
  ```
13
13
 
14
14
  ####Capfile
@@ -1,18 +1,14 @@
1
1
  require "capistrano/scm/git"
2
2
 
3
3
  class Capistrano::SCM::Git::WithSubmodules < Capistrano::SCM::Git
4
+ alias_method :origin_archive_to_release_path, :archive_to_release_path if method_defined?(:archive_to_release_path)
4
5
 
5
6
  def archive_to_release_path
6
- fail ':repo_tree currently not supported by GitWithSubmodules' if fetch(:repo_tree)
7
+ origin_archive_to_release_path
7
8
 
9
+ return unless backend.test(:test, '-e', release_path) && backend.test("ls -A #{release_path} | read linevar")
8
10
 
9
- return if backend.test(:test, '-e', release_path) && backend.test("ls -A #{release_path} | read linevar")
10
-
11
- _clone_repo
12
-
13
- backend.within_only release_path do
14
- git :submodule, 'update', '--init', '--recursive'
15
- end
11
+ submodules_to_release_path
16
12
 
17
13
  unless fetch(:git_keep_meta, false)
18
14
  verbose = Rake.application.options.trace ? 'v' : ''
@@ -20,40 +16,24 @@ class Capistrano::SCM::Git::WithSubmodules < Capistrano::SCM::Git
20
16
  end
21
17
  end
22
18
 
23
- def _clone_repo
24
- git_version = backend.capture(:git, '--version').strip.match('^git version (\d+(?:\.\d+)+)$')
25
-
26
- if git_version.nil? || git_version[1] < '2.3.0'
27
- _clone_repo_with_old_git
28
- else
29
- _clone_repo_with_fresh_git
30
- end
31
- end
32
-
33
- def _clone_repo_with_fresh_git
34
- git :clone, '--reference', repo_path.to_s, '--dissociate', (fetch(:git_keep_meta, false) ? '' : '--depth=1'), '-b', fetch(:branch), repo_url, release_path
35
- end
36
-
37
- def _clone_repo_with_old_git
38
- git :clone, (fetch(:git_keep_meta, false) ? '' : '--depth=1'), '-b', fetch(:branch), "file://#{repo_path}", release_path
39
- backend.within_only release_path do
40
- git :remote, 'set-url', 'origin', repo_url
41
- end
42
- end
43
- end
44
-
45
-
46
- # shit hack to execute command only in specified directory
47
- module SSHKit
48
- module Backend
49
- class Abstract
50
- def within_only(directory, &block)
51
- pwd = @pwd
52
- @pwd = []
53
- within directory, &block
54
- ensure
55
- @pwd = pwd
19
+ ##
20
+ # Adds configured submodules recursively to release
21
+ # It does so by connecting the bare repo and the work tree using environment variables
22
+ # The reset creates a temporary index, but does not change the working directory
23
+ # The temporary index is removed after everything is done
24
+ def submodules_to_release_path
25
+ temp_index_file_path = release_path.join("INDEX_#{fetch(:release_timestamp)}")
26
+ backend.within "../releases/#{fetch(:release_timestamp)}" do
27
+ backend.with(
28
+ 'GIT_DIR' => repo_path.to_s,
29
+ 'GIT_WORK_TREE' => release_path.to_s,
30
+ 'GIT_INDEX_FILE' => temp_index_file_path.to_s
31
+ ) do
32
+ git :reset, '--mixed', fetch(:branch)
33
+ git :submodule, 'update', '--init', '--depth', 1, '--checkout', '--recursive'
34
+ verbose = Rake.application.options.trace ? 'v' : ''
35
+ backend.execute :rm, "-f#{verbose}", temp_index_file_path.to_s
56
36
  end
57
37
  end
58
38
  end
59
- end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-git-with-submodules
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Gorbylev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano