danger 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/bin/danger +1 -1
  3. data/lib/danger.rb +12 -12
  4. data/lib/danger/ci_source/buildkite.rb +5 -5
  5. data/lib/danger/ci_source/ci_source.rb +2 -2
  6. data/lib/danger/ci_source/circle.rb +11 -11
  7. data/lib/danger/ci_source/drone.rb +5 -5
  8. data/lib/danger/ci_source/jenkins.rb +4 -4
  9. data/lib/danger/ci_source/local_git_repo.rb +10 -10
  10. data/lib/danger/ci_source/semaphore.rb +5 -5
  11. data/lib/danger/ci_source/travis.rb +6 -6
  12. data/lib/danger/ci_source/xcode_server.rb +2 -2
  13. data/lib/danger/commands/init.rb +66 -66
  14. data/lib/danger/commands/init_helpers/interviewer.rb +14 -14
  15. data/lib/danger/commands/local.rb +9 -8
  16. data/lib/danger/commands/plugins/plugin_new.rb +8 -8
  17. data/lib/danger/commands/plugins/plugin_readme.rb +2 -2
  18. data/lib/danger/commands/runner.rb +3 -3
  19. data/lib/danger/comment_generators/github.md.erb +1 -1
  20. data/lib/danger/core_ext/string.rb +1 -1
  21. data/lib/danger/danger_core/dangerfile.rb +12 -12
  22. data/lib/danger/danger_core/dangerfile_dsl.rb +1 -1
  23. data/lib/danger/danger_core/environment_manager.rb +6 -6
  24. data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +9 -9
  25. data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +9 -9
  26. data/lib/danger/danger_core/plugins/dangerfile_import_plugin.rb +10 -6
  27. data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +1 -1
  28. data/lib/danger/plugin_support/plugin.rb +1 -1
  29. data/lib/danger/plugin_support/plugin_file_resolver.rb +23 -23
  30. data/lib/danger/plugin_support/plugin_parser.rb +40 -3
  31. data/lib/danger/request_source/github.rb +14 -14
  32. data/lib/danger/request_source/request_source.rb +4 -4
  33. data/lib/danger/scm_source/git_repo.rb +2 -2
  34. data/lib/danger/version.rb +2 -2
  35. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f27652279a0f07304e15f1f8dacf222f2da87e14
4
- data.tar.gz: 5446bc7ea136645a886279cc5323b507a5d4b487
3
+ metadata.gz: e63c577b5aa89a7b235f6f720d3a41d025ccb56a
4
+ data.tar.gz: b30b994f0372f4ae66aa9dd62af48e1c96f8a595
5
5
  SHA512:
6
- metadata.gz: 385dac5d395271a311240bb80ad17b92b8020369ccd332f4d6bf2c5d7f90584c0036e10140dd20fc8b15f3250a18e59d48980d4dfdc9fafb53b6811801e3c57b
7
- data.tar.gz: 27ea416083b1b0bd56252d4bb9185be4ef7e1904a4021fe96cda3ae90ea25de33c63d6680a4aa819b14df46746d5040004e95330f10c5aa9f61c9c4bf31ff662
6
+ metadata.gz: ba6cc6f86fb8f5859dd04fadd8066443f1fa816cf6ff3b6dc4fcceb5ab6a307bbb366c5404eaa2efbeaa4d2888fe15e3cb1698c2b31be6740ebe7ba4ae434199
7
+ data.tar.gz: 6e1c4b7d707d8f966b9085d3a96d4fd2bba6ed504673631209a11bd1e07fb260b91b8ba074caa196c475677cb30b15aa223673f99747b214cb2143dc2da35802
data/bin/danger CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
2
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
3
3
 
4
4
  require 'danger'
5
5
  Danger::Runner.run ARGV
data/lib/danger.rb CHANGED
@@ -1,15 +1,15 @@
1
- require "danger/version"
2
- require "danger/danger_core/dangerfile"
3
- require "danger/danger_core/environment_manager"
4
- require "danger/commands/runner"
5
- require "danger/plugin_support/plugin"
6
- require "danger/core_ext/string"
1
+ require 'danger/version'
2
+ require 'danger/danger_core/dangerfile'
3
+ require 'danger/danger_core/environment_manager'
4
+ require 'danger/commands/runner'
5
+ require 'danger/plugin_support/plugin'
6
+ require 'danger/core_ext/string'
7
7
 
