Module: Fastlane::Helper::Git

Defined in:
lib/fastlane/plugin/emerge/helper/git.rb

Class Method Summary collapse

Class Method Details

.base_shaObject



21
22
23
24
25
26
27
28
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 21

def self.base_sha
  shell_command = "git merge-base #{remote_head_branch} #{branch}"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  return nil if stdout.strip.empty? || !status.success?
  current_sha = sha
  stdout.strip == current_sha ? nil : stdout.strip
end

.branchObject



7
8
9
10
11
12
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 7

def self.branch
  shell_command = "git rev-parse --abbrev-ref HEAD"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  stdout.strip if status.success?
end

.primary_remoteObject



30
31
32
33
34
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 30

def self.primary_remote
  remote = remote()
  return nil if remote.nil?
  remote.include?("origin") ? "origin" : remote.first
end

.remoteObject



58
59
60
61
62
63
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 58

def self.remote
  shell_command = "git remote"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  stdout.split("\n") if status.success?
end

.remote_head_branch(remote = primary_remote) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 36

def self.remote_head_branch(remote = primary_remote)
  return nil if remote.nil?
  shell_command = "git remote show #{remote}"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  return nil if stdout.nil? || !status.success?
  stdout
    .split("\n")
    .map(&:strip)
    .find { |line| line.start_with?("HEAD branch: ") }
    &.split(' ')
    &.last
end

.remote_url(remote = primary_remote) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 50

def self.remote_url(remote = primary_remote)
  return nil if remote.nil?
  shell_command = "git config --get remote.#{remote}.url"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  stdout if status.success?
end

.shaObject



14
15
16
17
18
19
# File 'lib/fastlane/plugin/emerge/helper/git.rb', line 14

def self.sha
  shell_command = "git rev-parse HEAD"
  UI.command(shell_command)
  stdout, _, status = Open3.capture3(shell_command)
  stdout.strip if status.success?
end