3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/danger/danger_core/executor.rb', line 3
def run(env: nil,
dm: nil,
cork: nil,
base: nil,
head: nil,
dangerfile_path: nil,
danger_id: nil)
cork ||= Cork::Board.new(silent: false,
verbose: false)
env ||= EnvironmentManager.new(ENV)
dm ||= Dangerfile.new(env, cork)
if dm.env.pr?
dm.init_plugins
dm.env.fill_environment_vars
begin
dm.env.ensure_danger_branches_are_setup
ci_base = base || EnvironmentManager.danger_base_branch
ci_head = head || EnvironmentManager.danger_head_branch
dm.env.scm.diff_for_folder(".", from: ci_base, to: ci_head)
dm.parse(Pathname.new(dangerfile_path))
if dm.env.request_source.organisation && !dm.env.request_source.danger_repo? && (danger_repo = dm.env.request_source.fetch_danger_repo)
url = dm.env.request_source.file_url(repository: danger_repo.name, path: "Dangerfile")
path = dm.plugin.download(url)
dm.parse(Pathname.new(path))
end
post_results(dm, danger_id)
dm.print_results
ensure
dm.env.clean_up
end
else
cork.puts "Not a Pull Request - skipping `danger` run"
end
end
|