capistrano-git-copy 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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +10 -1
- data/lib/capistrano/git/copy.rb +1 -0
- data/lib/capistrano/git_copy.rb +1 -2
- data/lib/capistrano/git_copy/task.rb +1 -0
- data/lib/capistrano/git_copy/tasks/deploy.cap +6 -0
- data/lib/capistrano/git_copy/utility.rb +16 -5
- data/lib/capistrano/git_copy/version.rb +1 -1
- data/vendor/git-archive-all/git-archive-all +15 -17
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4ae3564eccef2c188c4176c2ad8f2276b1f7c88
|
4
|
+
data.tar.gz: 993bfa2dc61a9c78376b5af0847f7c0fed5c6ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4833479a333245dda86f3b10fe27b90fd5050be08b9ec10444d751c11745c75d586de4d6e67b5d25ea1d1869b888aeb22aa1e71f219579f268f839a76b98c7b5
|
7
|
+
data.tar.gz: 31bd01e829bd93683883deb00a2ba0f960979d1f5badd3e77b4f7e6d855eb8b0a12b9607e05e98b676d2d87de7a22de1312c8989da00f3455abdee9e442a024e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.1.0 (2015-08-10)
|
4
|
+
### Changes
|
5
|
+
- Deprecated: require 'capistrano/git/copy'
|
6
|
+
- Allow to skip submodules (uses _git archive_ instead of _git-archive-all_)
|
7
|
+
### Fixed
|
8
|
+
- updated _git-archive-all_ to v1.11
|
9
|
+
- prevent tasks from being executed multiple times
|
10
|
+
|
3
11
|
## 1.0.2 (2015-05-26)
|
4
12
|
### Fixed
|
5
13
|
- use commit hash to fetch revision for log
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
[![Dependencies](https://img.shields.io/gemnasium/ydkn/capistrano-git-copy.svg)](https://gemnasium.com/ydkn/capistrano-git-copy)
|
3
3
|
[![Code Climate](https://img.shields.io/codeclimate/github/ydkn/capistrano-git-copy.svg)](https://codeclimate.com/github/ydkn/capistrano-git-copy)
|
4
4
|
|
5
|
+
[![Join the chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ydkn/capistrano-git-copy)
|
6
|
+
|
7
|
+
|
5
8
|
# Capistrano::GitCopy
|
6
9
|
|
7
10
|
Creates a tar archive locally from the git repository and uploads it to the remote server.
|
@@ -19,13 +22,19 @@ end
|
|
19
22
|
And require it in your `Capfile`:
|
20
23
|
|
21
24
|
```ruby
|
22
|
-
require 'capistrano/
|
25
|
+
require 'capistrano/git_copy'
|
23
26
|
```
|
24
27
|
|
25
28
|
Now use `git_copy` as your SCM type in your `config/deploy.rb`:
|
26
29
|
|
27
30
|
set :scm, :git_copy
|
28
31
|
|
32
|
+
By default, it includes all submodules into the deployment package. However,
|
33
|
+
if they are not needed in a particular deployment, you can disable them with
|
34
|
+
a configuration option:
|
35
|
+
|
36
|
+
set :with_submodules, false
|
37
|
+
|
29
38
|
## Notes
|
30
39
|
|
31
40
|
* Uses [git-archive-all](https://github.com/Kentzo/git-archive-all) for bundling repositories.
|
data/lib/capistrano/git/copy.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
STDERR.puts("[DEPRECATION] Please change \"require 'capistrano/git/copy'\" to \"require 'capistrano/git_copy'\" in your Capfile.")
|
data/lib/capistrano/git_copy.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path('../tasks/deploy.cap', __FILE__)
|
@@ -5,8 +5,11 @@ module Capistrano
|
|
5
5
|
module GitCopy
|
6
6
|
# Utility stuff to avoid cluttering of deploy.cap
|
7
7
|
class Utility
|
8
|
+
attr_reader :with_submodules
|
9
|
+
|
8
10
|
def initialize(context)
|
9
11
|
@context = context
|
12
|
+
@with_submodules = fetch(:with_submodules, true)
|
10
13
|
end
|
11
14
|
|
12
15
|
# Check if repo cache exists
|
@@ -40,20 +43,28 @@ module Capistrano
|
|
40
43
|
git :reset, '--hard', commit_hash
|
41
44
|
|
42
45
|
# submodules
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
if with_submodules
|
47
|
+
git :submodule, :init
|
48
|
+
git :submodule, :update
|
49
|
+
git :submodule, :foreach, '--recursive', :git, :submodule, :update, '--init'
|
50
|
+
end
|
46
51
|
|
47
52
|
# cleanup
|
48
53
|
git :clean, '-d', '-f'
|
49
|
-
|
54
|
+
if with_submodules
|
55
|
+
git :submodule, :foreach, '--recursive', :git, :clean, '-d', '-f'
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
# Create tar archive
|
53
60
|
#
|
54
61
|
# @return void
|
55
62
|
def prepare_release
|
56
|
-
|
63
|
+
if with_submodules
|
64
|
+
execute git_archive_all_bin, "--prefix=''", archive_path
|
65
|
+
else
|
66
|
+
git "archive --format=tar HEAD | gzip > #{archive_path}"
|
67
|
+
end
|
57
68
|
end
|
58
69
|
|
59
70
|
# Upload and extract release
|
@@ -7,7 +7,7 @@ from __future__ import unicode_literals
|
|
7
7
|
__version__ = "1.9"
|
8
8
|
|
9
9
|
import logging
|
10
|
-
from os import extsep, path, readlink
|
10
|
+
from os import extsep, path, readlink, curdir
|
11
11
|
from subprocess import CalledProcessError, Popen, PIPE
|
12
12
|
import sys
|
13
13
|
import tarfile
|
@@ -64,7 +64,7 @@ class GitArchiver(object):
|
|
64
64
|
try:
|
65
65
|
self.run_shell("[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1", main_repo_abspath)
|
66
66
|
except Exception as e:
|
67
|
-
raise ValueError("Not a git repository (or any of the parent directories)."
|
67
|
+
raise ValueError("Not a git repository (or any of the parent directories).")
|
68
68
|
|
69
69
|
main_repo_abspath = path.abspath(self.read_git_shell('git rev-parse --show-toplevel', main_repo_abspath).rstrip())
|
70
70
|
|
@@ -94,7 +94,7 @@ class GitArchiver(object):
|
|
94
94
|
if output_format is None:
|
95
95
|
file_name, file_ext = path.splitext(output_path)
|
96
96
|
output_format = file_ext[len(extsep):].lower()
|
97
|
-
self.LOG.debug("Output format is not explicitly set, determined format is {
|
97
|
+
self.LOG.debug("Output format is not explicitly set, determined format is {}.".format(output_format))
|
98
98
|
|
99
99
|
if not dry_run:
|
100
100
|
if output_format == 'zip':
|
@@ -116,19 +116,19 @@ class GitArchiver(object):
|
|
116
116
|
elif output_format == 'txz':
|
117
117
|
t_mode = 'w:xz'
|
118
118
|
else:
|
119
|
-
t_mode = 'w:{
|
119
|
+
t_mode = 'w:{}'.format(output_format)
|
120
120
|
|
121
121
|
archive = tarfile.open(path.abspath(output_path), t_mode)
|
122
122
|
add_file = lambda file_path, arcname: archive.add(file_path, arcname)
|
123
123
|
else:
|
124
|
-
raise RuntimeError("Unknown format: {
|
124
|
+
raise RuntimeError("Unknown format: {}".format(output_format))
|
125
125
|
|
126
126
|
def archiver(file_path, arcname):
|
127
|
-
self.LOG.debug("Compressing {
|
127
|
+
self.LOG.debug("Compressing {} => {}...".format(file_path, arcname))
|
128
128
|
add_file(file_path, arcname)
|
129
129
|
else:
|
130
130
|
archive = None
|
131
|
-
archiver = lambda file_path, arcname: self.LOG.info("{
|
131
|
+
archiver = lambda file_path, arcname: self.LOG.info("{} => {}".format(file_path, arcname))
|
132
132
|
|
133
133
|
self.archive_all_files(archiver)
|
134
134
|
|
@@ -225,7 +225,7 @@ class GitArchiver(object):
|
|
225
225
|
patterns = exclude_patterns[key]
|
226
226
|
for p in patterns:
|
227
227
|
if fnmatch(file_name, p) or fnmatch(repo_file_path, p):
|
228
|
-
self.LOG.debug("Exclude pattern matched {
|
228
|
+
self.LOG.debug("Exclude pattern matched {}: {}".format(p, repo_file_path))
|
229
229
|
is_excluded = True
|
230
230
|
|
231
231
|
if not len(components):
|
@@ -270,13 +270,12 @@ class GitArchiver(object):
|
|
270
270
|
# Git puts path in quotes if file path has unicode characters.
|
271
271
|
repo_file_path = repo_file_path.strip('"') # file path relative to current repo
|
272
272
|
file_name = path.basename(repo_file_path)
|
273
|
+
main_repo_file_path = path.join(repo_path, repo_file_path) # file path relative to the main repo
|
273
274
|
|
274
275
|
# Only list symlinks and files that don't start with git.
|
275
|
-
if file_name.startswith(".git") or (not path.islink(
|
276
|
+
if file_name.startswith(".git") or (not path.islink(main_repo_file_path) and path.isdir(main_repo_file_path)):
|
276
277
|
continue
|
277
278
|
|
278
|
-
main_repo_file_path = path.join(repo_path, repo_file_path) # file path relative to the main repo
|
279
|
-
|
280
279
|
if self.is_file_excluded(repo_abspath, repo_file_path, exclude_patterns):
|
281
280
|
continue
|
282
281
|
|
@@ -286,7 +285,7 @@ class GitArchiver(object):
|
|
286
285
|
self.run_shell("git submodule init", repo_abspath)
|
287
286
|
self.run_shell("git submodule update", repo_abspath)
|
288
287
|
|
289
|
-
for submodule_path in self.read_shell("git submodule --quiet foreach 'pwd'", repo_abspath).splitlines():
|
288
|
+
for submodule_path in self.read_shell("git submodule --quiet foreach 'pwd -P'", repo_abspath).splitlines():
|
290
289
|
# Shell command returns absolute paths to submodules.
|
291
290
|
submodule_path = path.relpath(submodule_path, self.main_repo_abspath)
|
292
291
|
for file_path in self.walk_git_files(submodule_path):
|
@@ -323,7 +322,7 @@ class GitArchiver(object):
|
|
323
322
|
raise ValueError("abspath MUST be absoulte path.")
|
324
323
|
|
325
324
|
if not path.commonprefix([repo_abspath, abspath]):
|
326
|
-
raise ValueError("abspath (\"{
|
325
|
+
raise ValueError("abspath (\"{}\") MUST have common prefix with repo_abspath (\"{}\")".format(abspath, repo_abspath))
|
327
326
|
|
328
327
|
components = []
|
329
328
|
|
@@ -333,8 +332,7 @@ class GitArchiver(object):
|
|
333
332
|
if tail:
|
334
333
|
components.insert(0, tail)
|
335
334
|
|
336
|
-
|
337
|
-
components.insert(0, path.relpath(repo_abspath, repo_abspath))
|
335
|
+
components.insert(0, curdir)
|
338
336
|
return components
|
339
337
|
|
340
338
|
@staticmethod
|
@@ -425,7 +423,7 @@ if __name__ == '__main__':
|
|
425
423
|
from optparse import OptionParser
|
426
424
|
|
427
425
|
parser = OptionParser(usage="usage: %prog [-v] [--prefix PREFIX] [--no-exclude] [--force-submodules] [--extra EXTRA1 [EXTRA2]] [--dry-run] OUTPUT_FILE",
|
428
|
-
version="%prog {
|
426
|
+
version="%prog {}".format(__version__))
|
429
427
|
|
430
428
|
parser.add_option('--prefix',
|
431
429
|
type='string',
|
@@ -491,6 +489,6 @@ if __name__ == '__main__':
|
|
491
489
|
options.extra)
|
492
490
|
archiver.create(output_file_path, options.dry_run)
|
493
491
|
except Exception as e:
|
494
|
-
parser.exit(2, "{
|
492
|
+
parser.exit(2, "{}\n".format(e))
|
495
493
|
|
496
494
|
sys.exit(0)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-git-copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Schwab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- capistrano-git-copy.gemspec
|
90
90
|
- lib/capistrano/git/copy.rb
|
91
91
|
- lib/capistrano/git_copy.rb
|
92
|
+
- lib/capistrano/git_copy/task.rb
|
92
93
|
- lib/capistrano/git_copy/tasks/deploy.cap
|
93
94
|
- lib/capistrano/git_copy/utility.rb
|
94
95
|
- lib/capistrano/git_copy/version.rb
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: '0'
|
114
115
|
requirements: []
|
115
116
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.4.
|
117
|
+
rubygems_version: 2.4.8
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: Copy local git repository deploy strategy for capistrano
|