hubstats 0.3.17 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +0 -1
- data/CHANGELOG.markdown +10 -0
- data/MIT-LICENSE +3 -1
- data/README.md +2 -2
- data/app/assets/javascripts/hubstats/application.js +80 -24
- data/app/assets/javascripts/hubstats/pull_requests.js +35 -3
- data/app/assets/javascripts/hubstats/select2.js +8 -1
- data/app/assets/javascripts/hubstats/users.js +17 -5
- data/app/assets/stylesheets/hubstats/application.css +39 -1
- data/app/assets/stylesheets/hubstats/bootstrap.css +0 -6
- data/app/assets/stylesheets/hubstats/deploys.css +2 -0
- data/app/assets/stylesheets/hubstats/label.css +2 -0
- data/app/assets/stylesheets/hubstats/octicons.css.erb +2 -0
- data/app/assets/stylesheets/hubstats/pull_requests.css +2 -0
- data/app/controllers/hubstats/application_controller.rb +12 -4
- data/app/controllers/hubstats/base_controller.rb +8 -0
- data/app/controllers/hubstats/deploys_controller.rb +31 -8
- data/app/controllers/hubstats/events_controller.rb +11 -0
- data/app/controllers/hubstats/pull_requests_controller.rb +9 -1
- data/app/controllers/hubstats/repos_controller.rb +17 -3
- data/app/controllers/hubstats/users_controller.rb +15 -0
- data/app/models/hubstats/comment.rb +13 -5
- data/app/models/hubstats/deploy.rb +29 -6
- data/app/models/hubstats/label.rb +16 -4
- data/app/models/hubstats/pull_request.rb +44 -2
- data/app/models/hubstats/repo.rb +48 -4
- data/app/models/hubstats/user.rb +130 -32
- data/app/views/hubstats/deploys/index.html.erb +1 -3
- data/app/views/hubstats/deploys/show.html.erb +7 -2
- data/app/views/hubstats/partials/_comment-condensed.html.erb +3 -0
- data/app/views/hubstats/partials/_comment.html.erb +3 -0
- data/app/views/hubstats/partials/_deploy-condensed.html.erb +2 -2
- data/app/views/hubstats/partials/_deploy.html.erb +1 -1
- data/app/views/hubstats/partials/_footer.html.erb +22 -0
- data/app/views/hubstats/partials/_header.html.erb +18 -10
- data/app/views/hubstats/partials/_pull-condensed.html.erb +2 -0
- data/app/views/hubstats/partials/_pull.html.erb +2 -0
- data/app/views/hubstats/partials/_quick_addition_stats.html.erb +2 -0
- data/app/views/hubstats/partials/_quick_stats.html.erb +1 -0
- data/app/views/hubstats/partials/_repo.html.erb +2 -3
- data/app/views/hubstats/partials/_user-condensed.html.erb +4 -0
- data/app/views/hubstats/partials/_user.html.erb +4 -2
- data/app/views/hubstats/pull_requests/index.html.erb +6 -1
- data/app/views/hubstats/pull_requests/show.html.erb +5 -0
- data/app/views/hubstats/repos/dashboard.html.erb +6 -4
- data/app/views/hubstats/repos/show.html.erb +6 -1
- data/app/views/hubstats/tables/_comments-condensed.html.erb +2 -1
- data/app/views/hubstats/tables/_comments.html.erb +2 -1
- data/app/views/hubstats/tables/_deploys-condensed.html.erb +1 -0
- data/app/views/hubstats/tables/_deploys.html.erb +1 -0
- data/app/views/hubstats/tables/_grouped_deploys.html.erb +1 -0
- data/app/views/hubstats/tables/_grouped_pulls.html.erb +1 -0
- data/app/views/hubstats/tables/_pulls-condensed.html.erb +1 -0
- data/app/views/hubstats/tables/_pulls.html.erb +1 -0
- data/app/views/hubstats/tables/_repos-condensed.html.erb +1 -0
- data/app/views/hubstats/tables/_repos.html.erb +1 -0
- data/app/views/hubstats/tables/_users-condensed.html.erb +1 -0
- data/app/views/hubstats/tables/_users.html.erb +1 -1
- data/app/views/hubstats/users/index.html.erb +3 -2
- data/app/views/hubstats/users/show.html.erb +7 -1
- data/app/views/layouts/hubstats/application.html.erb +4 -4
- data/config/routes.rb +2 -1
- data/db/seeds.rb +41 -0
- data/hubstats.gemspec +1 -0
- data/lib/generators/hubstats/install_generator.rb +2 -1
- data/lib/hub_helper.rb +18 -0
- data/lib/hubstats.rb +0 -30
- data/lib/hubstats/events_handler.rb +25 -7
- data/lib/hubstats/github_api.rb +43 -15
- data/lib/hubstats/version.rb +1 -1
- data/lib/tasks/hubstats_tasks.rake +1 -0
- data/lib/tasks/populate_task.rake +2 -1
- data/spec/controllers/hubstats/deploys_controller_spec.rb +0 -3
- data/spec/controllers/hubstats/pull_requests_controller_spec.rb +3 -4
- data/spec/controllers/hubstats/repos_controller_spec.rb +4 -5
- data/spec/factories/comment.rb +2 -1
- data/spec/factories/deploys.rb +1 -0
- data/spec/factories/pull_requests.rb +1 -0
- data/spec/factories/repo.rb +1 -0
- data/spec/factories/users.rb +2 -1
- data/spec/lib/hubstats/github_api_spec.rb +5 -5
- metadata +41 -26
- data/date_range +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
<!-- Either say there are no users to show, or show all of the stat titles along with the stats/users -->
|
1
2
|
<% if @users.length > 0 %>
|
2
3
|
<div class="users">
|
3
4
|
<div class="row single-user header">
|
@@ -13,7 +14,6 @@
|
|
13
14
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
14
15
|
<a class="header desc" id="comments"> Comments <span class="octicon"></span></a>
|
15
16
|
</div>
|
16
|
-
<!-- Show the net additions instead of the additions and deletions separately -->
|
17
17
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
18
18
|
<a class="header desc" id="netadditions"> Net Additions <span class="octicon"></span></a>
|
19
19
|
</div>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<div class="container" id="user"%>
|
2
2
|
<div class="row"%>
|
3
3
|
<div class="col-lg-3">
|
4
|
+
|
5
|
+
<!-- Allow for filtering by repository or user -->
|
4
6
|
<div class="form-group">
|
5
7
|
<input class="select2-control" id="repos">
|
6
8
|
</input>
|
@@ -11,10 +13,9 @@
|
|
11
13
|
</div>
|
12
14
|
</div>
|
13
15
|
|
16
|
+
<!-- Show all of the users with their individual stats -->
|
14
17
|
<div class="col-lg-9">
|
15
|
-
|
16
18
|
<%= render 'hubstats/tables/users' %>
|
17
|
-
|
18
19
|
<div class="text-center">
|
19
20
|
<%= will_paginate @users, renderer: BootstrapPagination::Rails %>
|
20
21
|
</div>
|
@@ -1,10 +1,16 @@
|
|
1
1
|
<div class="container" id="repo">
|
2
2
|
<div class="row">
|
3
|
+
|
4
|
+
<!-- Title with the user's GitHub username -->
|
3
5
|
<h1 class="title text-center"><a href=<%=@user.html_url%>> <%= @user.login %></a> </h1>
|
6
|
+
|
7
|
+
<!-- Show all of the stats about the user -->
|
4
8
|
<%= render 'hubstats/partials/quick_stats' %>
|
5
9
|
</div>
|
10
|
+
|
6
11
|
<div class="row">
|
7
12
|
|
13
|
+
<!-- Show all of this user's merged pull requests in a "condensed" view -->
|
8
14
|
<div class="col-lg-6 col-md-5 col-sm-5 col-xs-5">
|
9
15
|
<h3> Pull Requests</h3>
|
10
16
|
<%= render 'hubstats/tables/pulls-condensed' %>
|
@@ -13,7 +19,7 @@
|
|
13
19
|
<% end %>
|
14
20
|
</div>
|
15
21
|
|
16
|
-
<!-- Show all of
|
22
|
+
<!-- Show all of this user's deploys in a "condensed" view -->
|
17
23
|
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
18
24
|
<h3> Deployments </h3>
|
19
25
|
<%= render 'hubstats/tables/deploys-condensed' %>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<!-- Show the header, format the entire page, and show all other pages below header -->
|
1
2
|
<!DOCTYPE html>
|
2
3
|
<html>
|
3
4
|
<head>
|
@@ -7,9 +8,8 @@
|
|
7
8
|
<%= csrf_meta_tags %>
|
8
9
|
</head>
|
9
10
|
<body>
|
10
|
-
|
11
|
-
<%=
|
12
|
-
<%=
|
13
|
-
|
11
|
+
<%= render 'hubstats/partials/header' %>
|
12
|
+
<%= yield %>
|
13
|
+
<%= render 'hubstats/partials/footer' %>
|
14
14
|
</body>
|
15
15
|
</html>
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Draw all of the routes that will be used in Hubstats
|
1
2
|
Hubstats::Engine.routes.draw do
|
2
3
|
root to: "pull_requests#index" # sets default root to be the pulls page
|
3
4
|
post "/handler" => "events#handler", :as => :handler
|
@@ -9,6 +10,6 @@ Hubstats::Engine.routes.draw do
|
|
9
10
|
get "/repos" => "repos#index", :as => :repos # route is for the repo filter on the pull request and deploys page
|
10
11
|
get "/:repo" => "repos#show", :as => :repo # routes to specific repo's stats
|
11
12
|
scope "/:repo", :as => :repo do
|
12
|
-
get '/pull/:id' => "pull_requests#show", :as => :pull
|
13
|
+
get '/pull/:id' => "pull_requests#show", :as => :pull # routes to the specific repo's pull id
|
13
14
|
end
|
14
15
|
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# List of deploys with the little pieces of code that can be used to populate the deploys database.
|
2
|
+
# All of the deploy information is fake. The repo names are a few of Sport Ngin's open source repos on GitHub.
|
3
|
+
|
4
|
+
# format of each deploy:
|
5
|
+
# [git sha, repository name, date and time of deployment, user_id, string of associated PR ids]
|
6
|
+
deploy_list = [
|
7
|
+
["c1a2b37", "sportngin/active_zuora", "2010-12-03 18:00:00 -0500", 7562793, "15140096, 33691392, 33364992"],
|
8
|
+
["i32jb9e", "sportngin/active_zuora", "2013-05-26 17:00:00 -0500", 61645, "9334784, 1734656"],
|
9
|
+
["w19dkid", "sportngin/active_zuora", "2011-08-21 02:00:00 -0500", 47206, "23174656, 1487616, 4963840, 1231872, 10871808"],
|
10
|
+
["n83b20c", "sportngin/homebrew-homebrew", "2014-11-08 05:00:00 -0500", 1319495, "2484224, 1239808"],
|
11
|
+
["c92kda8", "sportngin/delayed_job_loner", "2010-11-10 12:00:00 -0500", 314014, "19986432, 23796481, 21961729"],
|
12
|
+
["b91k9dk", "sportngin/passenger", "2010-02-18 11:00:00 -0500", 1557830, "5870592"],
|
13
|
+
["ieoq630", "sportngin/strong_parameters", "2012-04-14 11:00:00 -0500", 142288, "31363329, 7326209"],
|
14
|
+
["c1a2b38", "sportngin/objective-ci", "2013-12-03 18:01:00 -0500", 7562793, "16291842, 6195970"],
|
15
|
+
["c1a2b39", "sportngin/objective-ci", "2014-12-04 13:00:00 -0500", 43369, "16448002, 27447298"],
|
16
|
+
["29xkdi9", "sportngin/objective-ci", "2015-01-18 14:00:00 -0500", 3011, "6396163"],
|
17
|
+
["9xkdjqk", "sportngin/objective-ci", "2015-03-21 07:00:00 -0500", 1352, "18483204"],
|
18
|
+
["is93h1n", "sportngin/safe_cookies", "2014-12-31 09:00:00 -0500", 6384174, "3274757, 5708038"],
|
19
|
+
["kdiq13j", "sportngin/safe_cookies", "2013-11-17 04:00:00 -0500", 6902485, "10444039, 11917574"],
|
20
|
+
["ciap1kd", "sportngin/passenger", "2010-08-29 01:00:00 -0500", 7231089, "25856007"],
|
21
|
+
["iek9s0d", "sportngin/safe_cookies", "2015-05-13 12:00:00 -0500", 4095632, "4534280, 3557640"],
|
22
|
+
["918240d", "sportngin/make-resourceful", "2015-04-01 03:00:00 -0500", 5577837, "27117320, 1967369, 20911625"],
|
23
|
+
["dis8203", "sportngin/make-resourceful", "2015-02-27 08:00:00 -0500", 5167099, "9657609, 4745225, 35976969, 5180938"],
|
24
|
+
["2kd9sac", "sportngin/passenger", "2015-05-26 03:00:00 -0500", 7452482, "23303693, 2990349"],
|
25
|
+
["0slqi83", "sportngin/make-resourceful", "2015-05-27 13:00:00 -0500", 4240287, "34394381"],
|
26
|
+
["c92k102", "sportngin/passenger", "2015-05-27 12:00:00 -0500", 9447923, "25449231"]
|
27
|
+
]
|
28
|
+
|
29
|
+
# Public - Looks into the repo database to return the id of the repo that matches the repo name.
|
30
|
+
#
|
31
|
+
# repo_name - the name of the repo
|
32
|
+
#
|
33
|
+
# Returns - the id of the repo
|
34
|
+
def replace_name_with_id (repo_name)
|
35
|
+
return Hubstats::Repo.where(full_name: repo_name).first.id.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
# Add each deploy to the deploy database one at a time.
|
39
|
+
deploy_list.each do |git_revision, repo_name, deployed_at, user_id, pull_request_ids|
|
40
|
+
Hubstats::Deploy.create(git_revision: git_revision, repo_id: replace_name_with_id(repo_name), deployed_at: deployed_at, user_id: user_id, pull_request_ids: pull_request_ids)
|
41
|
+
end
|
data/hubstats.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "octokit", "~> 3.2"
|
21
21
|
s.add_dependency "will_paginate-bootstrap"
|
22
22
|
s.add_dependency "select2-rails", "3.5.9"
|
23
|
+
s.add_dependency "bootstrap-datepicker-rails", "~> 1.4.0"
|
23
24
|
|
24
25
|
s.add_development_dependency "rspec-rails",'~> 3.0.0.beta'
|
25
26
|
s.add_development_dependency "shoulda-matchers", "~> 2.6"
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Hubstats
|
2
2
|
class InstallGenerator < ::Rails::Generators::Base
|
3
3
|
|
4
|
+
# Copies the octokit.example.yml when 'rails generate hubstats:install' is run on the command line
|
4
5
|
source_root File.expand_path('../', __FILE__)
|
5
6
|
def octokit_initializer
|
6
7
|
copy_file "octokit.example.yml", "#{Rails.root}/config/octokit.yml"
|
7
8
|
end
|
8
9
|
|
9
10
|
end
|
10
|
-
end
|
11
|
+
end
|
data/lib/hub_helper.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
module HubHelper
|
2
|
+
|
3
|
+
# Public - Gets the PR number from the comment
|
4
|
+
#
|
5
|
+
# comment - the comment that we will get the PR number from
|
6
|
+
#
|
7
|
+
# Returns - either the PR number or nil
|
2
8
|
def self.get_pull_number(comment)
|
3
9
|
if comment[:pull_request]
|
4
10
|
return comment[:pull_request][:number]
|
@@ -11,6 +17,13 @@ module HubHelper
|
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
20
|
+
# Public - Sets the comment's repo_id, pull_number, and type.
|
21
|
+
#
|
22
|
+
# comment - the comment that will be updated
|
23
|
+
# repo_id - the id of the repo that the comment belongs to
|
24
|
+
# kind - the type of comment (pull request, issue, or commit)
|
25
|
+
#
|
26
|
+
# Returns - the PR with the new repository
|
14
27
|
def self.comment_setup(comment, repo_id, kind)
|
15
28
|
comment[:repo_id] = repo_id
|
16
29
|
comment[:pull_number] = get_pull_number(comment)
|
@@ -18,6 +31,11 @@ module HubHelper
|
|
18
31
|
return comment
|
19
32
|
end
|
20
33
|
|
34
|
+
# Public - Sets the PR's repository.
|
35
|
+
#
|
36
|
+
# pull_request - the PR that is passed in
|
37
|
+
#
|
38
|
+
# Returns - the PR with the new repository
|
21
39
|
def self.pull_setup(pull_request)
|
22
40
|
pull_request[:repository] = pull_request[:base][:repo]
|
23
41
|
return pull_request
|
data/lib/hubstats.rb
CHANGED
@@ -5,35 +5,5 @@ require "hubstats/events_handler"
|
|
5
5
|
require "active_support/core_ext/numeric"
|
6
6
|
require "hubstats/config"
|
7
7
|
|
8
|
-
|
9
8
|
module Hubstats
|
10
|
-
|
11
|
-
DATE_RANGE_ARRAY = [
|
12
|
-
{
|
13
|
-
display_value: "Today",
|
14
|
-
date: 1.day
|
15
|
-
},{
|
16
|
-
display_value: "One Week",
|
17
|
-
date: 1.week
|
18
|
-
},{
|
19
|
-
display_value: "Two Weeks",
|
20
|
-
date: 2.weeks
|
21
|
-
},{
|
22
|
-
display_value: "One Month",
|
23
|
-
date: 4.weeks
|
24
|
-
},{
|
25
|
-
display_value: "Three Months",
|
26
|
-
date: 12.weeks
|
27
|
-
},{
|
28
|
-
display_value: "Six Months",
|
29
|
-
date: 24.weeks
|
30
|
-
},{
|
31
|
-
display_value: "All Time",
|
32
|
-
date: 520.weeks
|
33
|
-
}
|
34
|
-
]
|
35
|
-
|
36
|
-
def self.config
|
37
|
-
@@config ||= Hubstats::Config.parse
|
38
|
-
end
|
39
9
|
end
|
@@ -1,19 +1,30 @@
|
|
1
1
|
module Hubstats
|
2
2
|
class EventsHandler
|
3
3
|
|
4
|
+
# Public - Processes comments and PRs
|
5
|
+
#
|
6
|
+
# payload - the data that we will be processing
|
7
|
+
# type - the type of data that payload is
|
8
|
+
#
|
9
|
+
# Returns - nothing
|
4
10
|
def route(payload, type)
|
5
11
|
case type
|
6
12
|
when "issue_comment", "IssueCommentEvent"
|
7
|
-
comment_processor(payload,"Issue")
|
13
|
+
comment_processor(payload, "Issue")
|
8
14
|
when "commit_comment", "CommitCommentEvent"
|
9
|
-
comment_processor(payload,"Commit")
|
15
|
+
comment_processor(payload, "Commit")
|
10
16
|
when "pull_request", "PullRequestEvent"
|
11
17
|
pull_processor(payload)
|
12
18
|
when "pull_request_review_comment", "PullRequestReviewCommentEvent"
|
13
|
-
comment_processor(payload,"PullRequest")
|
19
|
+
comment_processor(payload, "PullRequest")
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
23
|
+
# Public - Gets the information for the new PR, makes the new PR, grabs the labels, and makes new labels
|
24
|
+
#
|
25
|
+
# payload - the information that we will use to get data off of
|
26
|
+
#
|
27
|
+
# Returns - nothing, but makes the new PR and adds appropriate labels
|
17
28
|
def pull_processor(payload)
|
18
29
|
pull_request = payload[:pull_request]
|
19
30
|
pull_request[:repository] = payload[:repository]
|
@@ -23,16 +34,24 @@ module Hubstats
|
|
23
34
|
new_pull.add_labels(labels)
|
24
35
|
end
|
25
36
|
|
26
|
-
|
37
|
+
# Public - Gets the information for the new comment and updates it
|
38
|
+
#
|
39
|
+
# payload - the information that we will use to get data off of
|
40
|
+
#
|
41
|
+
# Returns - nothing, but updates the comment
|
42
|
+
def comment_processor(payload, kind)
|
27
43
|
comment = payload[:comment]
|
28
44
|
comment[:kind] = kind
|
29
45
|
comment[:repo_id] = payload[:repository][:id]
|
30
46
|
comment[:pull_number] = get_pull_number(payload)
|
31
|
-
|
32
47
|
Hubstats::Comment.create_or_update(comment.with_indifferent_access)
|
33
48
|
end
|
34
49
|
|
35
|
-
#
|
50
|
+
# Public - Grabs the PR number off of any of the various places it can be
|
51
|
+
#
|
52
|
+
# payload - the thing that we will use to try to attain the PR number
|
53
|
+
#
|
54
|
+
# Returns - the PR number
|
36
55
|
def get_pull_number(payload)
|
37
56
|
if payload[:pull_request]
|
38
57
|
return payload[:pull_request][:number]
|
@@ -44,6 +63,5 @@ module Hubstats
|
|
44
63
|
return nil
|
45
64
|
end
|
46
65
|
end
|
47
|
-
|
48
66
|
end
|
49
67
|
end
|
data/lib/hubstats/github_api.rb
CHANGED
@@ -4,7 +4,12 @@ module Hubstats
|
|
4
4
|
|
5
5
|
cattr_accessor :auth_info
|
6
6
|
|
7
|
-
|
7
|
+
# Public - configures the information needed to receive webhooks from GitHub
|
8
|
+
#
|
9
|
+
# options - the options to be passed in or an empty hash
|
10
|
+
#
|
11
|
+
# Returns - the configured auth_info
|
12
|
+
def self.configure(options = {})
|
8
13
|
@@auth_info = {}
|
9
14
|
if access_token = ENV['GITHUB_API_TOKEN'] || options["access_token"]
|
10
15
|
@@auth_info[:access_token] = access_token
|
@@ -15,30 +20,35 @@ module Hubstats
|
|
15
20
|
@@auth_info
|
16
21
|
end
|
17
22
|
|
18
|
-
|
23
|
+
# Public - Checks that the options passed in are valid and configured correctly
|
24
|
+
#
|
25
|
+
# options - the options to be checked or an empty hash
|
26
|
+
#
|
27
|
+
# Returns - the new configured info
|
28
|
+
def self.client(options = {})
|
19
29
|
configure(Hubstats.config.github_auth) if @@auth_info.nil?
|
20
30
|
ent = Octokit::Client.new(@@auth_info.merge(options))
|
21
31
|
ent.user #making sure it was configured properly
|
22
32
|
return ent
|
23
33
|
end
|
24
34
|
|
25
|
-
# Public
|
35
|
+
# Public - Gets all of a specific kind from a repo, and processes them.
|
26
36
|
#
|
27
37
|
# repo_name - the name of a repo
|
28
38
|
# kind - a kind of object (pull,comment)
|
29
39
|
# options - any possible option a particular kind of object
|
30
40
|
#
|
31
41
|
# Returns an array of that particular kind
|
32
|
-
def self.inline(repo_name, kind, options={})
|
42
|
+
def self.inline(repo_name, kind, options = {})
|
33
43
|
path = ["repos",repo_name,kind].join('/')
|
34
|
-
octo = client({:auto_paginate => true
|
44
|
+
octo = client({:auto_paginate => true})
|
35
45
|
octo.paginate(path, options) do |data, last_response|
|
36
46
|
last_response.data.each{|v| route(v,kind,repo_name)}.clear
|
37
47
|
wait_limit(1,octo.rate_limit)
|
38
48
|
end.each{|v| route(v,kind,repo_name)}.clear
|
39
49
|
end
|
40
50
|
|
41
|
-
# Public
|
51
|
+
# Public - Gets repos found in configuration file
|
42
52
|
#
|
43
53
|
# Returns - an array of github repo objects
|
44
54
|
def self.get_repos
|
@@ -53,7 +63,9 @@ module Hubstats
|
|
53
63
|
repos
|
54
64
|
end
|
55
65
|
|
56
|
-
# Public
|
66
|
+
# Public - Gets extra information on pull requests, e.g size, additions ...
|
67
|
+
#
|
68
|
+
# Returns - nothing
|
57
69
|
def self.update_pulls
|
58
70
|
grab_size = 250
|
59
71
|
begin
|
@@ -66,7 +78,6 @@ module Hubstats
|
|
66
78
|
pr = client.pull_request(repo.full_name, pull.number)
|
67
79
|
Hubstats::PullRequest.create_or_update(HubHelper.pull_setup(pr))
|
68
80
|
end
|
69
|
-
|
70
81
|
wait_limit(grab_size,client.rate_limit)
|
71
82
|
end
|
72
83
|
puts "All Pull Requests are up to date"
|
@@ -76,6 +87,11 @@ module Hubstats
|
|
76
87
|
end
|
77
88
|
end
|
78
89
|
|
90
|
+
# Public - Makes a new webhook from a repository
|
91
|
+
#
|
92
|
+
# repo - the repository that is attempting to have a hook made with
|
93
|
+
#
|
94
|
+
# Returns - the hook and a message (or just a message and no hook)
|
79
95
|
def self.create_hook(repo)
|
80
96
|
begin
|
81
97
|
client.create_hook(
|
@@ -106,7 +122,7 @@ module Hubstats
|
|
106
122
|
end
|
107
123
|
end
|
108
124
|
|
109
|
-
# Public
|
125
|
+
# Public - Delete webhook from github repository
|
110
126
|
#
|
111
127
|
# repo - a repo github object
|
112
128
|
# old_endpoint - A string of the previous endpoint
|
@@ -125,7 +141,7 @@ module Hubstats
|
|
125
141
|
end
|
126
142
|
end
|
127
143
|
|
128
|
-
# Public
|
144
|
+
# Public - updates a hook if it exists, otherwise creates one
|
129
145
|
#
|
130
146
|
# repo - a repo github object
|
131
147
|
# old_endpoint - A string of the previous endpoint
|
@@ -136,7 +152,7 @@ module Hubstats
|
|
136
152
|
create_hook(repo)
|
137
153
|
end
|
138
154
|
|
139
|
-
# Public
|
155
|
+
# Public - gets labels for a particular label
|
140
156
|
#
|
141
157
|
# repo - a repo github object
|
142
158
|
#
|
@@ -153,7 +169,7 @@ module Hubstats
|
|
153
169
|
labels
|
154
170
|
end
|
155
171
|
|
156
|
-
# Public
|
172
|
+
# Public - gets the label for a given pull request
|
157
173
|
#
|
158
174
|
# repo_name - a the repo_name
|
159
175
|
# pull_request_number - the number of the pull_request you want labels of
|
@@ -164,7 +180,7 @@ module Hubstats
|
|
164
180
|
issue[:labels]
|
165
181
|
end
|
166
182
|
|
167
|
-
# Public
|
183
|
+
# Public - Gets all the labels for a repo, adds all labels to a pull
|
168
184
|
#
|
169
185
|
# repo - the particular repository, you want to add labels to
|
170
186
|
def self.add_labels(repo)
|
@@ -173,13 +189,26 @@ module Hubstats
|
|
173
189
|
end
|
174
190
|
end
|
175
191
|
|
176
|
-
|
192
|
+
# Public - Puts the process to sleep if there is a "timeout" before continuing
|
193
|
+
#
|
194
|
+
# grab_size - the amount of data that is being attempted to grab
|
195
|
+
# rate_limit - the amount of time to wait to grab data
|
196
|
+
#
|
197
|
+
# Returns - nothing
|
198
|
+
def self.wait_limit(grab_size, rate_limit)
|
177
199
|
if rate_limit.remaining < grab_size
|
178
200
|
puts "Hit Github rate limit, waiting #{Time.at(rate_limit.resets_in).utc.strftime("%H:%M:%S")} to get more"
|
179
201
|
sleep(rate_limit.resets_in)
|
180
202
|
end
|
181
203
|
end
|
182
204
|
|
205
|
+
# Public - Routes to the correst setup methods to be used to update or create comments or PRs
|
206
|
+
#
|
207
|
+
# object - the new thing to be updated or created
|
208
|
+
# kind - the type of thing (pull comment, issue comment, normal comment, pull, or issue)
|
209
|
+
# repo_name - the name of the repository to which object belongs (optional)
|
210
|
+
#
|
211
|
+
# Returns - nothing, but does update the object
|
183
212
|
def self.route(object, kind, repo_name = nil)
|
184
213
|
if kind == "pulls/comments"
|
185
214
|
repo = Hubstats::Repo.where(full_name: repo_name).first
|
@@ -202,4 +231,3 @@ module Hubstats
|
|
202
231
|
end
|
203
232
|
end
|
204
233
|
end
|
205
|
-
|