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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e5ef7bab4e5be2f012b843ae03aa534f161ab0b
4
- data.tar.gz: 06c0fb3e75d82960cfd02edfe8e027bb26ef2d34
3
+ metadata.gz: bb2d212e098eb884c15a2a7a3f0b9dbc6e5a137e
4
+ data.tar.gz: 672168b65f58dc804469c16f3cca712d389c0240
5
5
  SHA512:
6
- metadata.gz: e068fc6c5771ce093cc4757c758b07c692aebf9e92ad643fbfb87733f3167ef4ad91fa23dfc5a9b0d802cd460f33ac1682607d9575481d382482e1ad87fb3407
7
- data.tar.gz: c7bb4213bd1fc5945039b9fadffd5db048105643ee31ecf84e891028458e7a41e038cdf5980ab83c92d08800a32596586b34d5afc734798a818253b22464e291
6
+ metadata.gz: 55587ebd76886541942c3d0336fcfaaf992f34dac15d75073fee6293c90523ab14cd0e0fbd63ccce9f9a66eda9b218acf09c311848259b482c0057339bfab32e
7
+ data.tar.gz: 3118f37767103641b52ba4ac5991267d78daa591e7ac3ef753a25ecefbb5b3f90f7d124361a1ff83e4aa1ff5395839b541bd73b40a32964d7904080525bc0f6a
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.2 (2017-04-30)
4
+ ### Changes
5
+ - updated _git-archive-all_ to 1.16.4
6
+
3
7
  ## 1.3.1 (2017-03-18)
4
8
  ### Fixed
5
9
  - missing require of tmpdir (see #22)
@@ -3,6 +3,6 @@ module Capistrano
3
3
  # GitCopy
4
4
  module GitCopy
5
5
  # gem version
6
- VERSION = '1.3.1'
6
+ VERSION = '1.3.2'
7
7
  end
8
8
  end
@@ -34,7 +34,7 @@ import tarfile
34
34
  from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
35
35
  import re
36
36
 
37
- __version__ = "1.15"
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: string
62
+ @type prefix: str
63
63
 
64
64
  @param exclude: Determines whether archiver should follow rules specified in .gitattributes files.
65
- @type exclude: bool
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: string
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("You MUST pass absolute path to the main git repository.")
85
+ raise ValueError("main_repo_abspath must be an absolute path")
86
86
 
87
87
  try:
88
- path.isdir(".git") or self.run_shell("git rev-parse --git-dir > /dev/null 2>&1", main_repo_abspath)
89
- except Exception as e:
90
- raise ValueError("{0} not a git repository (or any of the parent directories).".format(main_repo_abspath))
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: string
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: string
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("Unknown format: {0}".format(output_format))
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) # this will take care of submodule init and update
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'), ['Foo*', '*Bar']}
168
+ E.g. {('.', 'Catalyst', 'Editions', 'Base'): ['Foo*', '*Bar']}
174
169
 
175
- @type repo_abspath: string
176
- @param repo_abspath: Absolute path to the git repository.
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
- @rtype: dict
182
- @return: Dictionary representing exclude patterns.
183
- Keys are tuples of strings. Values are lists of strings.
184
- Returns None if self.exclude is not set.
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.read_shell("git config --get core.attributesfile", repo_abspath).rstrip()
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
- @type repo_file_path: string
233
- @param repo_file_path: Path to a file within repo_abspath.
227
+ @param repo_file_path: Path to a file within repo_abspath.
228
+ @type repo_file_path: str
234
229
 
235
- @type exclude_patterns: dict
236
- @param exclude_patterns: Exclude patterns with format specified for get_exclude_patterns.
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
- @type repo_path: string
291
- @param repo_path: Path to the git submodule repository relative to main_repo_abspath.
286
+ @param repo_path: Path to the git submodule repository relative to main_repo_abspath.
287
+ @type repo_path: str
292
288
 
293
- @rtype: iterator
294
- @return: Iterator to traverse files under git control relative to main_repo_abspath.
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.read_git_shell(
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
- file_name = path.basename(repo_file_path)
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(main_repo_file_path) and path.isdir(main_repo_file_path):
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.run_shell("git submodule init", repo_abspath)
320
- self.run_shell("git submodule update", repo_abspath)
321
-
322
- gitmodulesfile = path.join(repo_path, ".gitmodules")
323
- if path.isfile(gitmodulesfile):
324
- with open(gitmodulesfile) as f:
325
- for line in f.readlines():
326
- m = re.match("^\s*path\s*=\s*(.*)\s*$", line)
327
- if m:
328
- submodule_path = m.group(1)
329
- submodule_path = path.join(repo_path, submodule_path)
330
- for file_path in self.walk_git_files(submodule_path):
331
- yield file_path
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 '.' (concrete symbol depends on OS).
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: string
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: string
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 run_shell(cmd, cwd=None):
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: string
391
+ @type cwd: str
444
392
  @param cwd: Working directory.
445
393
 
446
- @rtype: string
447
- @return: Output of the command.
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.1
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-03-18 00:00:00.000000000 Z
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.8
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.