eac_git 0.21.0 → 0.22.1

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
  SHA256:
3
- metadata.gz: caa960785b3fe7f53bb968ad369475ff1bf385124b7809e5dddcceebc7619e71
4
- data.tar.gz: 486ac5819da4c8a41391b7e9808d3ba1d7948f5c1cc41b6434adba85ea243d3e
3
+ metadata.gz: bf4272006fb184bc833ba0a393c6f53bd54b9c0b8faf508dfc314aba47255217
4
+ data.tar.gz: ec4af90358dd5b79502db4054022f55cc38a68cb1e4262e56287351a9dac2ea7
5
5
  SHA512:
6
- metadata.gz: d42b82d4cbf4c0a5bdd4098b94802e544d5f2f41d20afb07aa07bd13be2993828e692ad1e2b6d970283d67175b9f8368f36f8c2796e4cb984ce0ef6eaf398111
7
- data.tar.gz: 5795595e09c93e181761bd8d1fbe0c099399278c4fe0d008592d1605463c3a259f0a5b4d964d92b34555204df7e2bd6bb14fd1aa37ee750ec526b6c3b681ff96
6
+ metadata.gz: c99d1ecba28badb204831466c23cb214adf38537c2373c364a9ed53e2647ded18149dda118e07bcf191f2e0c2ea744f4e629d8c538934af2ea4fa02e3675fe6b
7
+ data.tar.gz: 26b2e4ee6b2e449cc3ace713685af90b3202bf2031adaf7d00c9fc5060e5a9b52e62b90ae7c82eadb41b8296ba982cb18fc11efbd795077abd313f1c0c821b7e
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacGit
4
+ module Executables
5
+ module GitCommandExtensions
6
+ def command(*args)
7
+ super.envvar('PATH', path_with_git_subrepo)
8
+ end
9
+
10
+ def gem_root
11
+ '../..'.to_pathname.expand_path(__dir__)
12
+ end
13
+
14
+ def git_subrepo_root
15
+ gem_root.join('vendor', 'git-subrepo')
16
+ end
17
+
18
+ def path_with_git_subrepo
19
+ ([git_subrepo_root.join('lib').to_path] +
20
+ ENV['PATH'].if_present('').split(::File::PATH_SEPARATOR))
21
+ .join(::File::PATH_SEPARATOR)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,43 +3,21 @@
3
3
  module EacGit
4
4
  module Executables
5
5
  class << self
6
- include ::EacRubyUtils::SimpleCache
6
+ enable_memoized
7
7
 
8
8
  def env
9
9
  ::EacRubyUtils::Envs.local
10
10
  end
11
11
 
12
- private
13
-
14
- def git_uncached
12
+ memoize def git
15
13
  r = env.executable('git', '--version')
16
- r.extend(GitCommandExtensions)
14
+ r.extend(::EacGit::Executables::GitCommandExtensions)
17
15
  r
18
16
  end
19
17
 
20
- def tar_uncached
18
+ memoize def tar
21
19
  env.executable('tar', '--version')
22
20
  end
23
-
24
- module GitCommandExtensions
25
- def command(*args)
26
- super.envvar('PATH', path_with_git_subrepo)
27
- end
28
-
29
- def gem_root
30
- '../..'.to_pathname.expand_path(__dir__)
31
- end
32
-
33
- def git_subrepo_root
34
- gem_root.join('vendor', 'git-subrepo')
35
- end
36
-
37
- def path_with_git_subrepo
38
- ([git_subrepo_root.join('lib').to_path] +
39
- ENV['PATH'].if_present('').split(::File::PATH_SEPARATOR))
40
- .join(::File::PATH_SEPARATOR)
41
- end
42
- end
43
21
  end
44
22
  end
45
23
  end
@@ -4,7 +4,7 @@ module EacGit
4
4
  class Local
5
5
  class Commit
6
6
  class ChangedFile