8
- require "claide"
9
- require "colored"
10
- require "pathname"
11
- require "terminal-table"
12
- require "cork"
8
+ require 'claide'
9
+ require 'colored'
10
+ require 'pathname'
11
+ require 'terminal-table'
12
+ require 'cork'
13
13
 
14
14
  # Import all the Sources (CI, Request and SCM)
15
15
  Dir[File.expand_path('danger/*source/*.rb', File.dirname(__FILE__))].each do |file|
@@ -19,7 +19,7 @@ end
19
19
  module Danger
20
20
  # @return [String] The path to the local gem directory
21
21
  def self.gem_path
22
- gem_name = "danger"
22
+ gem_name = 'danger'
23
23
  unless Gem::Specification.find_all_by_name(gem_name).any?
24
24
  raise "Couldn't find gem directory for 'danger'"
25
25
  end
@@ -5,16 +5,16 @@ module Danger
5
5
  module CISource
6
6
  class Buildkite < CI
7
7
  def self.validates?(env)
8
- return false unless env["BUILDKITE"]
9
- return false unless env["BUILDKITE_REPO"]
10
- return false unless env["BUILDKITE_PULL_REQUEST"]
8
+ return false unless env['BUILDKITE']
9
+ return false unless env['BUILDKITE_REPO']
10
+ return false unless env['BUILDKITE_PULL_REQUEST']
11
11
 
12
12
  return true
13
13
  end
14
14
 
15
15
  def initialize(env)
16
- self.repo_url = env["BUILDKITE_REPO"]
17
- self.pull_request_id = env["BUILDKITE_PULL_REQUEST"]
16
+ self.repo_url = env['BUILDKITE_REPO']
17
+ self.pull_request_id = env['BUILDKITE_PULL_REQUEST']
18
18
 
19
19
  repo_matches = self.repo_url.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
20
20
  self.repo_slug = repo_matches[2] unless repo_matches.nil?
@@ -16,7 +16,7 @@ module Danger
16
16
  end
17
17
 
18
18
  def supported_request_sources
19
- raise "CISource subclass must specify the supported request sources"
19
+ raise 'CISource subclass must specify the supported request sources'
20
20
  end
21
21
 
22
22
  def supports?(request_source)
@@ -28,7 +28,7 @@ module Danger
28
28
  end
29
29
 
30
30
  def initialize(_env)
31
- raise "Subclass and overwrite initialize"
31
+ raise 'Subclass and overwrite initialize'
32
32
  end
33
33
  end
34
34
  end
@@ -6,9 +6,9 @@ module Danger
6
6
  module CISource
7
7
  class CircleCI < CI
8
8
  def self.validates?(env)
9
- return false unless env["CIRCLE_BUILD_NUM"]
10
- return false unless env["CIRCLE_PROJECT_USERNAME"]
11
- return false unless env["CIRCLE_PROJECT_REPONAME"]
9
+ return false unless env['CIRCLE_BUILD_NUM']
10
+ return false unless env['CIRCLE_PROJECT_USERNAME']
11
+ return false unless env['CIRCLE_PROJECT_REPONAME']
12
12
 
13
13
  return true
14
14
  end
@@ -27,11 +27,11 @@ module Danger
27
27
  end
28
28
 
29
29
  def pull_request_url(env)
30
- url = env["CI_PULL_REQUEST"]
30
+ url = env['CI_PULL_REQUEST']
31
31
 
32
- if url.nil? && !env["CIRCLE_PROJECT_USERNAME"].nil? && !env["CIRCLE_PROJECT_REPONAME"].nil?
33
- repo_slug = env["CIRCLE_PROJECT_USERNAME"] + "/" + env["CIRCLE_PROJECT_REPONAME"]
34
- url = fetch_pull_request_url(repo_slug, env["CIRCLE_BUILD_NUM"])
32
+ if url.nil? && !env['CIRCLE_PROJECT_USERNAME'].nil? && !env['CIRCLE_PROJECT_REPONAME'].nil?
33
+ repo_slug = env['CIRCLE_PROJECT_USERNAME'] + '/' + env['CIRCLE_PROJECT_REPONAME']
34
+ url = fetch_pull_request_url(repo_slug, env['CIRCLE_BUILD_NUM'])
35
35
  end
36
36
 
37
37
  url
@@ -40,13 +40,13 @@ module Danger
40
40
  def initialize(env)
