eac_git 0.10.0 → 0.11.0

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: 2ec311c88709310162dce2346aaeab5d0f806c34328f59acc2ea441078e67c31
4
- data.tar.gz: 32a078b92200395e6dd323b67b90d9d25819bc3eacb5da1da79121e14f69d415
3
+ metadata.gz: 5583900c213a539c619f4d6e7fca1ee9ad8d0c2188549097e572e2c69160aa63
4
+ data.tar.gz: 9de7fa274c112090871bcc160d54bf3cc3b9730f8bc603852044d1d20145c8da
5
5
  SHA512:
6
- metadata.gz: 4de5084aa3ec1a3c1ab79565d648fd69561a709fd7ab1be956d6850253275368d6a154b87ebbb3d8d888d1d91400a399f8fd9505aa107c2d3c22adad871154f7
7
- data.tar.gz: 94bff2c958c603be3c8a9f03fff9961e5065bd6d8ddc61921f2961aa35a45a2b09b0959ababbdd4ccc21bc442a471535948ca4503b258dcdfb808dd363574a67
6
+ metadata.gz: abf9630280dce2fd8252797e7c15620d0d2ae017e0d856ddb21ff96158812a3d95fb20f4a068e6d338690a40510cd3dafd60c207a208f1d1dea1f0bf80812102
7
+ data.tar.gz: 6839845a4a856bd6d01cc5642bc03bc44afa29a1f7623cb19e226b49ee1c763ddcacce19c2da56c41eb2d096fda61349edcd020e400e7b6255d4623a9dec768b
@@ -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
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.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.10.0
4
+ version: 0.11.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: 2021-11-26 00:00:00.000000000 Z
11
+ date: 2022-01-17 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
@@ -93,6 +93,7 @@ files:
93
93
  - lib/eac_git.rb
94
94
  - lib/eac_git/executables.rb
95
95
  - lib/eac_git/local.rb
96
+ - lib/eac_git/local/branch.rb
96
97
  - lib/eac_git/local/commit.rb
97
98
  - lib/eac_git/local/commit/archive.rb
98
99
  - lib/eac_git/local/commit/changed_file.rb