class Danger::DangerfileBitbucketCloudPlugin


@tags core, bitbucket_cloud
@see danger/danger
warn “#{bitbucket_cloud.html_link(”Package.json“)} was edited.” if git.modified_files.include? “Package.json”
@example Highlight with a clickable link if a Package.json is changed
end
message “This PR changes #{ bitbucket_cloud.html_link(config_files) }”
config_files = git.modified_files.select { |path| path.include? “config/” }
if git.modified_files.include? “config/*.js”
@example Send a message with links to a collection of specific files
warn “This PR does not have any assignees yet.” if bitbucket_cloud.pr_json.length == 0
@example Ensure that all PRs have an assignee
message “Welcome, Danger.” if bitbucket_cloud.pr_author == “dangermcshane”
@example Highlight when a celebrity makes a pull request
failure “Please re-submit this PR to develop, we may have already fixed your issue.” if bitbucket_cloud.branch_for_base != “develop”
@example Only accept PRs to the develop branch
failure “Please provide a summary in the Pull Request description” if bitbucket_cloud.pr_body.length < 5
@example Ensure there is a summary for a PR
failure “Please add labels to this PR” if bitbucket_cloud.pr_labels.empty?
@example Ensure that labels have been used on the PR
declared_trivial = (bitbucket_cloud.pr_title + bitbucket_cloud.pr_body).include?(“#trivial”)
@example Declare a PR to be simple to avoid specific Danger rules
warn “PR is classed as Work in Progress” if bitbucket_cloud.pr_title.include? “[WIP]”
@example Warn when a PR is classed as work in progress
through a few standard functions to simplify your code.
Handles interacting with Bitbucket Cloud inside a Dangerfile. Provides a few functions which wrap ‘pr_json` and also

def self.instance_name

Returns:
  • (String) -
def self.instance_name
  "bitbucket_cloud"
end

def self.new(dangerfile)

So that this init can fail.
def self.new(dangerfile)
  return nil if dangerfile.env.request_source.class != Danger::RequestSources::BitbucketCloud
  super
end

def base_commit

Returns:
  • (String) -
def base_commit
  @bs.pr_json[:destination][:commit][:hash]
end

def branch_for_base

Returns:
  • (String) -
def branch_for_base
  @bs.pr_json[:destination][:branch][:name]
end

def branch_for_head

Returns:
  • (String) -
def branch_for_head
  @bs.pr_json[:source][:branch][:name]
end

def head_commit

Returns:
  • (String) -
def head_commit
  @bs.pr_json[:source][:commit][:hash]
end

def initialize(dangerfile)

def initialize(dangerfile)
  super(dangerfile)
  @bs = dangerfile.env.request_source
end

def pr_author

Returns:
  • (String) -
def pr_author
  @bs.pr_json[:author][:nickname]
end

def pr_description

Returns:
  • (String) -
def pr_description
  @bs.pr_json[:description].to_s
end

def pr_json

Returns:
  • (Hash) -
def pr_json
  @bs.pr_json
end

def pr_link

Returns:
  • (String) -
def pr_link
  @bs.pr_json[:links][:self][:href]
end

def pr_title

Returns:
  • (String) -
def pr_title
  @bs.pr_json[:title].to_s
end