41
41
  self.repo_url = GitRepo.new.origins # CircleCI doesn't provide a repo url env variable :/
42
42
 
43
- @circle_token = env["CIRCLE_CI_API_TOKEN"]
43
+ @circle_token = env['CIRCLE_CI_API_TOKEN']
44
44
  url = pull_request_url(env)
45
45
 
46
- if URI.parse(url).path.split("/").count == 5
47
- paths = URI.parse(url).path.split("/")
46
+ if URI.parse(url).path.split('/').count == 5
47
+ paths = URI.parse(url).path.split('/')
48
48
  # The first one is an extra slash, ignore it
49
- self.repo_slug = paths[1] + "/" + paths[2]
49
+ self.repo_slug = paths[1] + '/' + paths[2]
50
50
  self.pull_request_id = paths[4]
51
51
  end
52
52
  end
@@ -4,9 +4,9 @@ module Danger
4
4
  module CISource
5
5
  class Drone < CI
6
6
  def self.validates?(env)
7
- return false unless env["DRONE"]
8
- return false unless env["DRONE_REPO"]
9
- return false unless env["DRONE_PULL_REQUEST"].to_i > 0
7
+ return false unless env['DRONE']
8
+ return false unless env['DRONE_REPO']
9
+ return false unless env['DRONE_PULL_REQUEST'].to_i > 0
10
10
 
11
11
  return true
12
12
  end
@@ -16,8 +16,8 @@ module Danger
16
16
  end
17
17
 
18
18
  def initialize(env)
19
- self.repo_slug = env["DRONE_REPO"]
20
- self.pull_request_id = env["DRONE_PULL_REQUEST"]
19
+ self.repo_slug = env['DRONE_REPO']
20
+ self.pull_request_id = env['DRONE_PULL_REQUEST']
21
21
  self.repo_url = GitRepo.new.origins # Drone doesn't provide a repo url env variable :/
22
22
  end
23
23
  end
@@ -5,8 +5,8 @@ module Danger
5
5
  module CISource
6
6
  class Jenkins < CI
7
7
  def self.validates?(env)
8
- return false unless env["ghprbPullId"].to_i > 0
9
- return false unless env["GIT_URL"]
8
+ return false unless env['ghprbPullId'].to_i > 0
9
+ return false unless env['GIT_URL']
10
10
 
11
11
  return true
12
12
  end
@@ -16,8 +16,8 @@ module Danger
16
16
  end
17
17
 
18
18
  def initialize(env)
19
- self.repo_url = env["GIT_URL"]
20
- self.pull_request_id = env["ghprbPullId"]
19
+ self.repo_url = env['GIT_URL']
20
+ self.pull_request_id = env['ghprbPullId']
21
21
 
22
22
  repo_matches = self.repo_url.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
23
23
  self.repo_slug = repo_matches[2] unless repo_matches.nil?
@@ -9,7 +9,7 @@ module Danger
9
9
  attr_accessor :base_commit, :head_commit
10
10
 
11
11
  def self.validates?(env)
12
- return !env["DANGER_USE_LOCAL_GIT"].nil?
12
+ return !env['DANGER_USE_LOCAL_GIT'].nil?
13
13
  end
14
14
 
15
15
  def git
@@ -25,20 +25,20 @@ module Danger
25
25
  end
26
26
 
27
27
  def initialize(env = {})
28
- github_host = env["DANGER_GITHUB_HOST"] || "github.com"
28
+ github_host = env['DANGER_GITHUB_HOST'] || 'github.com'
29
29
 
30
30
  # get the remote URL
31
31
  remote = run_git "remote show origin -n | grep \"Fetch URL\" | cut -d ':' -f 2-"
32
32
  if remote
33
33
  remote_url_matches = remote.match(%r{#{Regexp.escape github_host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
34
- if !remote_url_matches.nil? and remote_url_matches["repo_slug"]
35
- self.repo_slug = remote_url_matches["repo_slug"]
34
+ if !remote_url_matches.nil? and remote_url_matches['repo_slug']
35
+ self.repo_slug = remote_url_matches['repo_slug']
36
36
  else
37
- puts "Danger local requires a repository hosted on GitHub.com or GitHub Enterprise."
37
+ puts 'Danger local requires a repository hosted on GitHub.com or GitHub Enterprise.'
38
38
  end
39
39
  end
40
40
 
41
- specific_pr = env["LOCAL_GIT_PR_ID"]
41
+ specific_pr = env['LOCAL_GIT_PR_ID']
42
42
  pr_ref = specific_pr ? "##{specific_pr}" : ''
43
43
  pr_command = "log --merges --oneline | grep \"Merge pull request #{pr_ref}\" | head -n 1"
44
44
 
@@ -49,13 +49,13 @@ module Danger
49
49
  if specific_pr
50
50
  raise "Could not find the pull request (#{specific_pr}) inside the git history for this repo."
51
51
  else
52
- raise "No recent pull requests found for this repo, danger requires at least one PR for the local mode."
52
+ raise 'No recent pull requests found for this repo, danger requires at least one PR for the local mode.'
53
53
  end
54
54
  end
55
55
 
56
- self.pull_request_id = pr_merge.match("#([0-9]+)")[1]
57
- sha = pr_merge.split(" ")[0]
58
- parents = run_git("rev-list --parents -n 1 #{sha}").strip.split(" ")
56
+ self.pull_request_id = pr_merge.match('#([0-9]+)')[1]
57
+ sha = pr_merge.split(' ')[0]
58
+ parents = run_git("rev-list --parents -n 1 #{sha}").strip.split(' ')
59
59
  self.base_commit = parents[0]
60
60
  self.head_commit = parents[1]
61
61
  end
@@ -4,9 +4,9 @@ module Danger
4
4
  module CISource
5
5
  class Semaphore < CI
6
6
  def self.validates?(env)
7
- return false unless env["SEMAPHORE"]
8
- return false unless env["SEMAPHORE_REPO_SLUG"]
9
- return false unless env["PULL_REQUEST_NUMBER"].to_i > 0
7
+ return false unless env['SEMAPHORE']
8
+ return false unless env['SEMAPHORE_REPO_SLUG']
9
+ return false unless env['PULL_REQUEST_NUMBER'].to_i > 0
10
10
 
11
11
  return true
12
12
  end
@@ -16,8 +16,8 @@ module Danger
16
16
  end
17
17
 
18
18
  def initialize(env)
19
- self.repo_slug = env["SEMAPHORE_REPO_SLUG"]
20
- self.pull_request_id = env["PULL_REQUEST_NUMBER"]
19
+ self.repo_slug = env['SEMAPHORE_REPO_SLUG']
20
+ self.pull_request_id = env['PULL_REQUEST_NUMBER']
21
21
  self.repo_url = GitRepo.new.origins # Semaphore doesn't provide a repo url env variable :/
22
22
  end
23
23
  end
@@ -5,9 +5,9 @@ module Danger
5
5
  module CISource
6
6
  class Travis < CI
7
7
  def self.validates?(env)
8
- return false unless env["HAS_JOSH_K_SEAL_OF_APPROVAL"]
9
- return false unless env["TRAVIS_REPO_SLUG"]
10
- return false unless env["TRAVIS_PULL_REQUEST"]
8
+ return false unless env['HAS_JOSH_K_SEAL_OF_APPROVAL']
9
+ return false unless env['TRAVIS_REPO_SLUG']
10
+ return false unless env['TRAVIS_PULL_REQUEST']
11
11
 
12
12
  return true
13
13
  end
@@ -17,9 +17,9 @@ module Danger
17
17
  end
18
18
 
19
19
  def initialize(env)
20
- self.repo_slug = env["TRAVIS_REPO_SLUG"]
21
- if env["TRAVIS_PULL_REQUEST"].to_i > 0
22
- self.pull_request_id = env["TRAVIS_PULL_REQUEST"]
20
+ self.repo_slug = env['TRAVIS_REPO_SLUG']
21
+ if env['TRAVIS_PULL_REQUEST'].to_i > 0
22
+ self.pull_request_id = env['TRAVIS_PULL_REQUEST']
23
23
  end
24
24
  self.repo_url = GitRepo.new.origins # Travis doesn't provide a repo url env variable :/
25
25
  end
@@ -4,7 +4,7 @@ module Danger
4
4
  module CISource
5
5
  class XcodeServer < CI
6
6
  def self.validates?(env)
7
- return false unless env["XCS_BOT_NAME"]
7
+ return false unless env['XCS_BOT_NAME']
8
8
 
9
9
  return true
10
10
  end
@@ -14,7 +14,7 @@ module Danger
14
14
  end
15
15
 
16
16
  def initialize(env)
17
- bot_name = env["XCS_BOT_NAME"]
17
+ bot_name = env['XCS_BOT_NAME']
18
18
  return if bot_name.nil?
19
19
 
20
20
  repo_matches = bot_name.match(/\[(.+)\]/)
@@ -17,7 +17,7 @@ module Danger
17
17
  end
18
18
 
19
19
  def initialize(argv)
20
- @bot_name = File.basename(Dir.getwd).split(".").first.capitalize + "Bot"
20
+ @bot_name = File.basename(Dir.getwd).split('.').first.capitalize + 'Bot'
21
21
  super
22
22
  @ui = Interviewer.new(cork)
23
23
  ui.no_delay = argv.flag?('impatient', false)
@@ -43,19 +43,19 @@ module Danger
43
43
  def show_todo_state
44
44
  ui.say "We need to do the following:\n"
45
45
  ui.pause 0.6
46
- ui.say " - [ ] Create a Dangerfile and add a few simple rules."
46
+ ui.say ' - [ ] Create a Dangerfile and add a few simple rules.'
47
47
  ui.pause 0.6
48
48
  ui.say " - [#{@account_created ? 'x' : ' '}] Create a GitHub account for Danger to use, for messaging."
49
49
  ui.pause 0.6
50
- ui.say " - [ ] Set up an access token for Danger."
50
+ ui.say ' - [ ] Set up an access token for Danger.'
51
51
  ui.pause 0.6
52
52
  ui.say " - [ ] Set up Danger to run on your CI.\n\n"
53
53
  end
54
54
 
55
55
  def setup_dangerfile
56
56
  dir = Danger.gem_path
57
- content = File.read(File.join(dir, "lib", "assets", "DangerfileTemplate"))
58
- File.write("Dangerfile", content)
57
+ content = File.read(File.join(dir, 'lib', 'assets', 'DangerfileTemplate'))
58
+ File.write('Dangerfile', content)
59
59
 
60
60
  ui.header 'Step 1: Creating a starter Dangerfile'
61
61
  ui.say "I've set up an example Dangerfile for you in this folder.\n"
@@ -63,14 +63,14 @@ module Danger
63
63
 
64
64
  ui.say "cat #{Dir.pwd}/Dangerfile\n".blue
65
65
  content.lines.each do |l|
66
- ui.say " " + l.chomp.green
66
+ ui.say ' ' + l.chomp.green
67
67
  end
68
- ui.say ""
68
+ ui.say ''
69
69
  ui.pause 2
70
70
 
71
71
  ui.say "There's a collection of small, simple ideas in here, but Danger is about being able to easily"
72
- ui.say "iterate. The power comes from you having the ability to codify fixes for some of the problems"
73
- ui.say "that come up in day to day programming. It can be difficult to try and see those from day 1."
72
+ ui.say 'iterate. The power comes from you having the ability to codify fixes for some of the problems'
73
+ ui.say 'that come up in day to day programming. It can be difficult to try and see those from day 1.'
74
74
 
75
75
  ui.say "\nIf you'd like to investigate the file, and make some changes - I'll wait here,"
76
76
  ui.say "press return when you're ready to move on..."
@@ -91,7 +91,7 @@ module Danger
91
91
  ui.link 'https://www.flickr.com/search/?text=robot&license=2%2C3%2C4%2C5%2C6%2C9'
92
92
  ui.link 'https://www.google.com/search?q=robot&tbs=sur:fmc&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwjgy8-f95jLAhWI7hoKHV_UD00QsAQIMQ&biw=1265&bih=1359'
93
93
 
94
- ui.say ""
94
+ ui.say ''
95
95
  note_about_clicking_links
96
96
  ui.pause 1
97
97
  ui.say "\nCool, please press return when you have your account ready (and you've verified the email...)"
@@ -102,25 +102,25 @@ module Danger
102
102
  ui.header 'Step 3: Configuring a GitHub Personal Access Token'
103
103
 
104
104
  ui.say "Here's the link, you should open this in the private session where you just created the new GitHub account"
105
- ui.link "https://github.com/settings/tokens/new"
105
+ ui.link 'https://github.com/settings/tokens/new'
106
106
  ui.pause 1
107
107
 
108
- @is_open_source = ui.ask_with_answers("For token access rights, I need to know if this is for an Open Source or Closed Source project\n", ["Open", "Closed"])
108
+ @is_open_source = ui.ask_with_answers("For token access rights, I need to know if this is for an Open Source or Closed Source project\n", ['Open', 'Closed'])
109
109
 
110
110
  if considered_an_oss_repo?
111
111
  ui.say "For Open Source projects, I'd recommend giving the token the smallest scope possible."
112
- ui.say "This means only providing access to " + "public_repo".yellow + " in the token.\n\n"
112
+ ui.say 'This means only providing access to ' + 'public_repo'.yellow + " in the token.\n\n"
113
113
  ui.pause 1
114
114
  ui.say "This token limits Danger's abilities to just writing comments on OSS projects. I recommend"
115
- ui.say "this because the token can quite easily be extracted from the environment via pull requests."
115
+ ui.say 'this because the token can quite easily be extracted from the environment via pull requests.'
116
116
  ui.say "#{@bot_name} does not need admin access to your repo. So its ability to cause chaos is minimalized.\n"
117
117
 
118
- elsif @is_open_source == "closed"
118
+ elsif @is_open_source == 'closed'
119
119
  ui.say "For Closed Source projects, I'd recommend giving the token access to the whole repo scope."
120
- ui.say "This means only providing access to " + "repo".yellow + ", and its children in the token.\n\n"
120
+ ui.say 'This means only providing access to ' + 'repo'.yellow + ", and its children in the token.\n\n"
121
121
  ui.pause 1
122
- ui.say "It's worth noting that you " + "should not".bold.white + " re-use this token for OSS repos."
123
- ui.say "Make a new one for those repos with just " + "public_repo".yellow + "."
122
+ ui.say "It's worth noting that you " + 'should not'.bold.white + ' re-use this token for OSS repos.'
123
+ ui.say 'Make a new one for those repos with just ' + 'public_repo'.yellow + '.'
124
124
  ui.pause 1
125
125
  ui.say "Additionally, don't forget to add your new GitHub account as a collaborator to your Closed Source project."
126
126
  end
@@ -130,87 +130,87 @@ module Danger
130
130
  end
131
131
 
132
132
  def considered_an_oss_repo?
133
- @is_open_source == "open"
133
+ @is_open_source == 'open'
134
134
  end
135
135
 
136
136
  def current_repo_slug
137
137
  @git = GitRepo.new
138
138
  repo_matches = @git.origins.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$})