7
- enable_simple_cache
7
+ enable_memoized
8
8
 
9
9
  attr_reader :commit, :diff_tree
10
10
 
@@ -22,11 +22,11 @@ module EacGit
22
22
  "#{path}|#{status}"
23
23
  end
24
24
 
25
- def src_size_uncached
25
+ memoize def src_size
26
26
  size(src_sha1)
27
27
  end
28
28
 
29
- def dst_size_uncached
29
+ memoize def dst_size
30
30
  size(dst_sha1)
31
31
  end
32
32
 
@@ -4,7 +4,7 @@ module EacGit
4
4
  class Local
5
5
  class Commit
6
6
  require_sub __FILE__, include_modules: true
7
- enable_simple_cache
7
+ enable_memoized
8
8
  include ::Comparable
9
9
 
10
10
  FIELDS = {
@@ -31,13 +31,13 @@ module EacGit
31
31
  define_method(field) { format(format) }
32
32
  end
33
33
 
34
- def changed_files_uncached
34
+ memoize def changed_files
35
35
  diff_tree_execute.each_line.map do |line|
36
36
  ::EacGit::Local::Commit::ChangedFile.new(self, line)
37
37
  end
38
38
  end
39
39
 
40
- def changed_files_size_uncached
40
+ memoize def changed_files_size
41
41
  changed_files.inject(0) { |a, e| a + e.dst_size }
42
42
  end
43
43
 
@@ -5,7 +5,6 @@ module EacGit
5
5
  class Remote
6
6
  NO_SUCH_REMOTE_CODE = 512
7
7
 
8
- enable_simple_cache
9
8
  include ::EacGit::RemoteLike
10
9
 
11
10
  common_constructor :local, :name
@@ -5,10 +5,18 @@ module EacGit
5
5
  # A git-subrepo (https://github.com/ingydotnet/git-subrepo) in a [EacGit::Local].
6
6
  class Subrepo
7
7
  require_sub __FILE__
8
- enable_simple_cache
8
+ enable_memoized
9
+
10
+ class << self
11
+ # @param subpath [Pathname, String]
12
+ # @return [String]
13
+ def sanitize_subpath(subpath)
14
+ subpath.to_pathname.to_path.gsub(%r{/+$}, '').to_pathname
15
+ end
16
+ end
9
17
 
10
18
  common_constructor :local, :subpath do
11
- self.subpath = subpath.to_pathname
19
+ self.subpath = self.class.sanitize_subpath(subpath)
12
20
  local.raise_error "Config file \"#{config_absolute_path}\" not found" unless
13
21
  config_absolute_path.file?
14
22
  end
@@ -24,21 +32,19 @@ module EacGit
24
32
  config_absolute_path.write(config.to_content)
25
33
  end
26
34
 
27
- private
28
-
29
- def config_uncached
35
+ memoize def config
30
36
  ::EacGit::Subrepo::Configuration.from_file(config_absolute_path)
31
37
  end
32
38
 
33
- def config_absolute_path_uncached
39
+ memoize def config_absolute_path
34
40
  config_relative_path.expand_path(local.root_path)
35
41
  end
36
42
 
37
- def config_relative_path_uncached
43
+ memoize def config_relative_path
38
44
  subpath.join('.gitrepo')
39
45
  end
40
46
 
41
- def remote_uncached
47
+ memoize def remote
42
48
  ::EacGit::Remote.new(remote_uri)
43
49
  end
44
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.21.0'
4
+ VERSION = '0.22.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
@@ -63,6 +63,7 @@ extra_rdoc_files: []
63
63
  files:
64
64
  - lib/eac_git.rb
65
65
  - lib/eac_git/executables.rb
66
+ - lib/eac_git/executables/git_command_extensions.rb
66
67
  - lib/eac_git/local.rb
67
68
  - lib/eac_git/local/branch.rb
68
69
  - lib/eac_git/local/changed_file.rb