Class: Danger::RequestSources::BitbucketCloud
Constant Summary
RequestSource::DANGER_REPO_NAME
Instance Attribute Summary collapse
#ci_source, #environment, #ignored_violations
Class Method Summary
collapse
Instance Method Summary
collapse
#apply_template, #generate_comment, #generate_description, #generate_inline_comment_body, #generate_inline_markdown_body, #markdown_link_to_message, #markdown_parser, #messages_are_equivalent, #process_markdown, #random_compliment, #table
#parse_comment, #parse_message_from_row, #parse_tables_from_comment, #table_kind_from_title, #violations_from_table
available_request_sources, available_source_names_and_envs, #file_url, inherited, optional_env_vars, source_name
Constructor Details
#initialize(ci_source, environment) ⇒ BitbucketCloud
Returns a new instance of BitbucketCloud.
19
20
21
22
23
24
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 19
def initialize(ci_source, environment)
self.ci_source = ci_source
self.environment = environment
@api = BitbucketCloudAPI.new(ci_source.repo_slug, ci_source.pull_request_id, nil, environment)
end
|
Instance Attribute Details
#pr_json ⇒ Object
Returns the value of attribute pr_json.
10
11
12
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 10
def pr_json
@pr_json
end
|
Class Method Details
.env_vars ⇒ Object
12
13
14
15
16
17
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 12
def self.env_vars
[
"DANGER_BITBUCKETCLOUD_USERNAME",
"DANGER_BITBUCKETCLOUD_PASSWORD"
]
end
|
Instance Method Details
83
84
85
86
87
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 83
def (danger_id: "danger")
@api..each do |c|
@api.(c[:id]) if c[:content][:raw] =~ /generated_by_#{danger_id}/
end
end
|
#fetch_details ⇒ Object
43
44
45
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 43
def fetch_details
self.pr_json = @api.fetch_pr_json
end
|
#host ⇒ Object
39
40
41
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 39
def host
@host ||= @api.host
end
|
#organisation ⇒ Object
63
64
65
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 63
def organisation
nil
end
|
#scm ⇒ Object
35
36
37
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 35
def scm
@scm ||= GitRepo.new
end
|
#setup_danger_branches ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 47
def setup_danger_branches
base_branch = self.pr_json[:destination][:branch][:name]
base_commit = self.pr_json[:destination][:commit][:hash]
head_branch = self.pr_json[:source][:branch][:name]
head_commit = self.pr_json[:source][:commit][:hash]
scm.ensure_commitish_exists_on_branch! base_branch, base_commit
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
scm.ensure_commitish_exists_on_branch! head_branch, head_commit
self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{head_commit}"
end
|
#update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 67
def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [], danger_id: "danger", new_comment: false, remove_previous_comments: false)
(danger_id: danger_id) if ! ||
= generate_description(warnings: warnings, errors: errors)
+= "\n\n"
+= (warnings: warnings,
errors: errors,
messages: messages,
markdowns: markdowns,
previous_violations: {},
danger_id: danger_id,
template: "bitbucket_server")
@api.()
end
|
#validates_as_api_source? ⇒ Boolean
31
32
33
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 31
def validates_as_api_source?
@api.credentials_given?
end
|
#validates_as_ci? ⇒ Boolean
26
27
28
29
|
# File 'lib/danger/request_sources/bitbucket_cloud.rb', line 26
def validates_as_ci?
true
end
|