Module: SharedAudits

Defined in:
brew/Library/Homebrew/utils/notability.rb

Class Method Summary collapse

Class Method Details

.bitbucket(user, repo) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'brew/Library/Homebrew/utils/notability.rb', line 45

def bitbucket(user, repo)
  api_url = "https://api.bitbucket.org/2.0/repositories/#{user}/#{repo}"
  out, _, status= curl_output("--request", "GET", api_url)
  return unless status.success?

   = JSON.parse(out)
  return if .nil?

  return "Uses deprecated mercurial support in Bitbucket" if ["scm"] == "hg"

  return "Bitbucket fork (not canonical repository)" unless ["parent"].nil?

  return "Bitbucket repository too new (<30 days old)" if Date.parse(["created_on"]) >= (Date.today - 30)

  forks_out, _, forks_status= curl_output("--request", "GET", "#{api_url}/forks")
  return unless forks_status.success?

  watcher_out, _, watcher_status= curl_output("--request", "GET", "#{api_url}/watchers")
  return unless watcher_status.success?

   = JSON.parse(forks_out)
  return if .nil?

   = JSON.parse(watcher_out)
  return if .nil?

  return if (["size"] < 30) && (["size"] < 75)

  "Bitbucket repository not notable enough (<30 forks and <75 watchers)"
end

.github(user, repo) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'brew/Library/Homebrew/utils/notability.rb', line 8

def github(user, repo)
  begin
     = GitHub.repository(user, repo)
  rescue GitHub::HTTPNotFoundError
    return
  end

  return if .nil?

  return "GitHub fork (not canonical repository)" if ["fork"]
  if (["forks_count"] < 30) && (["subscribers_count"] < 30) &&
     (["stargazers_count"] < 75)
    return "GitHub repository not notable enough (<30 forks, <30 watchers and <75 stars)"
  end

  return if Date.parse(["created_at"]) <= (Date.today - 30)

  "GitHub repository too new (<30 days old)"
end

.gitlab(user, repo) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'brew/Library/Homebrew/utils/notability.rb', line 28

def gitlab(user, repo)
  out, _, status= curl_output("--request", "GET", "https://gitlab.com/api/v4/projects/#{user}%2F#{repo}")
  return unless status.success?

   = JSON.parse(out)
  return if .nil?

  return "GitLab fork (not canonical repository)" if ["fork"]
  if (["forks_count"] < 30) && (["star_count"] < 75)
    return "GitLab repository not notable enough (<30 forks and <75 stars)"
  end

  return if Date.parse(["created_at"]) <= (Date.today - 30)

  "GitLab repository too new (<30 days old)"
end