capistrano-git-copy 1.3.1 → 1.3.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/capistrano/git_copy/version.rb +1 -1
- data/vendor/git-archive-all/git_archive_all.py +64 -116
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb2d212e098eb884c15a2a7a3f0b9dbc6e5a137e
|
4
|
+
data.tar.gz: 672168b65f58dc804469c16f3cca712d389c0240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55587ebd76886541942c3d0336fcfaaf992f34dac15d75073fee6293c90523ab14cd0e0fbd63ccce9f9a66eda9b218acf09c311848259b482c0057339bfab32e
|
7
|
+
data.tar.gz: 3118f37767103641b52ba4ac5991267d78daa591e7ac3ef753a25ecefbb5b3f90f7d124361a1ff83e4aa1ff5395839b541bd73b40a32964d7904080525bc0f6a
|
data/CHANGELOG.md
CHANGED
@@ -34,7 +34,7 @@ import tarfile
|
|
34
34
|
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
|
35
35
|
import re
|
36
36
|
|
37
|
-
__version__ = "1.
|
37
|
+
__version__ = "1.16.4"
|
38
38
|
|
39
39
|
|
40
40
|
class GitArchiver(object):
|
@@ -59,10 +59,10 @@ class GitArchiver(object):
|
|
59
59
|
baz
|
60
60
|
foo/
|
61
61
|
bar
|
62
|
-
@type prefix:
|
62
|
+
@type prefix: str
|
63
63
|
|
64
64
|
@param exclude: Determines whether archiver should follow rules specified in .gitattributes files.
|
65
|
-
@type exclude:
|
65
|
+
@type exclude: bool
|
66
66
|
|
67
67
|
@param force_sub: Determines whether submodules are initialized and updated before archiving.
|
68
68
|
@type force_sub: bool
|
@@ -74,7 +74,7 @@ class GitArchiver(object):
|
|
74
74
|
If given path is path to a subdirectory (but not a submodule directory!) it will be replaced
|
75
75
|
with abspath to top-level directory of the repository.
|
76
76
|
If None, current cwd is used.
|
77
|
-
@type main_repo_abspath:
|
77
|
+
@type main_repo_abspath: str
|
78
78
|
"""
|
79
79
|
if extra is None:
|
80
80
|
extra = []
|
@@ -82,17 +82,12 @@ class GitArchiver(object):
|
|
82
82
|
if main_repo_abspath is None:
|
83
83
|
main_repo_abspath = path.abspath('')
|
84
84
|
elif not path.isabs(main_repo_abspath):
|
85
|
-
raise ValueError("
|
85
|
+
raise ValueError("main_repo_abspath must be an absolute path")
|
86
86
|
|
87
87
|
try:
|
88
|
-
path.
|
89
|
-
except
|
90
|
-
raise ValueError("{0} not a git repository
|
91
|
-
|
92
|
-
main_repo_abspath = path.abspath(
|
93
|
-
self.read_git_shell('git rev-parse --show-toplevel', main_repo_abspath)
|
94
|
-
.rstrip()
|
95
|
-
)
|
88
|
+
main_repo_abspath = path.abspath(self.run_git_shell('git rev-parse --show-toplevel', main_repo_abspath).rstrip())
|
89
|
+
except CalledProcessError:
|
90
|
+
raise ValueError("{0} is not part of a git repository".format(main_repo_abspath))
|
96
91
|
|
97
92
|
self.prefix = prefix
|
98
93
|
self.exclude = exclude
|
@@ -108,14 +103,14 @@ class GitArchiver(object):
|
|
108
103
|
Supported formats are: gz, zip, bz2, xz, tar, tgz, txz
|
109
104
|
|
110
105
|
@param output_path: Output file path.
|
111
|
-
@type output_path:
|
106
|
+
@type output_path: str
|
112
107
|
|
113
108
|
@param dry_run: Determines whether create should do nothing but print what it would archive.
|
114
109
|
@type dry_run: bool
|
115
110
|
|
116
111
|
@param output_format: Determines format of the output archive. If None, format is determined from extension
|
117
112
|
of output_file_path.
|
118
|
-
@type output_format:
|
113
|
+
@type output_format: str
|
119
114
|
"""
|
120
115
|
if output_format is None:
|
121
116
|
file_name, file_ext = path.splitext(output_path)
|
@@ -149,7 +144,7 @@ class GitArchiver(object):
|
|
149
144
|
def add_file(file_path, arcname):
|
150
145
|
archive.add(file_path, arcname)
|
151
146
|
else:
|
152
|
-
raise RuntimeError("
|
147
|
+
raise RuntimeError("unknown format: {0}".format(output_format))
|
153
148
|
|
154
149
|
def archiver(file_path, arcname):
|
155
150
|
self.LOG.debug("Compressing {0} => {1}...".format(file_path, arcname))
|
@@ -160,7 +155,7 @@ class GitArchiver(object):
|
|
160
155
|
def archiver(file_path, arcname):
|
161
156
|
self.LOG.info("{0} => {1}".format(file_path, arcname))
|
162
157
|
|
163
|
-
self.archive_all_files(archiver)
|
158
|
+
self.archive_all_files(archiver)
|
164
159
|
|
165
160
|
if archive is not None:
|
166
161
|
archive.close()
|
@@ -170,18 +165,18 @@ class GitArchiver(object):
|
|
170
165
|
Returns exclude patterns for a given repo. It looks for .gitattributes files in repo_file_paths.
|
171
166
|
|
172
167
|
Resulting dictionary will contain exclude patterns per path (relative to the repo_abspath).
|
173
|
-
E.g. {('.', 'Catalyst', 'Editions', 'Base')
|
168
|
+
E.g. {('.', 'Catalyst', 'Editions', 'Base'): ['Foo*', '*Bar']}
|
174
169
|
|
175
|
-
@
|
176
|
-
@
|
170
|
+
@param repo_abspath: Absolute path to the git repository.
|
171
|
+
@type repo_abspath: str
|
177
172
|
|
178
|
-
@type repo_file_paths: list
|
179
173
|
@param repo_file_paths: List of paths relative to the repo_abspath that are under git control.
|
174
|
+
@type repo_file_paths: list
|
180
175
|
|
181
|
-
@
|
182
|
-
|
183
|
-
|
184
|
-
|
176
|
+
@return: Dictionary representing exclude patterns.
|
177
|
+
Keys are tuples of strings. Values are lists of strings.
|
178
|
+
Returns None if self.exclude is not set.
|
179
|
+
@rtype: dict or None
|
185
180
|
"""
|
186
181
|
if not self.exclude:
|
187
182
|
return None
|
@@ -201,7 +196,7 @@ class GitArchiver(object):
|
|
201
196
|
|
202
197
|
# There may be no gitattributes.
|
203
198
|
try:
|
204
|
-
global_attributes_abspath = self.
|
199
|
+
global_attributes_abspath = self.run_git_shell("git config --get core.attributesfile", repo_abspath).rstrip()
|
205
200
|
exclude_patterns[()] = read_attributes(global_attributes_abspath)
|
206
201
|
except:
|
207
202
|
# And it's valid to not have them.
|
@@ -226,17 +221,17 @@ class GitArchiver(object):
|
|
226
221
|
"""
|
227
222
|
Checks whether file at a given path is excluded.
|
228
223
|
|
229
|
-
@type repo_abspath: string
|
230
224
|
@param repo_abspath: Absolute path to the git repository.
|
225
|
+
@type repo_abspath: str
|
231
226
|
|
232
|
-
@
|
233
|
-
@
|
227
|
+
@param repo_file_path: Path to a file within repo_abspath.
|
228
|
+
@type repo_file_path: str
|
234
229
|
|
235
|
-
@
|
236
|
-
@
|
230
|
+
@param exclude_patterns: Exclude patterns with format specified for get_exclude_patterns.
|
231
|
+
@type exclude_patterns: dict
|
237
232
|
|
238
|
-
@rtype: bool
|
239
233
|
@return: True if file should be excluded. Otherwise False.
|
234
|
+
@rtype: bool
|
240
235
|
"""
|
241
236
|
if exclude_patterns is None or not len(exclude_patterns):
|
242
237
|
return False
|
@@ -271,6 +266,7 @@ class GitArchiver(object):
|
|
271
266
|
|
272
267
|
@param archiver: Callable that accepts 2 arguments:
|
273
268
|
abspath to file on the system and relative path within archive.
|
269
|
+
@type archiver: Callable
|
274
270
|
"""
|
275
271
|
for file_path in self.extra:
|
276
272
|
archiver(path.abspath(file_path), path.join(self.prefix, file_path))
|
@@ -287,14 +283,14 @@ class GitArchiver(object):
|
|
287
283
|
|
288
284
|
Recurs into submodules as well.
|
289
285
|
|
290
|
-
@
|
291
|
-
@
|
286
|
+
@param repo_path: Path to the git submodule repository relative to main_repo_abspath.
|
287
|
+
@type repo_path: str
|
292
288
|
|
293
|
-
@
|
294
|
-
@
|
289
|
+
@return: Iterator to traverse files under git control relative to main_repo_abspath.
|
290
|
+
@rtype: Iterable
|
295
291
|
"""
|
296
292
|
repo_abspath = path.join(self.main_repo_abspath, repo_path)
|
297
|
-
repo_file_paths = self.
|
293
|
+
repo_file_paths = self.run_git_shell(
|
298
294
|
"git ls-files --cached --full-name --no-empty-directory",
|
299
295
|
repo_abspath
|
300
296
|
).splitlines()
|
@@ -303,11 +299,11 @@ class GitArchiver(object):
|
|
303
299
|
for repo_file_path in repo_file_paths:
|
304
300
|
# Git puts path in quotes if file path has unicode characters.
|
305
301
|
repo_file_path = repo_file_path.strip('"') # file path relative to current repo
|
306
|
-
|
302
|
+
repo_file_abspath = path.join(repo_abspath, repo_file_path) # absolute file path
|
307
303
|
main_repo_file_path = path.join(repo_path, repo_file_path) # file path relative to the main repo
|
308
304
|
|
309
305
|
# Only list symlinks and files.
|
310
|
-
if not path.islink(
|
306
|
+
if not path.islink(repo_file_abspath) and path.isdir(repo_file_abspath):
|
311
307
|
continue
|
312
308
|
|
313
309
|
if self.is_file_excluded(repo_abspath, repo_file_path, exclude_patterns):
|
@@ -316,19 +312,26 @@ class GitArchiver(object):
|
|
316
312
|
yield main_repo_file_path
|
317
313
|
|
318
314
|
if self.force_sub:
|
319
|
-
self.
|
320
|
-
self.
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
315
|
+
self.run_git_shell("git submodule init", repo_abspath)
|
316
|
+
self.run_git_shell("git submodule update", repo_abspath)
|
317
|
+
|
318
|
+
try:
|
319
|
+
repo_gitmodules_abspath = path.join(repo_abspath, ".gitmodules")
|
320
|
+
|
321
|
+
with open(repo_gitmodules_abspath) as f:
|
322
|
+
lines = f.readlines()
|
323
|
+
|
324
|
+
for l in lines:
|
325
|
+
m = re.match("^\s*path\s*=\s*(.*)\s*$", l)
|
326
|
+
|
327
|
+
if m:
|
328
|
+
submodule_path = m.group(1)
|
329
|
+
submodule_path = path.join(repo_path, submodule_path)
|
330
|
+
|
331
|
+
for submodule_file_path in self.walk_git_files(submodule_path):
|
332
|
+
yield submodule_file_path
|
333
|
+
except IOError:
|
334
|
+
pass
|
332
335
|
|
333
336
|
@staticmethod
|
334
337
|
def get_path_components(repo_abspath, abspath):
|
@@ -340,13 +343,13 @@ class GitArchiver(object):
|
|
340
343
|
'/Documents/Hobby/ParaView/Catalyst/Editions/Base/', function will return:
|
341
344
|
['.', 'Catalyst', 'Editions', 'Base']
|
342
345
|
|
343
|
-
First element is always
|
346
|
+
First element is always os.curdir (concrete symbol depends on OS).
|
344
347
|
|
345
348
|
@param repo_abspath: Absolute path to the git repository. Normalized via os.path.normpath.
|
346
|
-
@type repo_abspath:
|
349
|
+
@type repo_abspath: str
|
347
350
|
|
348
351
|
@param abspath: Absolute path to a file within repo_abspath. Normalized via os.path.normpath.
|
349
|
-
@type abspath:
|
352
|
+
@type abspath: str
|
350
353
|
|
351
354
|
@return: List of path components.
|
352
355
|
@rtype: list
|
@@ -378,73 +381,18 @@ class GitArchiver(object):
|
|
378
381
|
return components
|
379
382
|
|
380
383
|
@staticmethod
|
381
|
-
def
|
382
|
-
"""
|
383
|
-
Runs shell command.
|
384
|
-
|
385
|
-
@type cmd: string
|
386
|
-
@param cmd: Command to be executed.
|
387
|
-
|
388
|
-
@type cwd: string
|
389
|
-
@param cwd: Working directory.
|
390
|
-
|
391
|
-
@rtype: int
|
392
|
-
@return: Return code of the command.
|
393
|
-
|
394
|
-
@raise CalledProcessError: Raises exception if return code of the command is non-zero.
|
395
|
-
"""
|
396
|
-
p = Popen(cmd, shell=True, cwd=cwd)
|
397
|
-
p.wait()
|
398
|
-
|
399
|
-
if p.returncode:
|
400
|
-
raise CalledProcessError(returncode=p.returncode, cmd=cmd)
|
401
|
-
|
402
|
-
return p.returncode
|
403
|
-
|
404
|
-
@staticmethod
|
405
|
-
def read_shell(cmd, cwd=None, encoding='utf-8'):
|
406
|
-
"""
|
407
|
-
Runs shell command and reads output.
|
408
|
-
|
409
|
-
@type cmd: string
|
410
|
-
@param cmd: Command to be executed.
|
411
|
-
|
412
|
-
@type cwd: string
|
413
|
-
@param cwd: Working directory.
|
414
|
-
|
415
|
-
@type encoding: string
|
416
|
-
@param encoding: Encoding used to decode bytes returned by Popen into string.
|
417
|
-
|
418
|
-
@rtype: string
|
419
|
-
@return: Output of the command.
|
420
|
-
|
421
|
-
@raise CalledProcessError: Raises exception if return code of the command is non-zero.
|
422
|
-
"""
|
423
|
-
p = Popen(cmd, shell=True, stdout=PIPE, cwd=cwd)
|
424
|
-
output, _ = p.communicate()
|
425
|
-
output = output.decode(encoding)
|
426
|
-
|
427
|
-
if p.returncode:
|
428
|
-
if sys.version_info > (2, 6):
|
429
|
-
raise CalledProcessError(returncode=p.returncode, cmd=cmd, output=output)
|
430
|
-
else:
|
431
|
-
raise CalledProcessError(returncode=p.returncode, cmd=cmd)
|
432
|
-
|
433
|
-
return output
|
434
|
-
|
435
|
-
@staticmethod
|
436
|
-
def read_git_shell(cmd, cwd=None):
|
384
|
+
def run_git_shell(cmd, cwd=None):
|
437
385
|
"""
|
438
|
-
Runs git shell command, reads output and decodes it into unicode string
|
386
|
+
Runs git shell command, reads output and decodes it into unicode string.
|
439
387
|
|
440
|
-
@type cmd: string
|
441
388
|
@param cmd: Command to be executed.
|
389
|
+
@type cmd: str
|
442
390
|
|
443
|
-
@type cwd:
|
391
|
+
@type cwd: str
|
444
392
|
@param cwd: Working directory.
|
445
393
|
|
446
|
-
@rtype:
|
447
|
-
@return:
|
394
|
+
@rtype: str
|
395
|
+
@return: Output of the command.
|
448
396
|
|
449
397
|
@raise CalledProcessError: Raises exception if return code of the command is non-zero.
|
450
398
|
"""
|
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.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Schwab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6.
|
115
|
+
rubygems_version: 2.6.11
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Copy local git repository deploy strategy for capistrano.
|