eac_git 0.14.0 → 0.15.0

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: ab3d903a17794bf31cdfbacd18d66c6927f3877ce2214d3999ab7b895a5519b0
4
- data.tar.gz: 595bb8279d843f7ba6f46cda285fd5144ac3740a82557c8baf2789ea9b19674b
3
+ metadata.gz: 3fe4d94f7db9bca8bb4b528a63f88d5468814df46f29964ba93583f8f250356b
4
+ data.tar.gz: a546176555f4ecc7b3a0ddac7d13ad6d69346158c3a834c4d8c255955de1a0a8
5
5
  SHA512:
6
- metadata.gz: 29af9d3a7b4dd4d54b7e8dfba7dcf9f72411beb69291f83b29066194a632ebdbaaa1c73d32724e0476eca18e43a1e137abbce1e8e10256d13f7e57c1a0277ebd
7
- data.tar.gz: cbeb8f4124a92407bb30bedf91acc77553b86859c6315e9e10eba72994e0f867e17764d79e2f3b0831dfbbada0e29d61c4d3a3ea43102fcf204c601bf34d2300
6
+ metadata.gz: a2d29cfc5cc2bae11893f7abab005d796e309ff3572e4d44d708c0d45f71214deae8b256eb480b5c96c283d395d9c402f6614f2e83b6a42d4fd119b7aeaa6d7d
7
+ data.tar.gz: 6d30cbad563fe641196afefb77602b96de464c736eea5cb295c8209e5fdc106f98bb594ac51be06ad971cfd51ec94b23da28ba3cbdd3b0e6730f07dad2df0a96
@@ -20,7 +20,7 @@ module EacGit
20
20
  end
21
21
 
22
22
  def fields
23
- FIELDS.map { |field| [field, send(field)] }.to_h
23
+ FIELDS.index_with { |field| send(field) }
24
24
  end
25
25
 
26
26
  private
@@ -6,6 +6,7 @@ require 'ostruct'
6
6
  module EacGit
7
7
  class Local
8
8
  module DirtyFiles
9
+ QUOTED_PATH_PATTERN = /\A"(.+)"\z/.freeze
9
10
  STATUS_LINE_PATTERN = /\A(.)(.)\s(.+)\z/.freeze
10
11
 
11
12
  def dirty?
@@ -26,12 +27,22 @@ module EacGit
26
27
 
27
28
  private
28
29
 
30
+ # @param line [String]
31
+ # @return [Struct]
29
32
  def parse_status_line(line)
30
33
  STATUS_LINE_PATTERN.if_match(line) do |m|
31
- ::OpenStruct.new(index: m[1], worktree: m[2], path: m[3].to_pathname,
32
- absolute_path: m[3].to_pathname.expand_path(root_path))
34
+ path = parse_status_line_path(m[3]).to_pathname
35
+ { index: m[1], worktree: m[2], path: path, absolute_path: path.expand_path(root_path) }
36
+ .to_struct
33
37
  end
34
38
  end
39
+
40
+ # @param path [String]
41
+ # @return [String]
42
+ def parse_status_line_path(path)
43
+ m = QUOTED_PATH_PATTERN.match(path)
44
+ m ? m[1] : path
45
+ end
35
46
  end
36
47
  end
37
48
  end
@@ -6,7 +6,7 @@ require 'eac_ruby_utils/core_ext'
6
6
  module EacGit
7
7
  class Local
8
8
  class Remote
9
- NO_SUCH_REMOTE_CODE = 128
9
+ NO_SUCH_REMOTE_CODE = 512
10
10
 
11
11
  enable_simple_cache
12
12
  include ::EacGit::RemoteLike
@@ -11,7 +11,7 @@ module EacGit
11
11
  end
12
12
 
13
13
  def remotes
14
- command('remote').execute!.each_line.map(&:strip).reject(&:blank?).map do |name|
14
+ command('remote').execute!.each_line.map(&:strip).compact_blank.map do |name|
15
15
  remote(name)
16
16
  end
17
17
  end
@@ -24,7 +24,7 @@ module EacGit
24
24
  self.values = values.with_indifferent_access
25
25
  end
26
26
 
27
- MAPPING.each do |method_name, _config_key|
27
+ MAPPING.each_key do |method_name|
28
28
  define_method(method_name) do
29
29
  values[MAPPING.fetch(method_name)]
30
30
  end
@@ -35,7 +35,7 @@ module EacGit
35
35
  end
36
36
 
37
37
  def to_content
38
- "[subrepo]\n" + MAPPING.map { |k, v| " #{v} = #{send(k)}\n" }.join
38
+ "[subrepo]\n" + MAPPING.map { |k, v| " #{v} = #{send(k)}\n" }.join # rubocop:disable Style/StringConcatenation
39
39
  end
40
40
  end
41
41
  end
data/lib/eac_git/local.rb CHANGED
@@ -38,7 +38,7 @@ module EacGit
38
38
  ::EacGit::Local::Branch.new(self, name)
