aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/rubocops
diff options
context:
space:
mode:
authorGautham Goli2017-08-25 20:07:45 +0530
committerGautham Goli2017-08-26 18:06:00 +0530
commitd00c515dd8f9fced95a94ab373e0ee9bf5d74ac0 (patch)
treec282b20c364f05bb2435935a02241e0fe6e95bee /Library/Homebrew/rubocops
parenta9d63745ef9f89ebbd3080e20954f1de1fadad51 (diff)
downloadbrew-d00c515dd8f9fced95a94ab373e0ee9bf5d74ac0.tar.bz2
audit: Add previously unported GH patch audit rule in Patches cop
Diffstat (limited to 'Library/Homebrew/rubocops')
-rw-r--r--Library/Homebrew/rubocops/patches_cop.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/Library/Homebrew/rubocops/patches_cop.rb b/Library/Homebrew/rubocops/patches_cop.rb
index b27283382..7ee1a127a 100644
--- a/Library/Homebrew/rubocops/patches_cop.rb
+++ b/Library/Homebrew/rubocops/patches_cop.rb
@@ -25,12 +25,22 @@ module RuboCop
def patch_problems(patch)
patch_url = string_content(patch)
+ gh_patch_param_pattern = %r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)}
+ if regex_match_group(patch, gh_patch_param_pattern)
+ if patch_url !~ /\?full_index=\w+$/
+ problem <<-EOS.undent
+ GitHub patches should use the full_index parameter:
+ #{patch_url}?full_index=1
+ EOS
+ end
+ end
+
gh_patch_patterns = Regexp.union([%r{/raw\.github\.com/},
%r{gist\.github\.com/raw},
%r{gist\.github\.com/.+/raw},
%r{gist\.githubusercontent\.com/.+/raw}])
if regex_match_group(patch, gh_patch_patterns)
- unless patch_url =~ /[a-fA-F0-9]{40}/
+ if patch_url !~ /[a-fA-F0-9]{40}/
problem <<-EOS.undent.chomp
GitHub/Gist patches should specify a revision:
#{patch_url}