139
- repo_matches[2] || "[Your/Repo]"
139
+ repo_matches[2] || '[Your/Repo]'
140
140
  end
141
141
 
142
142
  def setup_danger_ci
143
143
  ui.header 'Step 4: Add Danger for your CI'
144
144
 
145
- uses_travis if File.exist? ".travis.yml"
146
- uses_circle if File.exist? "circle.yml"
147
- unsure_ci unless File.exist?(".travis.yml") || File.exist?(".circle.yml")
145
+ uses_travis if File.exist? '.travis.yml'
146
+ uses_circle if File.exist? 'circle.yml'
147
+ unsure_ci unless File.exist?('.travis.yml') || File.exist?('.circle.yml')
148
148
 
149
149
  ui.say "\nOK, I'll give you a moment to do this..."
150
150
  ui.wait_for_return
151
151
 
152
- ui.header "Final step: exposing the GitHub token as an environment build variable."
152
+ ui.header 'Final step: exposing the GitHub token as an environment build variable.'
153
153
  ui.pause 0.4
154
154
  if considered_an_oss_repo?
155
- ui.say "As you have an Open Source repo, this token should be considered public, otherwise you cannot"
155
+ ui.say 'As you have an Open Source repo, this token should be considered public, otherwise you cannot'
156
156
  ui.say "run Danger on pull requests from forks, limiting its use.\n"