39
39
  end
40
40
 
41
- def commit(ref, required = false)
41
+ def commit(ref, required = false) # rubocop:disable Style/OptionalBooleanParameter
42
42
  rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
43
43
  end
44
44
 
@@ -71,7 +71,7 @@ module EacGit
71
71
  end
72
72
 
73
73
  # @return [EacGit::Local::Commit
74
- def head(required = true)
74
+ def head(required = true) # rubocop:disable Style/OptionalBooleanParameter
75
75
  commit(HEAD_REFERENCE, required)
76
76
  end
77
77
 
@@ -94,7 +94,7 @@ module EacGit
94
94
  raise "#{root_path}: #{message}"
95
95
  end
96
96
 
97
- def rev_parse(ref, required = false)
97
+ def rev_parse(ref, required = false) # rubocop:disable Style/OptionalBooleanParameter
98
98
  r = command('rev-parse', ref).execute!(exit_outputs: { 128 => nil, 32_768 => nil })
99
99
  r.strip! if r.is_a?(String)
100
100
  return r if r.present?
@@ -12,8 +12,8 @@ module EacGit
12
12
  common_constructor :uri
13
13
 
14
14
  # @return [EacRubyUtils::Envs::Command
15
- def git_command(*args, &block)
16
- ::EacGit::Executables.git.command(*args, &block)
15
+ def git_command(...)
16
+ ::EacGit::Executables.git.command(...)
17
17
  end
18
18
 
19
19
  # @return [String]
@@ -8,13 +8,13 @@ module EacGit
8
8
  class << self
9
9
  def by_ls_remote_command_output(output)
10
10
  new(
11
- output.each_line.map { |line| line.strip.split(/\s+/) }.map { |x| [x[1], x[0]] }.to_h
11
+ output.each_line.map { |line| line.strip.split(/\s+/) }.to_h { |x| [x[1], x[0]] } # rubocop:disable Style/MapToHash
12
12
  )
13
13
  end
14
14
  end
15
15
 
16
16
  common_constructor :hashes
17
- delegate :fetch, :'[]', :count, :any?, :empty?, to: :hashes
17
+ delegate :fetch, :[], :count, :any?, :empty?, to: :hashes
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/rspec/stubbed_git_local_repo/fs_object'
4
+ require 'fileutils'
5
+
6
+ module EacGit
7
+ module Rspec
8
+ module StubbedGitLocalRepo
9
+ class Directory < ::EacGit::Rspec::StubbedGitLocalRepo::FsObject
10
+ # @return [self]
11
+ def create
12
+ ::FileUtils.mkdir_p(path)
13
+ self
14
+ end
15
+
16
+ # @return [self]
17
+ def delete
18
+ ::FileUtils.rm_rf(path)
19
+ self
20
+ end
21
+
22
+ # @param subpath [Array<String>]
23
+ # @return [EacGit::Rspec::StubbedGitLocalRepo::Directory]
24
+ def directory(*subpath)
25
+ git.directory(*self.subpath, *subpath)
26
+ end
27
+
28
+ # @param subpath [Array<String>]
29
+ # @return [EacGit::Rspec::StubbedGitLocalRepo::File]
30
+ def file(*subpath)
31
+ git.file(*self.subpath, *subpath)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/rspec/stubbed_git_local_repo/fs_object'
4
+ require 'fileutils'
5
+
6
+ module EacGit
7
+ module Rspec
8
+ module StubbedGitLocalRepo
9
+ class File < ::EacGit::Rspec::StubbedGitLocalRepo::FsObject
10
+ def touch
11
+ ::FileUtils.touch(path.to_path)
12
+ end
13
+
14
+ def delete
15
+ path.unlink
16
+ end
17
+
18
+ delegate :write, to: :path
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ module Rspec
7
+ module StubbedGitLocalRepo
8
+ class FsObject
9
+ # @!attribute [r] git
10
+ # @param git [EacGit::Rspec::StubbedGitLocalRepo::Repository]
11
+
12
+ # @!attribute [r] subpath
13
+ # @param git [Array<String>]
14
+
15
+ # @!method initialize(git, subpath)
16
+ # @param git [EacGit::Rspec::StubbedGitLocalRepo::Repository]
17
+ # @param subpath [Array<String>
18
+ common_constructor :git, :subpath
19
+
20
+ # @return [Pathname]
21
+ def path
22
+ git.root_path.join(*subpath)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/local'
4
+ require 'eac_git/rspec/stubbed_git_local_repo/directory'
5
+ require 'eac_git/rspec/stubbed_git_local_repo/file'
6
+ require 'eac_ruby_utils/core_ext'
7
+ require 'securerandom'
8
+
9
+ module EacGit
10
+ module Rspec
11
+ module StubbedGitLocalRepo
12
+ class Repository < ::EacGit::Local
13
+ # @return [EacGit::Rspec::StubbedGitLocalRepo::Directory]
14
+ def directory(*subpath)
15
+ ::EacGit::Rspec::StubbedGitLocalRepo::Directory.new(self, subpath)
16
+ end
17
+
18
+ def file(*subpath)
19
+ ::EacGit::Rspec::StubbedGitLocalRepo::File.new(self, subpath)
20
+ end
21
+
22
+ # @return [EacGit::Local::Commit
23
+ def random_commit
24
+ content = ::SecureRandom.hex
25
+ file = "#{content}.txt"
26
+ file(file).write(content)
27
+ command('add', file).execute!
28
+ command('commit', '-m', "Random commit: #{file}.").execute!
29
+ head
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,18 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_git/local'
4
3
  require 'eac_ruby_utils/envs'
