-
Notifications
You must be signed in to change notification settings - Fork 204
/
Dangerfile
38 lines (31 loc) · 2.05 KB
/
Dangerfile
1
2
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
pr_author = github.pr_author
# Message the user
message "Hi @#{pr_author} thank you for your submission at Fossasia's GCI 2017 website. Please correct any issues above, if any."
# include link unless provided.
markdown ":link: Maintainers: @#{pr_author} did not provide a live link, one can be found at https://#{pr_author}.github.io/gci17.fossasia.org" unless github.pr_body.include? 'http'
# Check if a Pull Request is mergeable and warn if you have merge issues
can_merge = github.pr_json['mergeable']
warn('This Pull Request appears to have merge errors. Please check CONTRIBUTING.md for help solving that.', sticky: false) unless can_merge
# Check for Pull Request description
warn 'Please do not remove the Pull Request template. Please add it back (see `.github/PULL_REQUEST_TEMPLATE.md`)' if github.pr_body.size < 24
warn 'Please be sure to replace the text "Replace this with your change description" with a summary of your change.' if github.pr_body.include?('- Replace this with your change description')
warn 'Please mark all the checkboxes.' if github.pr_body.include? '- [ ]'
# Warn if there is [WIP] in the title
warn 'Pull Request is classified as Work in Progress' if github.pr_title.include? '[WIP]'
# Warn the user to squash commits
warn "You have more than one commit! Please squash them. If you need help, check CONTRIBUTING.md. Mentor note: If you're going to merge this, use the Github 'Squash and merge' function (check mantainers.md)." if git.commits.size > 1
# Check if the PR uses dos (CRLF line-endings) and fail the build
git.modified_files.each do |file|
crlf = false
next if git.deleted_files.include? file
next if file =~ /.jpg|.png|.gif|.ico/i
File.open(File.expand_path(file), 'r').readlines.each do |line|
if line =~ /^.+?\r\n$/u
crlf = true
break
end
end
fail "File \"#{file}\" uses DOS line-endings (CRLF -- Carriage Return (`^M` in your diff) followed by a Line Feed), and not Unix line-endings (line-feeds). Please fix this file so it uses unix line-endings (line-feeds)." if crlf
end