157
157
  ui.pause 1
158
158
  end
159
159
 
160
- travis_token if File.exist? ".travis.yml"
161
- circle_token if File.exist? "circle.yml"
162
- unsure_token unless File.exist?(".travis.yml") || File.exist?(".circle.yml")
160
+ travis_token if File.exist? '.travis.yml'
161
+ circle_token if File.exist? 'circle.yml'
162
+ unsure_token unless File.exist?('.travis.yml') || File.exist?('.circle.yml')
163
163
 
164
164
  ui.pause 0.6
165
- ui.say "This is the last step, I can give you a second..."
165
+ ui.say 'This is the last step, I can give you a second...'
166
166
  ui.wait_for_return
167
167
  end
168
168
 
169
169
  def uses_travis
170
- danger = "bundle exec danger".yellow
171
- config = YAML.load(File.read(".travis.yml"))
172
- if config["script"]
173
- ui.say "Add " + "- ".yellow + danger + " as a new step in the " + "script".yellow + " section of your .travis.yml file."
170
+ danger = 'bundle exec danger'.yellow
171
+ config = YAML.load(File.read('.travis.yml'))
172
+ if config['script']
173
+ ui.say 'Add ' + '- '.yellow + danger + ' as a new step in the ' + 'script'.yellow + ' section of your .travis.yml file.'
174
174
  else
175
- ui.say "I'd recommend adding " + "script: ".yellow + danger + " to the script section of your .travis.yml file."
175
+ ui.say "I'd recommend adding " + 'script: '.yellow + danger + ' to the script section of your .travis.yml file.'
176
176
  end
177
177
 
178
178
  ui.pause 1
179
- ui.say "You shouldn't use " + "after_success, after_failure, after_script".red + " as they cannot fail your builds."
179
+ ui.say "You shouldn't use " + 'after_success, after_failure, after_script'.red + ' as they cannot fail your builds.'
180
180
  end
181
181
 
182
182
  def uses_circle
183
- danger = "- bundle exec danger".yellow
184
- config = YAML.load(File.read("circle.yml"))
183
+ danger = '- bundle exec danger'.yellow
184
+ config = YAML.load(File.read('circle.yml'))
185
185
 
186
- if config["test"]
187
- if config["test"]["post"]
188
- ui.say "Add " + danger + " as a new step in the " + "test:post:".yellow + " section of your circle.yml file."
186
+ if config['test']
187
+ if config['test']['post']
188
+ ui.say 'Add ' + danger + ' as a new step in the ' + 'test:post:'.yellow + ' section of your circle.yml file.'
189
189
  else
190
- ui.say "Add " + danger + " as a new step in the " + "test:override:".yellow + " section of your circle.yml file."
190
+ ui.say 'Add ' + danger + ' as a new step in the ' + 'test:override:'.yellow + ' section of your circle.yml file.'
191
191
  end
192
192
  else
193
- ui.say "Add this to the bottom of your circle.yml file:"
194
- ui.say "test:".green
195
- ui.say " post:".green
193
+ ui.say 'Add this to the bottom of your circle.yml file:'
194
+ ui.say 'test:'.green
195
+ ui.say ' post:'.green
196
196
  ui.say " #{danger}".green
197
197
  end
198
198
  end
199
199
 
200
200
  def unsure_ci
201
- danger = "bundle exec danger".yellow
201
+ danger = 'bundle exec danger'.yellow
202
202
  ui.say "As I'm not sure what CI you want to run Danger on based on the files in your repo, I'll just offer some generic"
203
- ui.say "advice. You want to run " + danger + " after your tests have finished running, it should still be during the testing"
204
- ui.say "process so the build can fail."
203
+ ui.say 'advice. You want to run ' + danger + ' after your tests have finished running, it should still be during the testing'
204
+ ui.say 'process so the build can fail.'
205
205
  end
206
206
 
207
207
  def travis_token
208
208
  # https://travis-ci.org/artsy/eigen/settings
209
- ui.say "In order to add an environment variable, go to:"
209
+ ui.say 'In order to add an environment variable, go to:'
210
210
  ui.link "https://travis-ci.org/#{current_repo_slug}/settings"
211
- ui.say "\nThe name is " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal Access Token."
211
+ ui.say "\nThe name is " + 'DANGER_GITHUB_API_TOKEN'.yellow + ' and the value is the GitHub Personal Access Token.'
212
212
  if @is_open_source
213
- ui.say "Make sure to have \"Display value in build log\" enabled."
213
+ ui.say 'Make sure to have "Display value in build log" enabled.'
214
214
  end
215
215
  end
216
216
 
@@ -218,28 +218,28 @@ module Danger
218
218
  # https://circleci.com/gh/artsy/eigen/edit#env-vars
219
219
  if considered_an_oss_repo?
220
220
  ui.say "Before we start, it's important to be up-front. CircleCI only really has one option to support running Danger"
221
- ui.say "for forks on OSS repos. It is quite a drastic option, and I want to let you know the best place to understand"
221
+ ui.say 'for forks on OSS repos. It is quite a drastic option, and I want to let you know the best place to understand'
222
222
  ui.say "the ramifications of turning on a setting I'm about to advise.\n"
223
- ui.link "https://circleci.com/docs/fork-pr-builds"
224
- ui.say "TLDR: If you have anything other than Danger config settings in CircleCI, then you should not turn on the setting."
223
+ ui.link 'https://circleci.com/docs/fork-pr-builds'
224
+ ui.say 'TLDR: If you have anything other than Danger config settings in CircleCI, then you should not turn on the setting.'
225
225
  ui.say "I'll give you a minute to read it..."
226
226
  ui.wait_for_return
227
227
 
228
- ui.say "On Danger/Danger we turn on " + "Permissive building of fork pull requests".yellow + " this exposes the token to Danger"
229
- ui.say "You can find this setting at:"
228
+ ui.say 'On Danger/Danger we turn on ' + 'Permissive building of fork pull requests'.yellow + ' this exposes the token to Danger'
229
+ ui.say 'You can find this setting at:'
230
230
  ui.link "https://circleci.com/gh/#{current_repo_slug}/edit#advanced-settings\n"
231
231
  ui.say "I'll hold..."
232
232
  ui.wait_for_return
233
233
  end
234
234
 
235
- ui.say "In order to expose an environment variable, go to:"
235
+ ui.say 'In order to expose an environment variable, go to:'
236
236
  ui.link "https://circleci.com/gh/#{current_repo_slug}/edit#env-vars"
237
- ui.say "The name is " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal Acess Token."
237
+ ui.say 'The name is ' + 'DANGER_GITHUB_API_TOKEN'.yellow + ' and the value is the GitHub Personal Acess Token.'
238
238
  end
239
239
 
240
240
  def unsure_token
241
- ui.say "You need to expose a token called " + "DANGER_GITHUB_API_TOKEN".yellow + " and the value is the GitHub Personal Acess Token."
242
- ui.say "Depending on the CI system, this may need to be done on the machine ( in the " + "~/.bashprofile".yellow + ") or in a web UI somewhere."
241
+ ui.say 'You need to expose a token called ' + 'DANGER_GITHUB_API_TOKEN'.yellow + ' and the value is the GitHub Personal Acess Token.'
242
+ ui.say 'Depending on the CI system, this may need to be done on the machine ( in the ' + '~/.bashprofile'.yellow + ') or in a web UI somewhere.'
243
243
  end
244
244
 
245
245
  def note_about_clicking_links
@@ -247,15 +247,15 @@ module Danger
247
247
  end
248
248
 
249
249
  def info
250
- ui.header "Useful info"
251
- ui.say "- One of the best ways to test out new rules locally is via " + "bundle exec danger local".yellow + "."
250
+ ui.header 'Useful info'
251
+ ui.say '- One of the best ways to test out new rules locally is via ' + 'bundle exec danger local'.yellow + '.'
252
252
  ui.pause 0.6
253
- ui.say "- You can have Danger output all of its variables to the console via the " + "--verbose".yellow + " option."
253
+ ui.say '- You can have Danger output all of its variables to the console via the ' + '--verbose'.yellow + ' option.'
254
254
  ui.pause 0.6
255
- ui.say "- You can look at the following Dangerfiles to get some more ideas:"
255
+ ui.say '- You can look at the following Dangerfiles to get some more ideas:'
256
256
  ui.pause 0.6
257
- ui.link "https://github.com/danger/danger/blob/master/Dangerfile"
258
- ui.link "https://github.com/artsy/eigen/blob/master/Dangerfile"
257
+ ui.link 'https://github.com/danger/danger/blob/master/Dangerfile'
258
+ ui.link 'https://github.com/artsy/eigen/blob/master/Dangerfile'
259
259
  ui.pause 1
260
260
  end
261
261
 
@@ -264,7 +264,7 @@ module Danger
264
264
  ui.pause 0.6
265
265
 
266
266
  ui.say "And you're good to go. Danger is a collaboration between Orta Therox, Gem 'Danger' McShane and Felix Krause."
267
- ui.say "If you like it, let others know. If you want to know more, follow " + "@orta".yellow + " and " + "@KrauseFx".yellow + " on Twitter."
267
+ ui.say 'If you like it, let others know. If you want to know more, follow ' + '@orta'.yellow + ' and ' + '@KrauseFx'.yellow + ' on Twitter.'
268
268
  ui.say "If you don't like it, help us improve it! xxx"
269
269
  end
270
270
  end