5
- require 'fileutils'
6
- require 'securerandom'
7
4
  require 'tmpdir'
8
5
 
9
6
  module EacGit
10
7
  module Rspec
11
8
  module StubbedGitLocalRepo
12
- def stubbed_git_local_repo(bare = false)
9
+ def stubbed_git_local_repo(bare = false) # rubocop:disable Style/OptionalBooleanParameter
13
10
  path = ::Dir.mktmpdir
14
11
  ::EacRubyUtils::Envs.local.command(stubbed_git_local_repo_args(path, bare)).execute!
15
- repo = StubbedGitRepository.new(path)
12
+ repo = ::EacGit::Rspec::StubbedGitLocalRepo::Repository.new(path)
16
13
  repo.command('config', 'user.email', 'theuser@example.net').execute!
17
14
  repo.command('config', 'user.name', 'The User').execute!
18
15
  repo
@@ -26,46 +23,7 @@ module EacGit
26
23
  r + [path]
27
24
  end
28
25
 
29
- class StubbedGitRepository < ::EacGit::Local
30
- def file(*subpath)
31
- StubbedGitRepositoryFile.new(self, subpath)
32
- end
33
-
34
- # @return [EacGit::Local::Commit
35
- def random_commit
36
- content = ::SecureRandom.hex
37
- file = "#{content}.txt"
38
- file(file).write(content)
39
- command('add', file).execute!
40
- command('commit', '-m', "Random commit: #{file}.").execute!
41
- head
42
- end
43
- end
44
-
45
- class StubbedGitRepositoryFile
46
- attr_reader :git, :subpath
47
-
48
- def initialize(git, subpath)
49
- @git = git
50
- @subpath = subpath
51
- end
52
-
53
- def path
54
- git.root_path.join(*subpath)
55
- end
56
-
57
- def touch
58
- ::FileUtils.touch(path.to_path)
59
- end
60
-
61
- def delete
62
- path.unlink
63
- end
64
-
65
- def write(content)
66
- path.write(content)
67
- end
68
- end
26
+ require_sub __FILE__
69
27
  end
70
28
  end
71
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-09 00:00:00.000000000 Z
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.107'
19
+ version: '0.120'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.107'
26
+ version: '0.120'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parseconfig
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,40 +44,20 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.1.2
47
- - !ruby/object:Gem::Dependency
48
- name: aranha-parsers
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '0.8'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.8.2
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '0.8'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.8.2
67
47
  - !ruby/object:Gem::Dependency
68
48
  name: eac_ruby_gem_support
69
49
  requirement: !ruby/object:Gem::Requirement
70
50
  requirements:
71
51
  - - "~>"
72
52
  - !ruby/object:Gem::Version
73
- version: 0.5.1
53
+ version: '0.9'
74
54
  type: :development
75
55
  prerelease: false
76
56
  version_requirements: !ruby/object:Gem::Requirement
77
57
  requirements:
78
58
  - - "~>"
79
59
  - !ruby/object:Gem::Version
80
- version: 0.5.1
60
+ version: '0.9'
81
61
  description:
82
62
  email:
83
63
  executables: []
@@ -104,6 +84,10 @@ files:
104
84
  - lib/eac_git/rspec.rb
105
85
  - lib/eac_git/rspec/setup.rb
106
86
  - lib/eac_git/rspec/stubbed_git_local_repo.rb
87
+ - lib/eac_git/rspec/stubbed_git_local_repo/directory.rb
88
+ - lib/eac_git/rspec/stubbed_git_local_repo/file.rb
89
+ - lib/eac_git/rspec/stubbed_git_local_repo/fs_object.rb
90
+ - lib/eac_git/rspec/stubbed_git_local_repo/repository.rb
107
91
  - lib/eac_git/version.rb
108
92
  - vendor/git-subrepo/Changes
109
93
  - vendor/git-subrepo/Intro.pod
@@ -301,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
301
285
  requirements:
302
286
  - - ">="
303
287
  - !ruby/object:Gem::Version
304
- version: '0'
288
+ version: '2.7'
305
289
  required_rubygems_version: !ruby/object:Gem::Requirement
306
290
  requirements:
307
291
  - - ">="