dapp 0.21.2 → 0.21.3

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: 6688aeaeb3fbb8ac79e79ebfb3a962fac517c837502baf782f63ba6ad0f66422
4
- data.tar.gz: 51c4ec39d9f8a76d28e86d8c1b5c58003b62cb695759a8d2ea8fe059947bc5f0
3
+ metadata.gz: caa68d93baa4f34fd39023d92e84e77f87d71cc0218b6198b2527f7462244f12
4
+ data.tar.gz: 20b6b7ad98b9766e75a063359b0b138c3d118b84e3b548f2a204caea772df87e
5
5
  SHA512:
6
- metadata.gz: d9a403972969a94073332d428d83d641bceb4e5b0c23b036dc28db0b7bcd65e11e7337e97a0dad7598b72e063eba32c2adf1396d1bc644e523f82996750fe77d
7
- data.tar.gz: 0c17e98a0a94b63999cf00d620b60472f45064f7f8ca98c6f61a2a0206059df98e97a22842d15ed3d1007cbf5cdd5c6e04b758ffd55f78d384a3cf4adf382ab4
6
+ metadata.gz: cea36eaca547f72db729ea8e68917d70dc9badc3fd029bf026eaa88855fabf120f22912e2905e798e558aba4d6ad35b964bcf0e9b4e3dce0fbadd49002d7a10f
7
+ data.tar.gz: 68ba6167d3753d9a30e9792eaf9959ae18d3e2200683bbe72d00fcaa1e11f5b0a75c982c9e4db4898e88361341b424581e6d1fa320f2faaeb837ddfd3fd07f8b
@@ -7,7 +7,10 @@ module Dapp
7
7
 
8
8
  def initialize(url, **kwargs, &blk)
9
9
  @_url = url
10
- @_name = url.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
10
+
11
+ url_without_scheme = url.split("://", 2).last
12
+ url_without_creds = url_without_scheme.split(":", 2).last
13
+ @_name = url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
11
14
 
12
15
  super(**kwargs, &blk)
13
16
  end
@@ -9,19 +9,25 @@ module Dapp
9
9
 
10
10
  @url = url
11
11
 
12
- dapp.log_secondary_process(dapp.t(code: 'process.git_artifact_clone', data: { url: url }), short: true) do
13
- begin
14
- if [:https, :ssh].include?(protocol) && !Rugged.features.include?(protocol)
15
- raise Error::Rugged, code: :rugged_protocol_not_supported, data: { url: url, protocol: protocol }
16
- end
12
+ _with_lock do
13
+ dapp.log_secondary_process(dapp.t(code: 'process.git_artifact_clone', data: { url: url }), short: true) do
14
+ begin
15
+ if [:https, :ssh].include?(protocol) && !Rugged.features.include?(protocol)
16
+ raise Error::Rugged, code: :rugged_protocol_not_supported, data: { url: url, protocol: protocol }
17
+ end
17
18
 
18
- Rugged::Repository.clone_at(url, path.to_s, bare: true, credentials: _rugged_credentials)
19
- rescue Rugged::NetworkError, Rugged::SslError, Rugged::OSError => e
20
- raise Error::Rugged, code: :rugged_remote_error, data: { message: e.message, url: url }
19
+ Rugged::Repository.clone_at(url, path.to_s, bare: true, credentials: _rugged_credentials)
20
+ rescue Rugged::NetworkError, Rugged::SslError, Rugged::OSError => e
21
+ raise Error::Rugged, code: :rugged_remote_error, data: { message: e.message, url: url }
22
+ end
21
23
  end
22
24
  end unless path.directory?
23
25
  end
24
26
 
27
+ def _with_lock(&blk)
28
+ dapp.lock("remote_git_artifact.#{name}", default_timeout: 120, &blk)
29
+ end
30
+
25
31
  def _rugged_credentials
26
32
  @_rugged_credentials ||= begin
27
33
  if protocol == :ssh
@@ -33,14 +39,27 @@ module Dapp
33
39
  end
34
40
 
35
41
  def path
36
- Pathname(dimg.build_path('git_repo_remote', name, Digest::MD5.hexdigest(url)).to_s)
42
+ Pathname(dimg.build_path('git_repo_remote', name).to_s)
37
43
  end
38
44
 
39
45
  def fetch!(branch = nil)
40
- branch ||= self.branch
41
- dapp.log_secondary_process(dapp.t(code: 'process.git_artifact_fetch', data: { url: url }), short: true) do
42
- git.fetch('origin', [branch], credentials: _rugged_credentials)
43
- raise Error::Rugged, code: :branch_not_exist_in_remote_git_repository, data: { branch: branch, url: url } unless branch_exist?(branch)
46
+ _with_lock do
47
+ branch ||= self.branch
48
+
49
+ cfg_path = path.join("config")
50
+ cfg = IniFile.load(cfg_path)
51
+ remote_origin_cfg = cfg['remote "origin"']
52
+
53
+ old_url = remote_origin_cfg["url"]
54
+ if old_url and old_url != url
55
+ remote_origin_cfg["url"] = url
56
+ cfg.write(filename: cfg_path)
57
+ end
58
+
59
+ dapp.log_secondary_process(dapp.t(code: 'process.git_artifact_fetch', data: { url: url }), short: true) do
60
+ git.fetch('origin', [branch], credentials: _rugged_credentials)
61
+ raise Error::Rugged, code: :branch_not_exist_in_remote_git_repository, data: { branch: branch, url: url } unless branch_exist?(branch)
62
+ end
44
63
  end unless dimg.ignore_git_fetch || dapp.dry_run?
45
64
  end
46
65
 
@@ -12,6 +12,12 @@ BANNER
12
12
  long: '--namespace NAME',
13
13
  default: nil
14
14
 
15
+ option :image_version,
16
+ long: '--image-version TAG',
17
+ description: "Custom tag (alias for --tag)",
18
+ default: [],
19
+ proc: proc { |v| composite_options(:image_versions) << v }
20
+
15
21
  option :tag,
16
22
  long: '--tag TAG',
17
23
  description: 'Custom tag',
@@ -66,7 +72,10 @@ BANNER
66
72
  def run(argv = ARGV)
67
73
  self.class.parse_options(self, argv)
68
74
 
69
- run_dapp_command(nil, options: cli_options) do |dapp|
75
+ options = cli_options
76
+ options[:tag] = [*options.delete(:tag), *options.delete(:image_version)]
77
+
78
+ run_dapp_command(nil, options: options) do |dapp|
70
79
  repo = if not cli_arguments[0].nil?
71
80
  self.class.required_argument(self, 'repo')
72
81
  else
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.21.2'.freeze
2
+ VERSION = '0.21.3'.freeze
3
3
  BUILD_CACHE_VERSION = 23
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.2
4
+ version: 0.21.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout