Class: Danger::DangerfileBitbucketCloudPlugin
- Defined in:
- lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb
Overview
Handles interacting with Bitbucket Cloud inside a Dangerfile. Provides a few functions which wrap ‘pr_json` and also through a few standard functions to simplify your code.
Bitbucket Cloud Misc collapse
-
#pr_json ⇒ Hash
The hash that represents the PR’s JSON.
PR Metadata collapse
-
#pr_author ⇒ String
The username of the author of the Pull Request.
-
#pr_description ⇒ String
(also: #pr_body)
The body text of the Pull Request.
-
#pr_title ⇒ String
The title of the Pull Request.
PR Commit Metadata collapse
-
#base_commit ⇒ String
The base commit to which the PR is going to be merged as a parent.
-
#branch_for_base ⇒ String
The branch to which the PR is going to be merged into.
-
#branch_for_head ⇒ String
The branch to which the PR is going to be merged from.
-
#head_commit ⇒ String
The head commit to which the PR is requesting to be merged from.
-
#pr_link ⇒ String
A href that represents the current PR.
Class Method Summary collapse
-
.instance_name ⇒ String
The instance name used in the Dangerfile.
-
.new(dangerfile) ⇒ Object
So that this init can fail.
Instance Method Summary collapse
-
#initialize(dangerfile) ⇒ DangerfileBitbucketCloudPlugin
constructor
A new instance of DangerfileBitbucketCloudPlugin.
Methods inherited from Plugin
all_plugins, clear_external_plugins, inherited, #method_missing
Constructor Details
#initialize(dangerfile) ⇒ DangerfileBitbucketCloudPlugin
Returns a new instance of DangerfileBitbucketCloudPlugin.
65 66 67 68 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 65 def initialize(dangerfile) super(dangerfile) @bs = dangerfile.env.request_source end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Danger::Plugin
Class Method Details
.instance_name ⇒ String
The instance name used in the Dangerfile
61 62 63 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 61 def self.instance_name "bitbucket_cloud" end |
.new(dangerfile) ⇒ Object
So that this init can fail.
53 54 55 56 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 53 def self.new(dangerfile) return nil if dangerfile.env.request_source.class != Danger::RequestSources::BitbucketCloud super end |
Instance Method Details
#base_commit ⇒ String
The base commit to which the PR is going to be merged as a parent.
131 132 133 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 131 def base_commit @bs.pr_json[:destination][:commit][:hash] end |
#branch_for_base ⇒ String
The branch to which the PR is going to be merged into.
107 108 109 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 107 def branch_for_base @bs.pr_json[:destination][:branch][:name] end |
#branch_for_head ⇒ String
The branch to which the PR is going to be merged from.
123 124 125 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 123 def branch_for_head @bs.pr_json[:source][:branch][:name] end |
#head_commit ⇒ String
The head commit to which the PR is requesting to be merged from.
139 140 141 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 139 def head_commit @bs.pr_json[:source][:commit][:hash] end |
#pr_author ⇒ String
The username of the author of the Pull Request.
99 100 101 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 99 def @bs.pr_json[:author][:username] end |
#pr_description ⇒ String Also known as: pr_body
The body text of the Pull Request.
90 91 92 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 90 def pr_description @bs.pr_json[:description].to_s end |
#pr_json ⇒ Hash
The hash that represents the PR’s JSON. For an example of what this looks like see the [Danger Fixture’d one](raw.githubusercontent.com/danger/danger/master/spec/fixtures/bitbucket_cloud_api/pr_response.json).
74 75 76 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 74 def pr_json @bs.pr_json end |
#pr_link ⇒ String
A href that represents the current PR
115 116 117 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 115 def pr_link @bs.pr_json[:links][:self][:href] end |
#pr_title ⇒ String
The title of the Pull Request.
82 83 84 |
# File 'lib/danger/danger_core/plugins/dangerfile_bitbucket_cloud_plugin.rb', line 82 def pr_title @bs.pr_json[:title].to_s end |