only generate the one specific rule for single

parent 380e3914
Pipeline #31313 failed with stage
in 20 seconds
......@@ -20,13 +20,12 @@ end
desc 'Generate every single */**/Dangerfile'
task 'generate:single' do
contents = [
header,
lib_files_content
]
danger_files.each do |file|
contents << inlined_content(file)
contents = [
header,
lib_files_content,
inlined_content(file)
]
output_file = file.sub(%r{^src/}, 'rules/')
write_content(output_file, contents)
end
......
......@@ -8,27 +8,6 @@ def heredoc(text)
text.gsub(/ +/, ' ')
end
# --> src/git/commit_message_too_long/Dangerfile:
git
.commits
.select { |commit| commit.message.split(/\n/).first.length > 50 }
.each do |commit|
warn heredoc(
<<~TEXT
The commit #{commit.sha} `#{commit.message}` is too long. Please adhere \
to the following basic structural rules for creating a meaningful \
commit message: * Keep the first line of your commit message short (not more than 50 chars). \
Many tools such as Github and graphical git clients strip the subject after \
50 characters, and people working on the command line are better off with \
text which is not too wide.
* Keep the second line empty
* Use the rest of the commit message to describe the commit. There’s no \
restriction on the format nor the length, so be as descriptive and \
informative as possible.
TEXT
)
end
# --> src/git/fixup_commit/Dangerfile:
git
.commits
......
......@@ -8,36 +8,6 @@ def heredoc(text)
text.gsub(/ +/, ' ')
end
# --> src/git/commit_message_too_long/Dangerfile:
git
.commits
.select { |commit| commit.message.split(/\n/).first.length > 50 }
.each do |commit|
warn heredoc(
<<~TEXT
The commit #{commit.sha} `#{commit.message}` is too long. Please adhere \
to the following basic structural rules for creating a meaningful \
commit message: * Keep the first line of your commit message short (not more than 50 chars). \
Many tools such as Github and graphical git clients strip the subject after \
50 characters, and people working on the command line are better off with \
text which is not too wide.
* Keep the second line empty
* Use the rest of the commit message to describe the commit. There’s no \
restriction on the format nor the length, so be as descriptive and \
informative as possible.
TEXT
)
end
# --> src/git/fixup_commit/Dangerfile:
git
.commits
.select { |commit| commit.message =~ /^fixup! / }
.each do |commit|
warn "The commit #{commit.sha} `#{commit.message}` is a fixup commit. " \
'Please squash your commits before merging.'
end
# --> src/git/master_merge_commit/Dangerfile:
if git.commits.any? { |commit| commit.message =~ /^Merge branch 'master'/ }
warn 'Please rebase to get rid of the merge commits in this PR'
......
......@@ -8,41 +8,6 @@ def heredoc(text)
text.gsub(/ +/, ' ')
end
# --> src/git/commit_message_too_long/Dangerfile:
git
.commits
.select { |commit| commit.message.split(/\n/).first.length > 50 }
.each do |commit|
warn heredoc(
<<~TEXT
The commit #{commit.sha} `#{commit.message}` is too long. Please adhere \
to the following basic structural rules for creating a meaningful \
commit message: * Keep the first line of your commit message short (not more than 50 chars). \
Many tools such as Github and graphical git clients strip the subject after \
50 characters, and people working on the command line are better off with \
text which is not too wide.
* Keep the second line empty
* Use the rest of the commit message to describe the commit. There’s no \
restriction on the format nor the length, so be as descriptive and \
informative as possible.
TEXT
)
end
# --> src/git/fixup_commit/Dangerfile:
git
.commits
.select { |commit| commit.message =~ /^fixup! / }
.each do |commit|
warn "The commit #{commit.sha} `#{commit.message}` is a fixup commit. " \
'Please squash your commits before merging.'
end
# --> src/git/master_merge_commit/Dangerfile:
if git.commits.any? { |commit| commit.message =~ /^Merge branch 'master'/ }
warn 'Please rebase to get rid of the merge commits in this PR'
end
# --> src/git/wip_commit/Dangerfile:
git
.commits
......
......@@ -8,50 +8,6 @@ def heredoc(text)
text.gsub(/ +/, ' ')
end
# --> src/git/commit_message_too_long/Dangerfile:
git
.commits
.select { |commit| commit.message.split(/\n/).first.length > 50 }
.each do |commit|
warn heredoc(
<<~TEXT
The commit #{commit.sha} `#{commit.message}` is too long. Please adhere \
to the following basic structural rules for creating a meaningful \
commit message: * Keep the first line of your commit message short (not more than 50 chars). \
Many tools such as Github and graphical git clients strip the subject after \
50 characters, and people working on the command line are better off with \
text which is not too wide.
* Keep the second line empty
* Use the rest of the commit message to describe the commit. There’s no \
restriction on the format nor the length, so be as descriptive and \
informative as possible.
TEXT
)
end
# --> src/git/fixup_commit/Dangerfile:
git
.commits
.select { |commit| commit.message =~ /^fixup! / }
.each do |commit|
warn "The commit #{commit.sha} `#{commit.message}` is a fixup commit. " \
'Please squash your commits before merging.'
end
# --> src/git/master_merge_commit/Dangerfile:
if git.commits.any? { |commit| commit.message =~ /^Merge branch 'master'/ }
warn 'Please rebase to get rid of the merge commits in this PR'
end
# --> src/git/wip_commit/Dangerfile:
git
.commits
.select { |commit| commit.message =~ /\bWIP\b/ }
.each do |commit|
warn "The commit #{commit.sha} `#{commit.message}` is a WIP commit. " \
'Please cleanup your git history before merging.'
end
# --> src/merge_request/issue_reference/Dangerfile:
unless gitlab.mr_body =~ %r{/issues/\d+} || gitlab.mr_body =~ /#\d+/
warn heredoc(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment