Module: Fastlane::Helper::Github
- Defined in:
- lib/fastlane/plugin/emerge/helper/github.rb
Constant Summary collapse
- GITHUB_EVENT_PR =
- "pull_request".freeze 
- GITHUB_EVENT_PUSH =
- "push".freeze 
Class Method Summary collapse
- .base_sha ⇒ Object
- .branch ⇒ Object
- .event_name ⇒ Object
- .github_event_data ⇒ Object
- .is_pull_request? ⇒ Boolean
- .is_push? ⇒ Boolean
- .is_supported_github_event? ⇒ Boolean
- .pr_number ⇒ Object
- .previous_sha ⇒ Object
- .repo_name ⇒ Object
- .repo_owner ⇒ Object
- .sha ⇒ Object
Class Method Details
.base_sha ⇒ Object
| 36 37 38 39 40 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 36 def self.base_sha if is_pull_request? github_event_data.dig(:pull_request, :base, :sha) end end | 
.branch ⇒ Object
| 52 53 54 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 52 def self.branch is_pull_request? ? github_event_data.dig(:pull_request, :head, :ref) : Git.branch end | 
.event_name ⇒ Object
| 11 12 13 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 11 def self.event_name ENV['GITHUB_EVENT_NAME'] end | 
.github_event_data ⇒ Object
| 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 66 def self.github_event_data github_event_path = ENV['GITHUB_EVENT_PATH'] UI.error!("GITHUB_EVENT_PATH is not set") if github_event_path.nil? unless File.exist?(github_event_path) UI.error!("File #{github_event_path} doesn't exist") end file_content = File.read(github_event_path) file_json = JSON.parse(file_content, symbolize_names: true) if ENV['DEBUG'] UI.("Parsed GitHub event data: #{file_json.inspect}") end file_json end | 
.is_pull_request? ⇒ Boolean
| 20 21 22 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 20 def self.is_pull_request? event_name == GITHUB_EVENT_PR end | 
.is_push? ⇒ Boolean
| 24 25 26 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 24 def self.is_push? event_name == GITHUB_EVENT_PUSH end | 
.is_supported_github_event? ⇒ Boolean
| 15 16 17 18 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 15 def self.is_supported_github_event? UI.("GitHub event name: #{event_name}") is_pull_request? || is_push? end | 
.pr_number ⇒ Object
| 48 49 50 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 48 def self.pr_number is_pull_request? ? github_event_data.dig(:number) : nil end | 
.previous_sha ⇒ Object
| 42 43 44 45 46 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 42 def self.previous_sha if is_push? github_event_data.dig(:before) end end | 
.repo_name ⇒ Object
| 60 61 62 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 60 def self.repo_name github_event_data.dig(:repository, :full_name) end | 
.repo_owner ⇒ Object
| 56 57 58 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 56 def self.repo_owner github_event_data.dig(:repository, :owner, :login) end | 
.sha ⇒ Object
| 28 29 30 31 32 33 34 | # File 'lib/fastlane/plugin/emerge/helper/github.rb', line 28 def self.sha if is_push? ENV['GITHUB_SHA'] elsif is_pull_request? github_event_data.dig(:pull_request, :head, :sha) end end |