eac_git 0.10.0 → 0.12.1

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: 2ec311c88709310162dce2346aaeab5d0f806c34328f59acc2ea441078e67c31
4
- data.tar.gz: 32a078b92200395e6dd323b67b90d9d25819bc3eacb5da1da79121e14f69d415
3
+ metadata.gz: 74b934533947081e1c45fe9df4b42e0758722aee669f1bf5bd45325e3c5cfe44
4
+ data.tar.gz: 4cf3f4691f9fe8108fcebc63ba34bf85457dfab4cb56190ed3153f2a92640d89
5
5
  SHA512:
6
- metadata.gz: 4de5084aa3ec1a3c1ab79565d648fd69561a709fd7ab1be956d6850253275368d6a154b87ebbb3d8d888d1d91400a399f8fd9505aa107c2d3c22adad871154f7
7
- data.tar.gz: 94bff2c958c603be3c8a9f03fff9961e5065bd6d8ddc61921f2961aa35a45a2b09b0959ababbdd4ccc21bc442a471535948ca4503b258dcdfb808dd363574a67
6
+ metadata.gz: eed35716f990d17643d46afb8ddd174060da67063207b5eeecd008a5388cf8b9dd408b4f7b243cc758694c575a8bbf0f7ca5e6ceb16a5f9ba1ae162216531e5d
7
+ data.tar.gz: 13f589a6dacaf16bba3ac44eaaa4bb921ec2ac1117aaae0e71ad56aa27a7ba932476809a0753b15c3061d2f3e9337416cbba3d7526c2f8a128fe3460a27bec33
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ class Local
7
+ class Branch
8
+ REFS_PREFIX = 'refs/heads/'
9
+
10
+ common_constructor :local, :name
11
+
12
+ # @return [String]
13
+ def current_commit_id
14
+ local.rev_parse(full_ref_name, true)
15
+ end
16
+
17
+ # @return [Boolean]
18
+ def exist?
19
+ local.command('show-ref', '--quiet', full_ref_name).execute.fetch(:exit_code).zero?
20
+ end
21
+
22
+ def full_ref_name
23
+ "#{REFS_PREFIX}#{name}"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -13,6 +13,7 @@ module EacGit
13
13
  author_name: '%an', author_email: '%ae', author_date: '%ai',
14
14
  subject: '%s',
15
15
  author_all: '%an <%ae>, %ai',
16
+ commit_hash: '%H', abbreviated_commit_hash: '%h',
16
17
  commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
17
18
  commiter_all: '%cn <%ce>, %ci',
18
19
  raw_body: '%B'
@@ -19,8 +19,8 @@ module EacGit
19
19
  # @return [String, nil]
20
20
  def url
21
21
  local.command('remote', 'get-url', name)
22
- .execute!(exit_outputs: { NO_SUCH_REMOTE_CODE => nil })
23
- .if_present(nil, &:strip)
22
+ .execute!(exit_outputs: { NO_SUCH_REMOTE_CODE => nil })
23
+ .if_present(nil, &:strip)
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_git/local/remote'
5
+
6
+ module EacGit
7
+ class Local
8
+ module Remotes
9
+ def remote(name)
10
+ ::EacGit::Local::Remote.new(self, name)
11
+ end
12
+
13
+ def remotes
14
+ command('remote').execute!.each_line.map(&:strip).reject(&:blank?).map do |name|
15
+ remote(name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/eac_git/local.rb CHANGED
@@ -30,6 +30,14 @@ module EacGit
30
30
  root_path <=> other.root_path
31
31
  end
32
32
 
33
+ # Retrieves a local branch.
34
+ #
35
+ # @param name [String] Ex.: for "refs/heads/master", name should be "master".
36
+ # @return [EacGit::Local::Branch]
37
+ def branch(name)
38
+ ::EacGit::Local::Branch.new(self, name)
39
+ end
40
+
33
41
  def commit(ref, required = false)
34
42
  rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
35
43
  end
@@ -44,6 +52,16 @@ module EacGit
44
52
  source.to_s.strip.if_present(nil) { |v| ::EacGit::Local::Commit.new(self, v) }
45
53
  end
46
54
 
55
+ # Retrieves the current local branch.
56
+ #
57
+ # @return [EacGit::Local::Branch, nil]
58
+ def current_branch
59
+ command('symbolic-ref', '--quiet', HEAD_REFERENCE)
60
+ .execute!(exit_outputs: { 256 => '' })
61
+ .gsub(%r{\Arefs/heads/}, '').strip
62
+ .if_present { |v| branch(v) }
63
+ end
64
+
47
65
  def descendant?(descendant, ancestor)
48
66
  base = merge_base(descendant, ancestor)
49
67
  return false if base.blank?
@@ -92,7 +110,7 @@ module EacGit
92
110
  # @return [Array<EacGit::Local::Subrepo>]
93
111
  def subrepos
94
112
  command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip).select(&:present?)
95
- .map { |subpath| subrepo(subpath) }
113
+ .map { |subpath| subrepo(subpath) }
96
114
  end
97
115
 
98
116
  def to_s
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.10.0'
4
+ VERSION = '0.12.1'
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.10.0
4
+ version: 0.12.1
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: 2021-11-26 00:00:00.000000000 Z
11
+ date: 2022-06-04 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.74'
19
+ version: '0.83'
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.74'
26
+ version: '0.83'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parseconfig
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,20 +70,14 @@ dependencies:
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '0.3'
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 0.3.2
73
+ version: 0.5.1
77
74
  type: :development
78
75
  prerelease: false
79
76
  version_requirements: !ruby/object:Gem::Requirement
80
77
  requirements:
81
78
  - - "~>"
82
79
  - !ruby/object:Gem::Version
83
- version: '0.3'
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 0.3.2
80
+ version: 0.5.1
87
81
  description:
88
82
  email:
89
83
  executables: []
@@ -93,6 +87,7 @@ files:
93
87
  - lib/eac_git.rb
94
88
  - lib/eac_git/executables.rb
95
89
  - lib/eac_git/local.rb
90
+ - lib/eac_git/local/branch.rb
96
91
  - lib/eac_git/local/commit.rb
97
92
  - lib/eac_git/local/commit/archive.rb
98
93
  - lib/eac_git/local/commit/changed_file.rb
@@ -100,6 +95,7 @@ files:
100
95
  - lib/eac_git/local/dirty_files.rb
101
96
  - lib/eac_git/local/log.rb
102
97
  - lib/eac_git/local/remote.rb
98
+ - lib/eac_git/local/remotes.rb
103
99
  - lib/eac_git/local/subrepo.rb
104
100
  - lib/eac_git/local/subrepo/config.rb
105
101
  - lib/eac_git/remote.rb