2016-12-05 20:51:55 +01:00
message "Hi @#{github.pr_author} thank you for your submission at Awesome-Awesomeness. Be sure that you haven't got any errors below this. For any questions, ping @m1guelpf"
2016-12-05 20:10:31 +01:00
#Check for changes to README.md
has_readme_changes = git.modified_files.include?("README.md")
2016-12-05 20:54:06 +01:00
can_merge = github.pr_json["mergeable"]
2016-12-05 20:55:05 +01:00
warn("This PR cannot be merged yet.", sticky: false) unless can_merge
2016-12-05 20:10:31 +01:00
# Ensure there is a summary for a pull request
fail 'Please provide a summary in the Pull Request description' if github.pr_body.length < 5
# Warn if PR guideline boxes are not checked.
2016-12-05 20:44:32 +01:00
fail 'Please check PR guidelines and check the boxes.' if github.pr_body.include? '- [ ]'
2016-12-05 20:32:12 +01:00
# Warn the user if pull request fields remain unchanged
2016-12-05 20:44:32 +01:00
fail 'Please replace **[Insert URL to the list here.]** with the URL to the list.' if github.pr_body.include? '**[Insert URL to the list here.]**'
fail 'Please replace **[Explain what this list is about and why it should be included here.]** with an explanation of why we should include this list.' if github.pr_body.include? '**[Explain what this list is about and why it should be included here.]**'
2016-12-05 20:10:31 +01:00
# Warn if pull request is not updated
2016-12-05 20:44:32 +01:00
fail 'Please update the Pull Request title to contain the script name' if github.pr_title.include? 'Update README.md'
2016-12-05 20:49:11 +01:00
# Warn if there is [WIP] in the title
warn "PR is classed as Work in Progress" if github.pr_title.include? "[WIP]"
2016-12-05 20:10:31 +01:00
# Warn when there are merge commits in the diff
2016-12-05 20:44:54 +01:00
fail 'Please rebase to get rid of the merge commits in this Pull Request' if git.commits.any? { |c| c.message =~ /^Merge branch 'master'/ }
2016-12-05 20:10:31 +01:00
# Check links
if has_readme_changes
require 'json'
results = File.read 'ab-results-temp.md-markdown-table.json'
j = JSON.parse results
if j['error']==true
fail j['title']
markdown j['message']
end
end
2016-12-06 10:22:42 +01:00
if has_readme_changes
require 'rubygems'
require 'json'
require 'octokit'
2016-12-06 10:23:16 +01:00
client = Octokit::Client.new(:access_token => DANGER_GITHUB_API_TOKEN)
2016-12-06 10:22:42 +01:00
user = client.user
user.login
data = JSON.parse(json)
2016-12-06 10:27:32 +01:00
puts data
puts data['number']
2016-12-06 10:22:42 +01:00
Octokit.add_labels_to_an_issue("bayandin/awesome-awesomeness", data['number'], ['Changes Required'])