github_api2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +770 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api2/api/actions.rb +60 -0
- data/lib/github_api2/api/arguments.rb +253 -0
- data/lib/github_api2/api/config/property.rb +30 -0
- data/lib/github_api2/api/config/property_set.rb +120 -0
- data/lib/github_api2/api/config.rb +105 -0
- data/lib/github_api2/api/factory.rb +33 -0
- data/lib/github_api2/api.rb +398 -0
- data/lib/github_api2/authorization.rb +75 -0
- data/lib/github_api2/client/activity/events.rb +233 -0
- data/lib/github_api2/client/activity/feeds.rb +50 -0
- data/lib/github_api2/client/activity/notifications.rb +181 -0
- data/lib/github_api2/client/activity/starring.rb +130 -0
- data/lib/github_api2/client/activity/watching.rb +176 -0
- data/lib/github_api2/client/activity.rb +31 -0
- data/lib/github_api2/client/authorizations/app.rb +98 -0
- data/lib/github_api2/client/authorizations.rb +142 -0
- data/lib/github_api2/client/emojis.rb +19 -0
- data/lib/github_api2/client/gists/comments.rb +100 -0
- data/lib/github_api2/client/gists.rb +289 -0
- data/lib/github_api2/client/git_data/blobs.rb +51 -0
- data/lib/github_api2/client/git_data/commits.rb +101 -0
- data/lib/github_api2/client/git_data/references.rb +150 -0
- data/lib/github_api2/client/git_data/tags.rb +95 -0
- data/lib/github_api2/client/git_data/trees.rb +113 -0
- data/lib/github_api2/client/git_data.rb +31 -0
- data/lib/github_api2/client/gitignore.rb +57 -0
- data/lib/github_api2/client/issues/assignees.rb +77 -0
- data/lib/github_api2/client/issues/comments.rb +146 -0
- data/lib/github_api2/client/issues/events.rb +50 -0
- data/lib/github_api2/client/issues/labels.rb +189 -0
- data/lib/github_api2/client/issues/milestones.rb +146 -0
- data/lib/github_api2/client/issues.rb +248 -0
- data/lib/github_api2/client/markdown.rb +62 -0
- data/lib/github_api2/client/meta.rb +19 -0
- data/lib/github_api2/client/orgs/hooks.rb +182 -0
- data/lib/github_api2/client/orgs/members.rb +142 -0
- data/lib/github_api2/client/orgs/memberships.rb +131 -0
- data/lib/github_api2/client/orgs/projects.rb +57 -0
- data/lib/github_api2/client/orgs/teams.rb +407 -0
- data/lib/github_api2/client/orgs.rb +127 -0
- data/lib/github_api2/client/projects/cards.rb +158 -0
- data/lib/github_api2/client/projects/columns.rb +146 -0
- data/lib/github_api2/client/projects.rb +83 -0
- data/lib/github_api2/client/pull_requests/comments.rb +140 -0
- data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api2/client/pull_requests.rb +195 -0
- data/lib/github_api2/client/repos/branches/protections.rb +75 -0
- data/lib/github_api2/client/repos/branches.rb +48 -0
- data/lib/github_api2/client/repos/collaborators.rb +84 -0
- data/lib/github_api2/client/repos/comments.rb +125 -0
- data/lib/github_api2/client/repos/commits.rb +80 -0
- data/lib/github_api2/client/repos/contents.rb +263 -0
- data/lib/github_api2/client/repos/deployments.rb +138 -0
- data/lib/github_api2/client/repos/downloads.rb +62 -0
- data/lib/github_api2/client/repos/forks.rb +50 -0
- data/lib/github_api2/client/repos/hooks.rb +214 -0
- data/lib/github_api2/client/repos/invitations.rb +41 -0
- data/lib/github_api2/client/repos/keys.rb +104 -0
- data/lib/github_api2/client/repos/merging.rb +47 -0
- data/lib/github_api2/client/repos/pages.rb +48 -0
- data/lib/github_api2/client/repos/projects.rb +62 -0
- data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api2/client/repos/releases/assets.rb +136 -0
- data/lib/github_api2/client/repos/releases/tags.rb +24 -0
- data/lib/github_api2/client/repos/releases.rb +189 -0
- data/lib/github_api2/client/repos/statistics.rb +89 -0
- data/lib/github_api2/client/repos/statuses.rb +91 -0
- data/lib/github_api2/client/repos.rb +473 -0
- data/lib/github_api2/client/say.rb +25 -0
- data/lib/github_api2/client/scopes.rb +46 -0
- data/lib/github_api2/client/search/legacy.rb +111 -0
- data/lib/github_api2/client/search.rb +133 -0
- data/lib/github_api2/client/users/emails.rb +65 -0
- data/lib/github_api2/client/users/followers.rb +115 -0
- data/lib/github_api2/client/users/keys.rb +104 -0
- data/lib/github_api2/client/users.rb +117 -0
- data/lib/github_api2/client.rb +77 -0
- data/lib/github_api2/configuration.rb +70 -0
- data/lib/github_api2/connection.rb +82 -0
- data/lib/github_api2/constants.rb +61 -0
- data/lib/github_api2/core_ext/array.rb +25 -0
- data/lib/github_api2/core_ext/hash.rb +91 -0
- data/lib/github_api2/deprecation.rb +39 -0
- data/lib/github_api2/error/client_error.rb +89 -0
- data/lib/github_api2/error/service_error.rb +223 -0
- data/lib/github_api2/error.rb +32 -0
- data/lib/github_api2/ext/faraday.rb +40 -0
- data/lib/github_api2/mash.rb +7 -0
- data/lib/github_api2/middleware.rb +37 -0
- data/lib/github_api2/mime_type.rb +33 -0
- data/lib/github_api2/normalizer.rb +23 -0
- data/lib/github_api2/null_encoder.rb +25 -0
- data/lib/github_api2/page_iterator.rb +138 -0
- data/lib/github_api2/page_links.rb +63 -0
- data/lib/github_api2/paged_request.rb +42 -0
- data/lib/github_api2/pagination.rb +115 -0
- data/lib/github_api2/parameter_filter.rb +35 -0
- data/lib/github_api2/params_hash.rb +115 -0
- data/lib/github_api2/rate_limit.rb +25 -0
- data/lib/github_api2/request/basic_auth.rb +36 -0
- data/lib/github_api2/request/jsonize.rb +54 -0
- data/lib/github_api2/request/oauth2.rb +45 -0
- data/lib/github_api2/request/verbs.rb +63 -0
- data/lib/github_api2/request.rb +84 -0
- data/lib/github_api2/response/atom_parser.rb +22 -0
- data/lib/github_api2/response/follow_redirects.rb +140 -0
- data/lib/github_api2/response/header.rb +87 -0
- data/lib/github_api2/response/jsonize.rb +28 -0
- data/lib/github_api2/response/mashify.rb +24 -0
- data/lib/github_api2/response/raise_error.rb +22 -0
- data/lib/github_api2/response/xmlize.rb +28 -0
- data/lib/github_api2/response.rb +48 -0
- data/lib/github_api2/response_wrapper.rb +161 -0
- data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api2/utils/url.rb +63 -0
- data/lib/github_api2/validations/format.rb +26 -0
- data/lib/github_api2/validations/presence.rb +32 -0
- data/lib/github_api2/validations/required.rb +21 -0
- data/lib/github_api2/validations/token.rb +41 -0
- data/lib/github_api2/validations.rb +22 -0
- data/lib/github_api2/version.rb +5 -0
- data/lib/github_api2.rb +92 -0
- metadata +363 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
require_relative '../../api'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
class Client::Projects::Columns < API
|
|
8
|
+
REQUIRED_COLUMN_PARAMS = %w(name).freeze
|
|
9
|
+
REQUIRED_MOVE_COLUMN_PARAMS = %w(position).freeze
|
|
10
|
+
|
|
11
|
+
# List a project's columns
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# github = Github.new
|
|
15
|
+
# github.projects.columns.list :project_id
|
|
16
|
+
#
|
|
17
|
+
# @see https://developer.github.com/v3/projects/columns/#list-project-columns
|
|
18
|
+
#
|
|
19
|
+
# @api public
|
|
20
|
+
def list(*args)
|
|
21
|
+
arguments(args, required: [:project_id])
|
|
22
|
+
params = arguments.params
|
|
23
|
+
|
|
24
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
25
|
+
|
|
26
|
+
response = get_request("/projects/#{arguments.project_id}/columns", params)
|
|
27
|
+
|
|
28
|
+
return response unless block_given?
|
|
29
|
+
response.each { |el| yield el }
|
|
30
|
+
end
|
|
31
|
+
alias all list
|
|
32
|
+
|
|
33
|
+
# Get a project columns
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# github = Github.new
|
|
37
|
+
# github.projects.columns.get :column_id
|
|
38
|
+
#
|
|
39
|
+
# @see https://developer.github.com/v3/projects/columns/#get-a-project-column
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
def get(*args)
|
|
43
|
+
arguments(args, required: [:column_id])
|
|
44
|
+
params = arguments.params
|
|
45
|
+
|
|
46
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
47
|
+
|
|
48
|
+
get_request("/projects/columns/#{arguments.column_id}", params)
|
|
49
|
+
end
|
|
50
|
+
alias find get
|
|
51
|
+
|
|
52
|
+
# Create a project column
|
|
53
|
+
#
|
|
54
|
+
# @param [Hash] params
|
|
55
|
+
# @option params [String] :name
|
|
56
|
+
# Required. The name of the column.
|
|
57
|
+
#
|
|
58
|
+
# @example
|
|
59
|
+
# github = Github.new
|
|
60
|
+
# github.projects.columns.create :project_id, name: 'column-name'
|
|
61
|
+
#
|
|
62
|
+
# @see https://developer.github.com/v3/projects/columns/#create-a-project-column
|
|
63
|
+
#
|
|
64
|
+
# @api public
|
|
65
|
+
def create(*args)
|
|
66
|
+
arguments(args, required: [:project_id]) do
|
|
67
|
+
assert_required REQUIRED_COLUMN_PARAMS
|
|
68
|
+
end
|
|
69
|
+
params = arguments.params
|
|
70
|
+
|
|
71
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
72
|
+
|
|
73
|
+
post_request("/projects/#{arguments.project_id}/columns", params)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Update a project column
|
|
77
|
+
#
|
|
78
|
+
# @param [Hash] params
|
|
79
|
+
# @option params [String] :name
|
|
80
|
+
# Required. The name of the column.
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# github = Github.new
|
|
84
|
+
# github.repos.projects.update :column_id, name: 'new-column-name'
|
|
85
|
+
#
|
|
86
|
+
# @see https://developer.github.com/v3/projects/columns/#update-a-project-column
|
|
87
|
+
#
|
|
88
|
+
# @api public
|
|
89
|
+
def update(*args)
|
|
90
|
+
arguments(args, required: [:column_id]) do
|
|
91
|
+
assert_required REQUIRED_COLUMN_PARAMS
|
|
92
|
+
end
|
|
93
|
+
params = arguments.params
|
|
94
|
+
|
|
95
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
96
|
+
|
|
97
|
+
patch_request("/projects/columns/#{arguments.column_id}", params)
|
|
98
|
+
end
|
|
99
|
+
alias edit update
|
|
100
|
+
|
|
101
|
+
# Delete a project column
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# github = Github.new
|
|
105
|
+
# github.projects.columns.delete :column_id
|
|
106
|
+
#
|
|
107
|
+
# @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
|
|
108
|
+
#
|
|
109
|
+
# @api public
|
|
110
|
+
def delete(*args)
|
|
111
|
+
arguments(args, required: [:column_id])
|
|
112
|
+
params = arguments.params
|
|
113
|
+
|
|
114
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
115
|
+
|
|
116
|
+
delete_request("/projects/columns/#{arguments.column_id}", params)
|
|
117
|
+
end
|
|
118
|
+
alias remove delete
|
|
119
|
+
|
|
120
|
+
# Move a project column
|
|
121
|
+
#
|
|
122
|
+
# @param [Hash] params
|
|
123
|
+
# @option params [String] :position
|
|
124
|
+
# Required. Required. Can be one of 'first', 'last', or
|
|
125
|
+
# 'after:<column-id>', where <column-id> is the id value of a column in
|
|
126
|
+
# the same project.
|
|
127
|
+
#
|
|
128
|
+
# @example
|
|
129
|
+
# github = Github.new
|
|
130
|
+
# github.projects.columns.move :column_id, position: 'first'
|
|
131
|
+
#
|
|
132
|
+
# @see https://developer.github.com/v3/projects/columns/#move-a-project-column
|
|
133
|
+
#
|
|
134
|
+
# @api public
|
|
135
|
+
def move(*args)
|
|
136
|
+
arguments(args, required: [:column_id]) do
|
|
137
|
+
assert_required REQUIRED_MOVE_COLUMN_PARAMS
|
|
138
|
+
end
|
|
139
|
+
params = arguments.params
|
|
140
|
+
|
|
141
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
142
|
+
|
|
143
|
+
post_request("/projects/columns/#{arguments.column_id}/moves", params)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../api'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
# Projects API
|
|
8
|
+
class Client::Projects < API
|
|
9
|
+
PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json" # :nodoc:
|
|
10
|
+
|
|
11
|
+
require_all 'github_api2/client/projects',
|
|
12
|
+
'columns',
|
|
13
|
+
'cards'
|
|
14
|
+
|
|
15
|
+
# Access to Projects::Columns API
|
|
16
|
+
namespace :columns
|
|
17
|
+
|
|
18
|
+
# Access to Projects::Cards API
|
|
19
|
+
namespace :cards
|
|
20
|
+
|
|
21
|
+
# Get properties for a single project
|
|
22
|
+
#
|
|
23
|
+
# @see https://developer.github.com/v3/projects/#get-a-project
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.projects.get 1002604
|
|
28
|
+
#
|
|
29
|
+
# @api public
|
|
30
|
+
def get(*args)
|
|
31
|
+
arguments(args, required: [:id])
|
|
32
|
+
params = arguments.params
|
|
33
|
+
|
|
34
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
35
|
+
|
|
36
|
+
get_request("/projects/#{arguments.id}", params)
|
|
37
|
+
end
|
|
38
|
+
alias find get
|
|
39
|
+
|
|
40
|
+
# Edit a project
|
|
41
|
+
#
|
|
42
|
+
# @param [Hash] params
|
|
43
|
+
# @option params [String] :name
|
|
44
|
+
# Optional string
|
|
45
|
+
# @option params [String] :body
|
|
46
|
+
# Optional string
|
|
47
|
+
# @option params [String] :state
|
|
48
|
+
# Optional string
|
|
49
|
+
#
|
|
50
|
+
# @example
|
|
51
|
+
# github = Github.new
|
|
52
|
+
# github.projects.edit 1002604,
|
|
53
|
+
# name: "Outcomes Tracker",
|
|
54
|
+
# body: "The board to track work for the Outcomes application."
|
|
55
|
+
#
|
|
56
|
+
# @api public
|
|
57
|
+
def edit(*args)
|
|
58
|
+
arguments(args, required: [:id])
|
|
59
|
+
params = arguments.params
|
|
60
|
+
|
|
61
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
62
|
+
|
|
63
|
+
patch_request("/projects/#{arguments.id}", params)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Delete a project
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# github = Github.new
|
|
70
|
+
# github.projects.delete 1002604
|
|
71
|
+
#
|
|
72
|
+
# @api public
|
|
73
|
+
def delete(*args)
|
|
74
|
+
arguments(args, required: [:id])
|
|
75
|
+
params = arguments.params
|
|
76
|
+
|
|
77
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
78
|
+
|
|
79
|
+
delete_request("/projects/#{arguments.id}", arguments.params)
|
|
80
|
+
end
|
|
81
|
+
alias remove delete
|
|
82
|
+
end # Projects
|
|
83
|
+
end # Github
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::PullRequests::Comments < API
|
|
7
|
+
# List comments on a pull request
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# github = Github.new
|
|
11
|
+
# github.pull_requests.comments.list 'user-name', 'repo-name', number: 'id'
|
|
12
|
+
#
|
|
13
|
+
# List comments in a repository
|
|
14
|
+
#
|
|
15
|
+
# By default, Review Comments are ordered by ascending ID.
|
|
16
|
+
#
|
|
17
|
+
# @param [Hash] params
|
|
18
|
+
# @input params [String] :sort
|
|
19
|
+
# Optional string. Can be either created or updated. Default: created
|
|
20
|
+
# @input params [String] :direction
|
|
21
|
+
# Optional string. Can be either asc or desc. Ignored without sort parameter
|
|
22
|
+
# @input params [String] :since
|
|
23
|
+
# Optional string of a timestamp in ISO 8601
|
|
24
|
+
# format: YYYY-MM-DDTHH:MM:SSZ
|
|
25
|
+
# @example
|
|
26
|
+
# github = Github.new
|
|
27
|
+
# github.pull_requests.comments.list 'user-name', 'repo-name'
|
|
28
|
+
# github.pull_requests.comments.list 'user-name', 'repo-name' { |comm| ... }
|
|
29
|
+
#
|
|
30
|
+
# @api public
|
|
31
|
+
def list(*args)
|
|
32
|
+
arguments(args, required: [:user, :repo])
|
|
33
|
+
params = arguments.params
|
|
34
|
+
user = arguments.user
|
|
35
|
+
repo = arguments.repo
|
|
36
|
+
|
|
37
|
+
response = if (number = params.delete('number'))
|
|
38
|
+
get_request("/repos/#{user}/#{repo}/pulls/#{number}/comments", params)
|
|
39
|
+
else
|
|
40
|
+
get_request("/repos/#{user}/#{repo}/pulls/comments", params)
|
|
41
|
+
end
|
|
42
|
+
return response unless block_given?
|
|
43
|
+
response.each { |el| yield el }
|
|
44
|
+
end
|
|
45
|
+
alias_method :all, :list
|
|
46
|
+
|
|
47
|
+
# Get a single comment for pull requests
|
|
48
|
+
#
|
|
49
|
+
# @example
|
|
50
|
+
# github = Github.new
|
|
51
|
+
# github.pull_requests.comments.get 'user-name', 'repo-name', 'number'
|
|
52
|
+
#
|
|
53
|
+
# @example
|
|
54
|
+
# github.pull_requests.comments.get
|
|
55
|
+
# user: 'user-name',
|
|
56
|
+
# repo: 'repo-name',
|
|
57
|
+
# number: 'comment-number
|
|
58
|
+
#
|
|
59
|
+
# @api public
|
|
60
|
+
def get(*args)
|
|
61
|
+
arguments(args, required: [:user, :repo, :number])
|
|
62
|
+
|
|
63
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/comments", arguments.params)
|
|
64
|
+
end
|
|
65
|
+
alias_method :find, :get
|
|
66
|
+
|
|
67
|
+
# Create a pull request comment
|
|
68
|
+
#
|
|
69
|
+
# @param [Hash] params
|
|
70
|
+
# @option params [String] :body
|
|
71
|
+
# Required string. The text of the comment.
|
|
72
|
+
# @option params [String] :commit_id
|
|
73
|
+
# Required string - The SHA of the commit to comment on.
|
|
74
|
+
# @option params [String] :path
|
|
75
|
+
# Required string. The relative path of the file to comment on.
|
|
76
|
+
# @option params [Number] :position
|
|
77
|
+
# Required number. The line index in the diff to comment on.
|
|
78
|
+
#
|
|
79
|
+
# @example
|
|
80
|
+
# github = Github.new
|
|
81
|
+
# github.pull_requests.comments.create 'user-name', 'repo-name', 'number',
|
|
82
|
+
# body: "Nice change",
|
|
83
|
+
# commit_id: "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
|
84
|
+
# path: "file1.txt",
|
|
85
|
+
# position: 4
|
|
86
|
+
#
|
|
87
|
+
# Alternative Inputs
|
|
88
|
+
#
|
|
89
|
+
# Instead of passing commit_id, path, and position you can reply to
|
|
90
|
+
# an existing Pull Request Comment like this
|
|
91
|
+
# @option params [String] :body
|
|
92
|
+
# Required string. The text of the comment.
|
|
93
|
+
# @option params [Number] :in_reply_to
|
|
94
|
+
# Required number. The comment id to reply to.
|
|
95
|
+
#
|
|
96
|
+
# @example
|
|
97
|
+
# github = Github.new
|
|
98
|
+
# github.pull_requests.comments.create 'user-name','repo-name', 'number',
|
|
99
|
+
# body: "Nice change",
|
|
100
|
+
# in_reply_to: 4
|
|
101
|
+
#
|
|
102
|
+
# @api public
|
|
103
|
+
def create(*args)
|
|
104
|
+
arguments(args, required: [:user, :repo, :number])
|
|
105
|
+
|
|
106
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/comments", arguments.params)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Edit a pull request comment
|
|
110
|
+
#
|
|
111
|
+
# @param [Hash] params
|
|
112
|
+
# @option params [String] :body
|
|
113
|
+
# Required string. The text of the comment.
|
|
114
|
+
#
|
|
115
|
+
# @example
|
|
116
|
+
# github = Github.new
|
|
117
|
+
# github.pull_requests.comments.edit 'user-name', 'repo-name', 'number',
|
|
118
|
+
# body: "Nice change"
|
|
119
|
+
#
|
|
120
|
+
# @api public
|
|
121
|
+
def edit(*args)
|
|
122
|
+
arguments(args, required: [:user, :repo, :number])
|
|
123
|
+
|
|
124
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/comments/#{arguments.number}", arguments.params)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Delete a pull request comment
|
|
128
|
+
#
|
|
129
|
+
# @example
|
|
130
|
+
# github = Github.new
|
|
131
|
+
# github.pull_requests.comments.delete 'user-name', 'repo-name', 'number'
|
|
132
|
+
#
|
|
133
|
+
# @api public
|
|
134
|
+
def delete(*args)
|
|
135
|
+
arguments(args, required: [:user, :repo, :number])
|
|
136
|
+
|
|
137
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/comments/#{arguments.number}", arguments.params)
|
|
138
|
+
end
|
|
139
|
+
end # PullRequests::Comments
|
|
140
|
+
end # Github
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::PullRequests::Reviews < API
|
|
7
|
+
PREVIEW_MEDIA = "application/vnd.github.black-cat-preview+json".freeze # :nodoc:
|
|
8
|
+
|
|
9
|
+
# List reviews on a pull request
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# github = Github.new
|
|
13
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number'
|
|
14
|
+
#
|
|
15
|
+
# List pull request reviews in a repository
|
|
16
|
+
#
|
|
17
|
+
# @example
|
|
18
|
+
# github = Github.new
|
|
19
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number'
|
|
20
|
+
# github.pull_requests.reviews.list 'user-name', 'repo-name', number: 'pull-request-number' { |comm| ... }
|
|
21
|
+
#
|
|
22
|
+
# @api public
|
|
23
|
+
def list(*args)
|
|
24
|
+
arguments(args, required: [:user, :repo, :number])
|
|
25
|
+
params = arguments.params
|
|
26
|
+
|
|
27
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
28
|
+
|
|
29
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params)
|
|
30
|
+
return response unless block_given?
|
|
31
|
+
response.each { |el| yield el }
|
|
32
|
+
end
|
|
33
|
+
alias_method :all, :list
|
|
34
|
+
|
|
35
|
+
# Get a single review for pull requests
|
|
36
|
+
#
|
|
37
|
+
# @example
|
|
38
|
+
# github = Github.new
|
|
39
|
+
# github.pull_requests.reviews.get 'user-name', 'repo-name', 'number', 'id'
|
|
40
|
+
#
|
|
41
|
+
# @example
|
|
42
|
+
# github.pull_requests.reviews.get
|
|
43
|
+
# user: 'user-name',
|
|
44
|
+
# repo: 'repo-name',
|
|
45
|
+
# number: 1,
|
|
46
|
+
# id: 80
|
|
47
|
+
#
|
|
48
|
+
# @api public
|
|
49
|
+
def get(*args)
|
|
50
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
|
51
|
+
|
|
52
|
+
params = arguments.params
|
|
53
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
54
|
+
|
|
55
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}", params)
|
|
56
|
+
end
|
|
57
|
+
alias_method :find, :get
|
|
58
|
+
|
|
59
|
+
# Create a pull request review
|
|
60
|
+
#
|
|
61
|
+
# @param [Hash] params
|
|
62
|
+
# @option params [String] :event
|
|
63
|
+
# Required string - The review action (event) to perform; can be one of
|
|
64
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns
|
|
65
|
+
# HTTP 422 (Unrecognizable entity) and the review is left PENDING
|
|
66
|
+
# @option params [String] :body
|
|
67
|
+
# Optional string. The text of the review.
|
|
68
|
+
# @option params [Array] :comments
|
|
69
|
+
# Optional array of draft review comment objects. An array of comments
|
|
70
|
+
# part of the review.
|
|
71
|
+
#
|
|
72
|
+
# @example
|
|
73
|
+
# github = Github.new
|
|
74
|
+
# github.pull_requests.reviews.create 'user-name', 'repo-name', 'number',
|
|
75
|
+
# body: "Nice change",
|
|
76
|
+
# event: "APPROVE",
|
|
77
|
+
# comments: [
|
|
78
|
+
# {
|
|
79
|
+
# path: 'path/to/file/commented/on',
|
|
80
|
+
# position: 10,
|
|
81
|
+
# body: 'This looks good.'
|
|
82
|
+
# }
|
|
83
|
+
# ]
|
|
84
|
+
#
|
|
85
|
+
# @api public
|
|
86
|
+
def create(*args)
|
|
87
|
+
arguments(args, required: [:user, :repo, :number])
|
|
88
|
+
|
|
89
|
+
params = arguments.params
|
|
90
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
91
|
+
|
|
92
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Update a pull request review
|
|
96
|
+
#
|
|
97
|
+
# @param [Hash] params
|
|
98
|
+
# @option params [String] :state
|
|
99
|
+
# Required string - The review action (event) to perform; can be one of
|
|
100
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns
|
|
101
|
+
# HTTP 422 (Unrecognizable entity) and the review is left PENDING
|
|
102
|
+
# @optoin params [String] :body
|
|
103
|
+
# Optional string
|
|
104
|
+
#
|
|
105
|
+
# @example
|
|
106
|
+
# github = Github.new oauth_token: '...'
|
|
107
|
+
# github.pull_requests.reviews.update 'user-name', 'repo-name', 'number', 'review-id'
|
|
108
|
+
# body: "Update body",
|
|
109
|
+
# event: "APPROVE"
|
|
110
|
+
#
|
|
111
|
+
# @api public
|
|
112
|
+
def update(*args)
|
|
113
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
|
114
|
+
params = arguments.params
|
|
115
|
+
|
|
116
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
117
|
+
|
|
118
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/events", params)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# @option params [String] :message
|
|
122
|
+
# Optional string - Reason for dismissal
|
|
123
|
+
#
|
|
124
|
+
# @example
|
|
125
|
+
# github = Github.new oauth_token: '...'
|
|
126
|
+
# github.pull_requests.reviews.dismiss 'user-name', 'repo-name', 'number', 'review-id'
|
|
127
|
+
# message: "I can't get to this right now."
|
|
128
|
+
#
|
|
129
|
+
# @api public
|
|
130
|
+
def dismiss(*args)
|
|
131
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
|
132
|
+
params = arguments.params
|
|
133
|
+
|
|
134
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
135
|
+
|
|
136
|
+
put_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/dismissals", params)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# List comments on a pull request review
|
|
140
|
+
#
|
|
141
|
+
# @example
|
|
142
|
+
# github = Github.new
|
|
143
|
+
# github.pull_requests.revieiws.comments 'user-name', 'repo-name', 'number', 'review-id'
|
|
144
|
+
#
|
|
145
|
+
# @api public
|
|
146
|
+
def comments(*args)
|
|
147
|
+
arguments(args, required: [:user, :repo, :number, :id])
|
|
148
|
+
params = arguments.params
|
|
149
|
+
|
|
150
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
151
|
+
|
|
152
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/comments", params)
|
|
153
|
+
return response unless block_given?
|
|
154
|
+
response.each { |el| yield el }
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
end
|