capistrano-git-copy 1.5.4 → 1.5.5

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
  SHA256:
3
- metadata.gz: 643a1d09f446a1a37d47896f9868feeaa4030b2a0306ebab77ac24dd8bb6728d
4
- data.tar.gz: fa2212878ae3a8435e52d77a369f7b21e43444ce31d120af21037b3be0477c4e
3
+ metadata.gz: 911c6595d192844b5881b0d8a8cebc22807c1e05cb1f239180f88f75382c23df
4
+ data.tar.gz: 36ba77b942dbc78b60dc6aa3e21e2366d4ec42ac1c301c363adf5ee99efce925
5
5
  SHA512:
6
- metadata.gz: 3ac87e1fc29d7adaaedf48d9bbd92d635e0b9bd1e8a3a025c759910695bccb10605d30455d6506be030d3546fbc04bf666dcd73298ebbd78dc81ca2b949a62ee
7
- data.tar.gz: 323bd1c4beae97837dbb5a6db3d5e9afcfab223c91fe3fe538dc8fefb7a19abb2ff56d49209f82b074e044cc741dea2e352df74b81116424abca6e5dcda50b5a
6
+ metadata.gz: 6fdd39263057a50cf376c39dae078baf56314fc37e864d66b093e3ce8fad42974d1422c3697588c77b6c0c02255b9b0a251ee032d6c72e627ca4a1ffcd847c9c
7
+ data.tar.gz: efacaa507ac8796d60c21c329dde4920f52c9ce456a6031320973db3f5c2d32a4defb32fe489abf64c388c3d1a718f60e8275bd57534d934521eb8f4158748d0
@@ -5,9 +5,9 @@ stages:
5
5
 
6
6
  build:
7
7
  stage: build
8
- image: ruby:2.5
8
+ image: ruby:2.6
9
9
  script:
10
- - gem install bundler --no-ri --no-rdoc
10
+ - gem install bundler --no-document
11
11
  - bundle update
12
12
  artifacts:
13
13
  paths:
@@ -15,9 +15,9 @@ build:
15
15
 
16
16
  rubocop:
17
17
  stage: codequality
18
- image: ruby:2.5
18
+ image: ruby:2.6
19
19
  script:
20
- - gem install rubocop --no-ri --no-rdoc
20
+ - gem install rubocop rubocop-performance --no-document
21
21
  - rubocop
22
22
 
23
23
  dependency_scanning:
@@ -1,3 +1,6 @@
1
+ require:
2
+ - rubocop-performance
3
+
1
4
  AllCops:
2
5
  TargetRubyVersion: 2.3
3
6
 
@@ -1,82 +1,94 @@
1
- # Change Log
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
2
3
 
3
- ## 1.5.4 (2018-11-14)
4
- ### Changes
5
- - updated _git-archive-all_ to 1.19.2
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 1.5.3 (2018-11-02)
8
- ### Changes
9
- - updated _git-archive-all_ to 1.19.1
7
+ ## [Unreleased]
10
8
 
