lib/danger/request_source/github.rb in danger-0.8.4 vs lib/danger/request_source/github.rb in danger-0.8.5
- old
+ new
@@ -11,37 +11,37 @@
self.ci_source = ci_source
self.environment = environment
self.support_tokenless_auth = false
Octokit.auto_paginate = true
- @token = @environment["DANGER_GITHUB_API_TOKEN"]
- if @environment["DANGER_GITHUB_API_HOST"]
- Octokit.api_endpoint = @environment["DANGER_GITHUB_API_HOST"]
+ @token = @environment['DANGER_GITHUB_API_TOKEN']
+ if @environment['DANGER_GITHUB_API_HOST']
+ Octokit.api_endpoint = @environment['DANGER_GITHUB_API_HOST']
end
end
def scm
@scm ||= GitRepo.new
end
def host
- @host = @environment["DANGER_GITHUB_HOST"] || "github.com"
+ @host = @environment['DANGER_GITHUB_HOST'] || 'github.com'
end
def client
- raise "No API token given, please provide one using `DANGER_GITHUB_API_TOKEN`" if !@token && !support_tokenless_auth
+ raise 'No API token given, please provide one using `DANGER_GITHUB_API_TOKEN`' if !@token && !support_tokenless_auth
@client ||= Octokit::Client.new(access_token: @token)
end
def markdown_parser
@markdown_parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true)
end
def setup_danger_branches
# we can use a github specific feature here:
base_commit = self.pr_json[:base][:sha]
- head_commit = self.scm.head_commit
+ head_commit = self.pr_json[:head][:sha]
# Next, we want to ensure that we have a version of the current branch at a known location
self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{base_commit}"
# OK, so we want to ensure that we have a known head branch, this will always represent
@@ -117,11 +117,11 @@
end
begin
client.create_status(ci_source.repo_slug, latest_pr_commit_ref, status, {
description: message,
- context: "danger/danger",
+ context: 'danger/danger',
target_url: details_url
})
rescue
# This usually means the user has no commit access to this repo
# That's always the case for open source projects where you can only
@@ -144,12 +144,12 @@
client.delete_comment(ci_source.repo_slug, issue[:id])
end
end
def random_compliment
- compliment = ["Well done.", "Congrats.", "Woo!",
- "Yay.", "Jolly good show.", "Good on 'ya.", "Nice work."]
+ compliment = ['Well done.', 'Congrats.', 'Woo!',
+ 'Yay.', 'Jolly good show.', "Good on 'ya.", 'Nice work.']
compliment.sample
end
def generate_github_description(warnings: nil, errors: nil)
if errors.empty? && warnings.empty?
@@ -164,22 +164,22 @@
end
def generate_comment(warnings: [], errors: [], messages: [], markdowns: [], previous_violations: {}, danger_id: 'danger')
require 'erb'
- md_template = File.join(Danger.gem_path, "lib/danger/comment_generators/github.md.erb")
+ md_template = File.join(Danger.gem_path, 'lib/danger/comment_generators/github.md.erb')
# erb: http://www.rrn.dk/rubys-erb-templating-system
# for the extra args: http://stackoverflow.com/questions/4632879/erb-template-removing-the-trailing-line
@tables = [
- table("Error", "no_entry_sign", errors, previous_violations),
- table("Warning", "warning", warnings, previous_violations),
- table("Message", "book", messages, previous_violations)
+ table('Error', 'no_entry_sign', errors, previous_violations),
+ table('Warning', 'warning', warnings, previous_violations),
+ table('Message', 'book', messages, previous_violations)
]
@markdowns = markdowns
@danger_id = danger_id
- return ERB.new(File.read(md_template), 0, "-").result(binding)
+ return ERB.new(File.read(md_template), 0, '-').result(binding)
end
def table(name, emoji, violations, all_previous_violations)
content = violations.map { |v| process_markdown(v) }.uniq
kind = table_kind_from_title(name)