Module: Fastlane::Helper::Git
- Defined in:
- lib/fastlane/plugin/emerge/helper/git.rb
Class Method Summary collapse
- .base_sha ⇒ Object
- .branch ⇒ Object
- .primary_remote ⇒ Object
- .remote ⇒ Object
- .remote_head_branch(remote = primary_remote) ⇒ Object
- .remote_url(remote = primary_remote) ⇒ Object
- .sha ⇒ Object
Class Method Details
.base_sha ⇒ Object
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 |
.branch ⇒ Object
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_remote ⇒ Object
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 |
.remote ⇒ Object
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 |
.sha ⇒ Object
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 |