dapp 0.10.2 → 0.10.3

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: c1c1c851ed5f27bd25dd4b3cf8bc1b27431fe81c
4
- data.tar.gz: 32d35c1a530a102622ad85129d74d790a5711e4b
3
+ metadata.gz: aec1102e5d09b9d7a2ff35bb28197754f04542ed
4
+ data.tar.gz: d109455833c5662a9acc3fb68cdc0486b90b393c
5
5
  SHA512:
6
- metadata.gz: 1ed7f72ee220ac672365bd00b5a1bc2b62ea10132816439b627c5df61a1297f66b7e008410bcf5f23257ee5e6e845a9c54f0361c79607c5c99faea352ba0c523
7
- data.tar.gz: 495cf5dc364223895564aa19c99a6590cfe58a44f0a6c492c04aabd35c8111601cc49ac8a7ef8a20f27c96d519227706f57e4796dd701c9d33d40761ae4b5fee
6
+ metadata.gz: ae41e33d7e21d2fde9d8958005b7ec2e92c4e7a3aa73066d2c95721749fdf312fcdddb60d1efa5cb7778f593e59829f9694b9eef2022fa176867c3403fedffda
7
+ data.tar.gz: 8033a3e5a29f7e323c0ea59511645f96f7a4075d38a257c721c1c6e91f7897e342c5ceb3bd9acf276293d72486c1625cebf9df1106f7ea2910b6382a372bb7c6
@@ -64,7 +64,6 @@ require 'dapp/dimg/builder/shell'
64
64
  require 'dapp/dimg/builder/none'
65
65
  require 'dapp/dimg/build/stage/mod/logging'
66
66
  require 'dapp/dimg/build/stage/mod/group'
67
- require 'dapp/dimg/build/stage/mod/git_artifact_dependencies'
68
67
  require 'dapp/dimg/build/stage/base'
69
68
  require 'dapp/dimg/build/stage/ga_base'
70
69
  require 'dapp/dimg/build/stage/ga_dependencies_base'
@@ -168,7 +168,7 @@ module Dapp
168
168
  end
169
169
 
170
170
  def default_git_artifacts_dependencies(git_artifacts)
171
- git_artifacts.map { |git_artifact| git_artifact.stage_dependencies_checksums(self) }
171
+ git_artifacts.map { |git_artifact| git_artifact.stage_dependencies_checksum(self) }
172
172
  end
173
173
 
174
174
  def dependencies
@@ -3,8 +3,6 @@ module Dapp
3
3
  module Build
4
4
  module Stage
5
5
  class BeforeSetup < Base
6
- include Mod::GitArtifactsDependencies
7
-
8
6
  def initialize(dimg, next_stage)
9
7
  @prev_stage = AfterInstallArtifact.new(dimg, self)
10
8
  super
@@ -3,8 +3,6 @@ module Dapp
3
3
  module Build
4
4
  module Stage
5
5
  class BuildArtifact < Base
6
- include Mod::GitArtifactsDependencies
7
-
8
6
  def initialize(dimg)
9
7
  @prev_stage = GAArtifactPatch.new(dimg, self)
10
8
  @dimg = dimg
@@ -5,7 +5,6 @@ module Dapp
5
5
  module Install
6
6
  class Install < Base
7
7
  include Mod::Group
8
- include Mod::GitArtifactsDependencies
9
8
 
10
9
  def initialize(dimg, next_stage)
11
10
  @prev_stage = GAPreInstallPatch.new(dimg, self)
@@ -5,7 +5,6 @@ module Dapp
5
5
  module Setup
6
6
  class Setup < Base
7
7
  include Mod::Group
8
- include Mod::GitArtifactsDependencies
9
8
 
10
9
  def initialize(dimg, next_stage)
11
10
  @prev_stage = GAPreSetupPatch.new(dimg, self)
@@ -52,15 +52,27 @@ module Dapp
52
52
  patch_command(stage.prev_g_a_stage.layer_commit(self), nil)
53
53
  end
54
54
 
55
- def stage_dependencies_checksums(stage, from_commit = nil, to_commit = latest_commit)
55
+ def stage_dependencies_checksum(stage)
56
56
  return [] if (stage_dependencies = stages_dependencies[stage.name]).empty?
57
57
 
58
- paths = include_paths(true) + base_paths(stage_dependencies, true)
59
- diff_patches(from_commit, to_commit, paths: paths).map do |patch|
60
- delta_new_file = patch.delta.new_file
61
- content = patch.hunks.map { |h| h.lines.select { |l| l.line_origin == :context }.map(&:content).join }.join
62
- Digest::SHA256.hexdigest [delta_new_file[:path], content].join(':::')
58
+ paths = (include_paths(true) + base_paths(stage_dependencies, true)).uniq
59
+
60
+ to_commit = if repo.is_a? GitRepo::Own and repo.dimg.dev_mode?
61
+ nil
62
+ else
63
+ latest_commit
63
64
  end
65
+
66
+ diff_patches(nil, to_commit, paths: paths)
67
+ .sort_by {|patch| patch.delta.new_file[:path]}
68
+ .reduce(nil) {|prev_hash, patch|
69
+ Digest::SHA256.hexdigest [
70
+ prev_hash,
71
+ patch.delta.new_file[:path],
72
+ patch.delta.new_file[:mode].to_s,
73
+ patch.to_s
74
+ ].compact.join(':::')
75
+ }
64
76
  end