11
- ## 1.5.2 (2018-10-07)
12
- ### Changes
13
- - updated _git-archive-all_ to 1.18.3
14
-
15
- ## 1.5.1 (2018-09-24)
16
- ### Changes
17
- - updated _git-archive-all_ to 1.18.2
18
-
19
- ## 1.5.0 (2018-05-24)
20
- ### Feature
21
- - add option to switch off running git clean (#25)
22
- ### Changes
23
- - updated _git-archive-all_ to 1.17.1
24
- - add support for .gitattributes and export-ignore (#23)
25
-
26
- ## 1.4.0 (2017-05-31)
27
- ### Feature
28
- - deploy subdirectory
29
-
30
- ## 1.3.2 (2017-04-30)
31
- ### Changes
32
- - updated _git-archive-all_ to 1.16.4
33
-
34
- ## 1.3.1 (2017-03-18)
9
+ ## [1.5.5] - 2019-06-19
10
+ ### Fixed
11
+ - usage with git versions >= 2.22.0
12
+ ### Changed
13
+ - updated _git-archive-all_ to 1.19.4
14
+
15
+ ## [1.5.4] - 2018-11-14
16
+ ### Changed
17
+ - updated _git-archive-all_ to 1.19.2
18
+
19
+ ## [1.5.3] - 2018-11-02
20
+ ### Changed
21
+ - updated _git-archive-all_ to 1.19.1
22
+
23
+ ## [1.5.2] - 2018-10-07
24
+ ### Changed
25
+ - updated _git-archive-all_ to 1.18.3
26
+
27
+ ## [1.5.1] - 2018-09-24
28
+ ### Changed
29
+ - updated _git-archive-all_ to 1.18.2
30
+
31
+ ## [1.5.0] - 2018-05-24
32
+ ### Added
33
+ - add option to switch off running git clean (#25)
34
+ ### Changed
35
+ - updated _git-archive-all_ to 1.17.1
36
+ - add support for .gitattributes and export-ignore (#23)
37
+
38
+ ## [1.4.0] - 2017-05-31
39
+ ### Added
40
+ - deploy subdirectory
41
+
42
+ ## [1.3.2] - 2017-04-30
43
+ ### Changed
44
+ - updated _git-archive-all_ to 1.16.4
45
+
46
+ ## [1.3.1] - 2017-03-18
35
47
  ### Fixed
36
- - missing require of tmpdir (see #22)
37
-
38
- ## 1.3.0 (2016-12-11)
39
- ### Changes
40
- - capistrano 3.7.x compatibility - see updated README.md
41
-
42
- ## 1.2.1 (2016-12-11)
43
- ### Changes
44
- - updated _git-archive-all_ to HEAD
45
- - require _capistrano_ < 3.7.0 due to breaking changes
46
-
47
- ## 1.2.0 (2016-01-25)
48
- ### Changes
49
- - Check if local repository mirror is working and reinitialize if necessary
50
- - Added config option `git_excludes` to exclude files and directories
51
- - updated _git-archive-all_ to v1.13
52
-
53
- ## 1.1.0 (2015-08-10)
54
- ### Changes
55
- - Deprecated: require 'capistrano/git/copy'
56
- - Allow to skip submodules (uses _git archive_ instead of _git-archive-all_)
48
+ - missing require of tmpdir (see #22)
49
+
50
+ ## [1.3.0] - 2016-12-11
51
+ ### Changed
52
+ - capistrano 3.7.x compatibility - see updated README.md
53
+
54
+ ## [1.2.1] - 2016-12-11
55
+ ### Changed
56
+ - updated _git-archive-all_ to HEAD
57
+ - require _capistrano_ < 3.7.0 due to breaking changes
58
+
59
+ ## [1.2.0] - 2016-01-25
60
+ ### Changed
61
+ - Check if local repository mirror is working and reinitialize if necessary
62
+ - Added config option `git_excludes` to exclude files and directories
63
+ - updated _git-archive-all_ to v1.13
64
+
65
+ ## [1.1.0] - 2015-08-10
66
+ ### Changed
67
+ - Deprecated: require 'capistrano/git/copy'
68
+ - Allow to skip submodules (uses _git archive_ instead of _git-archive-all_)
57
69
  ### Fixed
58
- - updated _git-archive-all_ to v1.11
59
- - prevent tasks from being executed multiple times
70
+ - updated _git-archive-all_ to v1.11
71
+ - prevent tasks from being executed multiple times
60
72
 
61
- ## 1.0.2 (2015-05-26)
73
+ ## [1.0.2] - 2015-05-26
62
74
  ### Fixed
63
- - use commit hash to fetch revision for log
75
+ - use commit hash to fetch revision for log
64
76
 
65
- ## 1.0.1 (2015-05-20)
77
+ ## [1.0.1] - 2015-05-20
66
78
  ### Fixed
67
- - fixed usage of frozen string as branch (e.g. if using ENV values)
68
- - use working copy of cloned repository to fetch revision
79
+ - fixed usage of frozen string as branch (e.g. if using ENV values)
80
+ - use working copy of cloned repository to fetch revision
69
81
 
70
- ## 1.0.0 (2015-04-22)
82
+ ## [1.0.0] - 2015-04-22
71
83
  ### Fixed
72
- - support application names with whitespaces and other non-path-friendly characters
73
- - executing deploy/scm task twice
84
+ - support application names with whitespaces and other non-path-friendly characters
85
+ - executing deploy/scm task twice
74
86
 
75
- ## 0.8.1 (2015-04-11)
87
+ ## [0.8.1] - 2015-04-11
76
88
  ### Fixed
77
- - strip branch name only if it is a string
89
+ - strip branch name only if it is a string
78
90
 
79
- ## 0.8.0 (2015-04-07)
80
- ### Changes
81
- - changed namespace from Capistrano::Git::Copy to Capistrano::GitCopy to avoid problems when using it in conjunction with build-in git support from capistrano
82
- - strip whitespaces from branch for checking revision
91
+ ## [0.8.0] - 2015-04-07
92
+ ### Changed
93
+ - changed namespace from Capistrano::Git::Copy to Capistrano::GitCopy to avoid problems when using it in conjunction with build-in git support from capistrano
94
+ - strip whitespaces from branch for checking revision
@@ -69,13 +69,13 @@ module Capistrano
69
69
  if fetch(:with_submodules)
70
70
  git(:submodule, :init)
71
71
  git(:submodule, :update)
72
- git(:submodule, :foreach, '--recursive', :git, :submodule, :update, '--init')
72
+ git(:submodule, :foreach, '--recursive', '"git submodule update --init"')
73
73
  end
74
74
 
75
75
  # cleanup
76
76
  git(:clean, '-d', '-f') if fetch(:with_clean)
77
77
 
78
- git(:submodule, :foreach, '--recursive', :git, :clean, '-d', '-f') if fetch(:with_submodules)
78
+ git(:submodule, :foreach, '--recursive', '"git clean -d -f"') if fetch(:with_submodules)
79
79
  end
80
80
 
81
81
  # Create tar archive
@@ -5,6 +5,6 @@ module Capistrano
5
5
  # GitCopy
6
6
  module GitCopy
7
7
  # gem version
8
- VERSION = '1.5.4'
8
+ VERSION = '1.5.5'
9
9
  end
10
10
  end
@@ -32,7 +32,7 @@ from subprocess import CalledProcessError, Popen, PIPE
32
32
  import sys
33
33
  import re
34
34
 
35
- __version__ = "1.19.2"
35
+ __version__ = "1.19.4"
36
36
 
37
37
 
38
38
  try:
@@ -76,7 +76,7 @@ class GitArchiver(object):
76
76
 
77
77
  LOG = logging.getLogger('GitArchiver')
78
78
 
79
- def __init__(self, prefix='', exclude=True, force_sub=False, extra=None, main_repo_abspath=None):
79
+ def __init__(self, prefix='', exclude=True, force_sub=False, extra=None, main_repo_abspath=None, git_version=None):
80
80
  """
81
81
  @param prefix: Prefix used to prepend all paths in the resulting archive.
82
82
  Extra file paths are only prefixed if they are not relative.
@@ -101,7 +101,17 @@ class GitArchiver(object):
101
101
  with abspath to top-level directory of the repository.
102
102
  If None, current cwd is used.
103
103
  @type main_repo_abspath: str
104
+
105
+ @param git_version: Version of Git that determines whether various workarounds are on.
106
+ If None, tries to resolve via Git's CLI.
107
+ @type git_version: tuple or None
104
108
  """
109
+ if git_version is None:
110
+ git_version = self.get_git_version()
111
+
112
+ if git_version is not None and git_version < (1, 6, 1):
113
+ raise ValueError("git of version 1.6.1 and higher is required")
114
+
105
115
  if extra is None:
106
116
  extra = []
107
117
 
@@ -120,6 +130,7 @@ class GitArchiver(object):
120
130
  self.extra = extra
121
131
  self.force_sub = force_sub
122
132
  self.main_repo_abspath = main_repo_abspath
133
+ self.git_version = git_version
123
134
 
124
135
  self._check_attr_gens = {}
125
136
 
@@ -298,47 +309,7 @@ class GitArchiver(object):
298
309
  self._check_attr_gens[repo_abspath].close()
299
310
  del self._check_attr_gens[repo_abspath]
300
311
 
301
- @classmethod
302
- def decode_git_output(cls, output):
303
- """
304
- Decode Git's binary output handeling the way it escapes unicode characters.
305
-
306
- @type output: bytes
307
-
308
- @rtype: str
309
- """
310
- return output.decode('unicode_escape').encode('raw_unicode_escape').decode('utf-8')
311
-
312
- @classmethod
313
- def run_git_shell(cls, cmd, cwd=None):
314
- """
315
- Runs git shell command, reads output and decodes it into unicode string.
316
-
317
- @param cmd: Command to be executed.
318
- @type cmd: str
319
-
320
- @type cwd: str
321
- @param cwd: Working directory.
322
-
323
- @rtype: str
324
- @return: Output of the command.
325
-
326
- @raise CalledProcessError: Raises exception if return code of the command is non-zero.
327
- """
328
- p = Popen(cmd, shell=True, stdout=PIPE, cwd=cwd)
329
- output, _ = p.communicate()
330
- output = cls.decode_git_output(output)
331
-
332
- if p.returncode:
333
- if sys.version_info > (2, 6):
334
- raise CalledProcessError(returncode=p.returncode, cmd=cmd, output=output)
335
- else:
336
- raise CalledProcessError(returncode=p.returncode, cmd=cmd)
337
-
338
- return output
339
-
340
- @classmethod
341
- def check_attr(cls, repo_abspath, attrs):
312
+ def check_attr(self, repo_abspath, attrs):
342
313
  """
343
314
  Generator that returns attributes for given paths relative to repo_abspath.
344
315
 
@@ -378,7 +349,7 @@ class GitArchiver(object):
378
349
  nuls_count += 1
379
350
 
380
351
  if nuls_count % 3 == 0:
381
- yield map(cls.decode_git_output, (path, attr, info))
352
+ yield map(self.decode_git_output, (path, attr, info))
382
353
  path, attr, info = b'', b'', b''
383
354
  elif nuls_count % 3 == 0:
384
355
  path += b
@@ -387,6 +358,38 @@ class GitArchiver(object):
387
358
  elif nuls_count % 3 == 2:
388
359
  info += b
389
360
 
361
+ def read_attrs_old(process, repo_file_path):
362
+ """
363
+ Compatibility with versions 1.8.5 and below that do not recognize -z for output.
364
+ """
365
+ process.stdin.write(repo_file_path.encode('utf-8') + b'\0')
366
+ process.stdin.flush()
367
+
368
+ # For every attribute check-attr will output: <path>: <attribute>: <info>\n
369
+ # where <path> is c-quoted
370
+
371
+ path, attr, info = b'', b'', b''
372
+ lines_count = 0
373
+ lines_expected = len(attrs)
374
+
375
+ while lines_count != lines_expected:
376
+ line = process.stdout.readline()
377
+
378
+ info_start = line.rfind(b': ')
379
+ if info_start == -1:
380
+ raise RuntimeError("unexpected output of check-attr: {0}".format(line))
381
+
382
+ attr_start = line.rfind(b': ', 0, info_start)
383
+ if attr_start == -1:
384
+ raise RuntimeError("unexpected output of check-attr: {0}".format(line))
385
+
386
+ info = line[info_start + 2:len(line) - 1] # trim leading ": " and trailing \n
387
+ attr = line[attr_start + 2:info_start] # trim leading ": "
388
+ path = line[:attr_start]
389
+
390
+ yield map(self.decode_git_output, (path, attr, info))
391
+ lines_count += 1
392
+
390
393
  if not attrs:
391
394
  return
392
395
 
@@ -397,7 +400,12 @@ class GitArchiver(object):
397
400
  repo_file_path = yield
398
401
  repo_file_attrs = {}
399
402
 
400
- for path, attr, value in read_attrs(process, repo_file_path):
403
+ if self.git_version is None or self.git_version > (1, 8, 5):
404
+ reader = read_attrs
405
+ else:
406
+ reader = read_attrs_old
407
+
408
+ for path, attr, value in reader(process, repo_file_path):
401
409
  repo_file_attrs[attr] = value
402
410
 
403
411
  yield repo_file_attrs
@@ -405,6 +413,72 @@ class GitArchiver(object):
405
413
  process.stdin.close()
406
414
  process.wait()
407
415
 
416
+ @classmethod
417
+ def decode_git_output(cls, output):
418
+ """
419
+ Decode Git's binary output handeling the way it escapes unicode characters.
420
+
421
+ @type output: bytes
422
+
423
+ @rtype: str
424
+ """
425
+ return output.decode('unicode_escape').encode('raw_unicode_escape').decode('utf-8')
426
+
427
+ @classmethod
428
+ def run_git_shell(cls, cmd, cwd=None):
429
+ """
430
+ Runs git shell command, reads output and decodes it into unicode string.
431
+
432
+ @param cmd: Command to be executed.
433
+ @type cmd: str
434
+
435
+ @type cwd: str
436
+ @param cwd: Working directory.
437
+
438
+ @rtype: str
439
+ @return: Output of the command.
440
+
441
+ @raise CalledProcessError: Raises exception if return code of the command is non-zero.
442
+ """
443
+ p = Popen(cmd, shell=True, stdout=PIPE, cwd=cwd)
444
+ output, _ = p.communicate()
445
+ output = cls.decode_git_output(output)
446
+
447
+ if p.returncode:
448
+ if sys.version_info > (2, 6):
449
+ raise CalledProcessError(returncode=p.returncode, cmd=cmd, output=output)
450
+ else:
451
+ raise CalledProcessError(returncode=p.returncode, cmd=cmd)
452
+
453
+ return output
454
+
455
+ @classmethod
456
+ def get_git_version(cls):
457
+ """
458
+ Return version of git current shell points to.
459
+
460
+ If version cannot be parsed None is returned.
461
+
462
+ @rtype: tuple or None
463
+ """
464
+ try:
465
+ output = cls.run_git_shell('git version')
466
+ except CalledProcessError:
467
+ cls.LOG.warning("Unable to get Git version.")
468
+ return None
469
+
470
+ try:
471
+ version = output.split()[2]
472
+ except IndexError:
473
+ cls.LOG.warning("Unable to parse Git version \"%s\".", output)
474
+ return None
475
+
476
+ try:
477
+ return tuple(int(v) for v in version.split('.'))
478
+ except ValueError:
479
+ cls.LOG.warning("Unable to parse Git version \"%s\".", version)
480
+ return None
481
+
408
482
 
409
483
  def main():
410
484
  from optparse import OptionParser, SUPPRESS_HELP
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.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.7.7
117
+ rubygems_version: 3.0.3
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: Copy local git repository deploy strategy for capistrano.