Class: Danger::DangerfileGitHubPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/danger/danger_core/plugins/dangerfile_github_plugin.rb

PR Metadata collapse

PR Commit Metadata collapse

Instance Method Summary collapse

Methods inherited from Plugin

all_plugins, inherited, instance_name, #method_missing

Constructor Details

#initialize(dangerfile) ⇒ DangerfileGitHubPlugin

Returns a new instance of DangerfileGitHubPlugin.



5
6
7
8
9
10
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 5

def initialize(dangerfile)
  super(dangerfile)
  return nil unless dangerfile.env.request_source.class == Danger::RequestSources::GitHub

  @github = dangerfile.env.request_source
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Danger::Plugin

Instance Method Details

#base_commitObject

The base commit to which the PR is going to be merged as a parent

Returns:

  • String



56
57
58
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 56

def base_commit
  @github.pr_json[:base][:sha]
end

#branch_for_mergeObject

The branch to which the PR is going to be merged into

Returns:

  • String



48
49
50
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 48

def branch_for_merge
  @github.pr_json[:base][:ref]
end

#head_commitObject

The head commit to which the PR is requesting to be merged from

Returns:

  • String



64
65
66
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 64

def head_commit
  @github.pr_json[:head][:sha]
end

#pr_authorObject

The username of the author of the Pull Request

Returns:

  • String



32
33
34
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 32

def pr_author
  @github.pr_json[:user][:login].to_s
end

#pr_bodyObject

The body text of the Pull Request

Returns:

  • String



24
25
26
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 24

def pr_body
  @github.pr_json[:body].to_s
end

#pr_labelsString

The labels assigned to the Pull Request

Returns:



40
41
42
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 40

def pr_labels
  @github.issue_json[:labels].map { |l| l[:name] }
end

#pr_titleObject

The title of the Pull Request

Returns:

  • String



16
17
18
# File 'lib/danger/danger_core/plugins/dangerfile_github_plugin.rb', line 16

def pr_title
  @github.pr_json[:title].to_s
end