65
77
 
66
78
  def patch_size(from, to)
@@ -85,7 +97,7 @@ module Dapp
85
97
  end
86
98
 
87
99
  def latest_commit
88
- @latest_commit ||= commit || repo.latest_commit(branch)
100
+ @latest_commit ||= (commit || repo.latest_commit(branch))
89
101
  end
90
102
 
91
103
  def paramshash
@@ -213,10 +225,10 @@ module Dapp
213
225
  end
214
226
 
215
227
  def diff_patches(from, to, paths: include_paths_or_cwd)
216
- (@diff_patches ||= {})[[from, to, paths]] = repo.patches(from, to,
217
- paths: paths,
218
- exclude_paths: exclude_paths(true),
219
- force_text: true)
228
+ (@diff_patches ||= {})[[from, to, paths]] ||= repo.patches(from, to,
229
+ paths: paths,
230
+ exclude_paths: exclude_paths(true),
231
+ force_text: true)
220
232
  end
221
233
 
222
234
  def include_paths_or_cwd
@@ -15,6 +15,16 @@ module Dapp
15
15
  []
16
16
  end
17
17
 
18
+ # FIXME: Убрать логику исключения путей exclude_paths из данного класса,
19
+ # FIXME: т.к. большинство методов не поддерживают инвариант
20
+ # FIXME "всегда выдавать данные с исключенными путями".
21
+ # FIXME: Например, метод diff выдает данные без учета exclude_paths.
22
+ # FIXME: Лучше перенести фильтрацию в GitArtifact::diff_patches.
23
+ # FIXME: ИЛИ обеспечить этот инвариант, но это ограничит в возможностях
24
+ # FIXME: использование Rugged извне этого класса и это более сложный путь.
25
+ # FIXME: Лучше сейчас убрать фильтрацию, а добавить ее когда наберется достаточно
26
+ # FIXME: примеров использования.
27
+
18
28
  def patches(from, to, exclude_paths: [], **kwargs)
19
29
  diff(from, to, **kwargs).patches.select do |patch|
20
30
  !exclude_paths.any? { |p| check_path?(patch.delta.new_file[:path], p) }
@@ -22,7 +32,9 @@ module Dapp
22
32
  end
23
33
 
24
34
  def diff(from, to, **kwargs)
25
- if from.nil?
35
+ if to.nil?
36
+ raise "Workdir diff not supported for #{self.class}"
37
+ elsif from.nil?
26
38
  Rugged::Tree.diff(git, nil, to, **kwargs)
27
39
  else
28
40
  lookup_commit(from).diff(lookup_commit(to), **kwargs)
@@ -16,8 +16,16 @@ module Dapp
16
16
  raise Error::Rugged, code: :local_git_repository_does_not_exist
17
17
  end
18
18
 
19
+ # NOTICE: Параметры {from: nil, to: nil} можно указать только для Own repo.
20
+ # NOTICE: Для Remote repo такой вызов не имеет смысла и это ошибка пользователя класса Remote.
21
+
19
22
  def diff(from, to, **kwargs)
20
- if to.nil?
23
+ if from.nil? and to.nil?
24
+ mid_commit = latest_commit
25
+ diff_obj = super(nil, mid_commit, **kwargs)
26
+ diff_obj.merge! git.lookup(mid_commit).diff_workdir(**kwargs)
27
+ diff_obj
28
+ elsif to.nil?
21
29
  git.lookup(from).diff_workdir(**kwargs)
22
30
  else
23
31
  super
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.10.2'.freeze
3
- BUILD_CACHE_VERSION = 7
2
+ VERSION = '0.10.3'.freeze
3
+ BUILD_CACHE_VERSION = 8
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.10.2
4
+ version: 0.10.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-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -449,7 +449,6 @@ files:
449
449
  - lib/dapp/dimg/build/stage/install/ga_pre_install_patch.rb
450
450
  - lib/dapp/dimg/build/stage/install/ga_pre_install_patch_dependencies.rb
451
451
  - lib/dapp/dimg/build/stage/install/install.rb
452
- - lib/dapp/dimg/build/stage/mod/git_artifact_dependencies.rb
453
452
  - lib/dapp/dimg/build/stage/mod/group.rb
454
453
  - lib/dapp/dimg/build/stage/mod/logging.rb
455
454
  - lib/dapp/dimg/build/stage/setup/ga_post_setup_patch.rb
@@ -1,23 +0,0 @@
1
- module Dapp
2
- module Dimg
3
- module Build
4
- module Stage
5
- module Mod
6
- module GitArtifactsDependencies
7
- def local_git_artifacts_dependencies
8
- dimg.local_git_artifacts.map do |git_artifact|
9
- args = []
10
- args << self
11
- if dimg.dev_mode?
12
- args << git_artifact.latest_commit
13
- args << nil
14
- end
15
- git_artifact.stage_dependencies_checksums(*args)
16
- end
17
- end
18
- end
19
- end # Mod
20
- end # Stage
21
- end # Build
22
- end # Dimg
23
- end # Dapp