Audit GitHub repository notability.

This stuff seems to be taken better when coming from a script rather
than from a human. Feel free to disagree about the specific numbers
chosen here.
This commit is contained in:
Mike McQuaid 2015-07-08 14:22:44 +01:00
parent 48df76dc89
commit 51a1792e7a
2 changed files with 25 additions and 0 deletions

View File

@ -422,6 +422,26 @@ class FormulaAuditor
end end
end end
def audit_github_repository
return unless @strict
regex = %r{https?://github.com/([^/]+)/([^/]+)/?.*}
_, user, repo = *regex.match(formula.stable.url)
_, user, repo = *regex.match(formula.homepage) unless user
return if !user || !repo
metadata = GitHub.repository(user, repo)
problem "GitHub fork (not canonical repository)" if metadata["fork"]
if (metadata["forks_count"] < 5) || (metadata["watchers_count"] < 5) ||
(metadata["stargazers_count"] < 10)
problem "GitHub repository not notable enough (<5 forks, <5 watchers and/or <10 stars)"
end
if (Date.parse(metadata["created_at"]) > (Date.today - 30))
problem "GitHub repository too new (<30 days old)"
end
end
def audit_specs def audit_specs
if head_only?(formula) && formula.tap.to_s.downcase != "homebrew/homebrew-head-only" if head_only?(formula) && formula.tap.to_s.downcase != "homebrew/homebrew-head-only"
problem "Head-only (no stable download)" problem "Head-only (no stable download)"
@ -831,6 +851,7 @@ class FormulaAuditor
audit_specs audit_specs
audit_desc audit_desc
audit_homepage audit_homepage
audit_github_repository
audit_deps audit_deps
audit_conflicts audit_conflicts
audit_options audit_options

View File

@ -399,6 +399,10 @@ module GitHub extend self
open(uri) { |json| json["items"] } open(uri) { |json| json["items"] }
end end
def repository(user, repo)
open(URI.parse("https://api.github.com/repos/#{user}/#{repo}")) { |j| j }
end
def build_query_string(query, qualifiers) def build_query_string(query, qualifiers)
s = "q=#{uri_escape(query)}+" s = "q=#{uri_escape(query)}+"
s << build_search_qualifier_string(qualifiers) s << build_search_qualifier_string(qualifiers)