lingfennan-github_api 0.18.2
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/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api.rb +93 -0
- data/lib/github_api/api.rb +398 -0
- data/lib/github_api/api/actions.rb +60 -0
- data/lib/github_api/api/arguments.rb +253 -0
- data/lib/github_api/api/config.rb +105 -0
- data/lib/github_api/api/config/property.rb +30 -0
- data/lib/github_api/api/config/property_set.rb +120 -0
- data/lib/github_api/api/factory.rb +33 -0
- data/lib/github_api/authorization.rb +75 -0
- data/lib/github_api/client.rb +77 -0
- data/lib/github_api/client/activity.rb +31 -0
- data/lib/github_api/client/activity/events.rb +233 -0
- data/lib/github_api/client/activity/feeds.rb +50 -0
- data/lib/github_api/client/activity/notifications.rb +181 -0
- data/lib/github_api/client/activity/starring.rb +130 -0
- data/lib/github_api/client/activity/watching.rb +176 -0
- data/lib/github_api/client/authorizations.rb +142 -0
- data/lib/github_api/client/authorizations/app.rb +98 -0
- data/lib/github_api/client/emojis.rb +19 -0
- data/lib/github_api/client/gists.rb +289 -0
- data/lib/github_api/client/gists/comments.rb +100 -0
- data/lib/github_api/client/git_data.rb +31 -0
- data/lib/github_api/client/git_data/blobs.rb +51 -0
- data/lib/github_api/client/git_data/commits.rb +101 -0
- data/lib/github_api/client/git_data/references.rb +150 -0
- data/lib/github_api/client/git_data/tags.rb +95 -0
- data/lib/github_api/client/git_data/trees.rb +113 -0
- data/lib/github_api/client/gitignore.rb +57 -0
- data/lib/github_api/client/issues.rb +248 -0
- data/lib/github_api/client/issues/assignees.rb +77 -0
- data/lib/github_api/client/issues/comments.rb +146 -0
- data/lib/github_api/client/issues/events.rb +50 -0
- data/lib/github_api/client/issues/labels.rb +189 -0
- data/lib/github_api/client/issues/milestones.rb +146 -0
- data/lib/github_api/client/markdown.rb +62 -0
- data/lib/github_api/client/meta.rb +19 -0
- data/lib/github_api/client/orgs.rb +127 -0
- data/lib/github_api/client/orgs/hooks.rb +182 -0
- data/lib/github_api/client/orgs/members.rb +142 -0
- data/lib/github_api/client/orgs/memberships.rb +131 -0
- data/lib/github_api/client/orgs/projects.rb +57 -0
- data/lib/github_api/client/orgs/teams.rb +407 -0
- data/lib/github_api/client/projects.rb +83 -0
- data/lib/github_api/client/projects/cards.rb +158 -0
- data/lib/github_api/client/projects/columns.rb +146 -0
- data/lib/github_api/client/pull_requests.rb +195 -0
- data/lib/github_api/client/pull_requests/comments.rb +140 -0
- data/lib/github_api/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api/client/repos.rb +468 -0
- data/lib/github_api/client/repos/branches.rb +48 -0
- data/lib/github_api/client/repos/branches/protections.rb +75 -0
- data/lib/github_api/client/repos/collaborators.rb +84 -0
- data/lib/github_api/client/repos/comments.rb +125 -0
- data/lib/github_api/client/repos/commits.rb +80 -0
- data/lib/github_api/client/repos/contents.rb +246 -0
- data/lib/github_api/client/repos/deployments.rb +138 -0
- data/lib/github_api/client/repos/downloads.rb +62 -0
- data/lib/github_api/client/repos/forks.rb +48 -0
- data/lib/github_api/client/repos/hooks.rb +214 -0
- data/lib/github_api/client/repos/keys.rb +104 -0
- data/lib/github_api/client/repos/merging.rb +47 -0
- data/lib/github_api/client/repos/pages.rb +48 -0
- data/lib/github_api/client/repos/projects.rb +62 -0
- data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api/client/repos/releases.rb +189 -0
- data/lib/github_api/client/repos/releases/assets.rb +136 -0
- data/lib/github_api/client/repos/releases/tags.rb +24 -0
- data/lib/github_api/client/repos/statistics.rb +89 -0
- data/lib/github_api/client/repos/statuses.rb +91 -0
- data/lib/github_api/client/say.rb +25 -0
- data/lib/github_api/client/scopes.rb +46 -0
- data/lib/github_api/client/search.rb +133 -0
- data/lib/github_api/client/search/legacy.rb +111 -0
- data/lib/github_api/client/users.rb +117 -0
- data/lib/github_api/client/users/emails.rb +65 -0
- data/lib/github_api/client/users/followers.rb +115 -0
- data/lib/github_api/client/users/keys.rb +104 -0
- data/lib/github_api/configuration.rb +70 -0
- data/lib/github_api/connection.rb +82 -0
- data/lib/github_api/constants.rb +61 -0
- data/lib/github_api/core_ext/array.rb +25 -0
- data/lib/github_api/core_ext/hash.rb +91 -0
- data/lib/github_api/core_ext/ordered_hash.rb +107 -0
- data/lib/github_api/deprecation.rb +39 -0
- data/lib/github_api/error.rb +32 -0
- data/lib/github_api/error/client_error.rb +89 -0
- data/lib/github_api/error/service_error.rb +223 -0
- data/lib/github_api/ext/faraday.rb +38 -0
- data/lib/github_api/mash.rb +7 -0
- data/lib/github_api/middleware.rb +37 -0
- data/lib/github_api/mime_type.rb +33 -0
- data/lib/github_api/normalizer.rb +23 -0
- data/lib/github_api/null_encoder.rb +25 -0
- data/lib/github_api/page_iterator.rb +138 -0
- data/lib/github_api/page_links.rb +63 -0
- data/lib/github_api/paged_request.rb +42 -0
- data/lib/github_api/pagination.rb +115 -0
- data/lib/github_api/parameter_filter.rb +35 -0
- data/lib/github_api/params_hash.rb +115 -0
- data/lib/github_api/rate_limit.rb +25 -0
- data/lib/github_api/request.rb +85 -0
- data/lib/github_api/request/basic_auth.rb +36 -0
- data/lib/github_api/request/jsonize.rb +54 -0
- data/lib/github_api/request/oauth2.rb +44 -0
- data/lib/github_api/request/verbs.rb +63 -0
- data/lib/github_api/response.rb +48 -0
- data/lib/github_api/response/atom_parser.rb +22 -0
- data/lib/github_api/response/follow_redirects.rb +140 -0
- data/lib/github_api/response/header.rb +87 -0
- data/lib/github_api/response/jsonize.rb +28 -0
- data/lib/github_api/response/mashify.rb +24 -0
- data/lib/github_api/response/raise_error.rb +22 -0
- data/lib/github_api/response/xmlize.rb +27 -0
- data/lib/github_api/response_wrapper.rb +161 -0
- data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api/utils/url.rb +63 -0
- data/lib/github_api/validations.rb +22 -0
- data/lib/github_api/validations/format.rb +26 -0
- data/lib/github_api/validations/presence.rb +32 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +5 -0
- metadata +338 -0
|
@@ -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_api/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,158 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
require_relative '../../api'
|
|
5
|
+
|
|
6
|
+
module Github
|
|
7
|
+
class Client::Projects::Cards < API
|
|
8
|
+
REQUIRED_MOVE_CARD_PARAMS = %w(position).freeze
|
|
9
|
+
|
|
10
|
+
# List project cards for a column
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# github = Github.new
|
|
14
|
+
# github.projects.cards.list :column_id
|
|
15
|
+
#
|
|
16
|
+
# @see https://developer.github.com/v3/projects/cards/#list-project-cards
|
|
17
|
+
#
|
|
18
|
+
# @api public
|
|
19
|
+
def list(*args)
|
|
20
|
+
arguments(args, required: [:column_id])
|
|
21
|
+
params = arguments.params
|
|
22
|
+
|
|
23
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
24
|
+
|
|
25
|
+
response = get_request("/projects/columns/#{arguments.column_id}/cards", params)
|
|
26
|
+
|
|
27
|
+
return response unless block_given?
|
|
28
|
+
response.each { |el| yield el }
|
|
29
|
+
end
|
|
30
|
+
alias all list
|
|
31
|
+
|
|
32
|
+
# Get a project card
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# github = Github.new
|
|
36
|
+
# github.projects.cards.get :card_id
|
|
37
|
+
#
|
|
38
|
+
# @see https://developer.github.com/v3/projects/cards/#get-a-project-card
|
|
39
|
+
#
|
|
40
|
+
# @api public
|
|
41
|
+
def get(*args)
|
|
42
|
+
arguments(args, required: [:card_id])
|
|
43
|
+
params = arguments.params
|
|
44
|
+
|
|
45
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
46
|
+
|
|
47
|
+
get_request("/projects/columns/cards/#{arguments.card_id}", params)
|
|
48
|
+
end
|
|
49
|
+
alias find get
|
|
50
|
+
|
|
51
|
+
# Create a project card for a column
|
|
52
|
+
#
|
|
53
|
+
# @param [Hash] params
|
|
54
|
+
# @option params [String] :note
|
|
55
|
+
# The card's note content. Only valid for cards without another type of
|
|
56
|
+
# content, so this must be omitted if content_id and content_type are
|
|
57
|
+
# specified.
|
|
58
|
+
# @option params [Integer] :content_id
|
|
59
|
+
# The id of the Issue to associate with this card.
|
|
60
|
+
# @option params [String] :content_type
|
|
61
|
+
# The type of content to associate with this card. Can only be "Issue" at
|
|
62
|
+
# this time.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# github = Github.new
|
|
66
|
+
# github.projects.cards.create :column_id, note: 'Card Note'
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# github = Github.new
|
|
70
|
+
# github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type'
|
|
71
|
+
#
|
|
72
|
+
# @see https://developer.github.com/v3/projects/cards/#create-a-project-card
|
|
73
|
+
#
|
|
74
|
+
# @api public
|
|
75
|
+
def create(*args)
|
|
76
|
+
arguments(args, required: [:column_id])
|
|
77
|
+
params = arguments.params
|
|
78
|
+
|
|
79
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
80
|
+
|
|
81
|
+
post_request("/projects/columns/#{arguments.column_id}/cards", params)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Update a project card
|
|
85
|
+
#
|
|
86
|
+
# @param [Hash] params
|
|
87
|
+
# @option params [String] :note
|
|
88
|
+
# The card's note content. Only valid for cards without another type of
|
|
89
|
+
# content, so this cannot be specified if the card already has a
|
|
90
|
+
# content_id and content_type.
|
|
91
|
+
#
|
|
92
|
+
# @example
|
|
93
|
+
# github = Github.new
|
|
94
|
+
# github.projects.cards.update :card_id, note: 'New card note'
|
|
95
|
+
#
|
|
96
|
+
# @see https://developer.github.com/v3/projects/cards/#update-a-project-card
|
|
97
|
+
#
|
|
98
|
+
# @api public
|
|
99
|
+
def update(*args)
|
|
100
|
+
arguments(args, required: [:card_id])
|
|
101
|
+
params = arguments.params
|
|
102
|
+
|
|
103
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
104
|
+
|
|
105
|
+
patch_request("/projects/columns/cards/#{arguments.card_id}", params)
|
|
106
|
+
end
|
|
107
|
+
alias edit update
|
|
108
|
+
|
|
109
|
+
# Delete a project card
|
|
110
|
+
#
|
|
111
|
+
# @example
|
|
112
|
+
# github = Github.new
|
|
113
|
+
# github.projects.cards.delete :card_id
|
|
114
|
+
#
|
|
115
|
+
# @see https://developer.github.com/v3/projects/cards/#delete-a-project-card
|
|
116
|
+
#
|
|
117
|
+
# @api public
|
|
118
|
+
def delete(*args)
|
|
119
|
+
arguments(args, required: [:card_id])
|
|
120
|
+
params = arguments.params
|
|
121
|
+
|
|
122
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
123
|
+
|
|
124
|
+
delete_request("/projects/columns/cards/#{arguments.card_id}", params)
|
|
125
|
+
end
|
|
126
|
+
alias remove delete
|
|
127
|
+
|
|
128
|
+
# Move a project card
|
|
129
|
+
#
|
|
130
|
+
# @param [Hash] params
|
|
131
|
+
# @option params [String] :position
|
|
132
|
+
# Required. Required. Can be one of 'first', 'last', or
|
|
133
|
+
# 'after:<column-id>', where <column-id> is the id value of a column in
|
|
134
|
+
# the same project.
|
|
135
|
+
#
|
|
136
|
+
# @example
|
|
137
|
+
# github = Github.new
|
|
138
|
+
# github.projects.cards.move :card_id, position: 'bottom'
|
|
139
|
+
#
|
|
140
|
+
# @example
|
|
141
|
+
# github = Github.new
|
|
142
|
+
# github.projects.cards.move :card_id, position: 'after:<card-id>', column_id: <column-id>
|
|
143
|
+
#
|
|
144
|
+
# @see https://developer.github.com/v3/projects/cards/#move-a-project-card
|
|
145
|
+
#
|
|
146
|
+
# @api public
|
|
147
|
+
def move(*args)
|
|
148
|
+
arguments(args, required: [:card_id]) do
|
|
149
|
+
assert_required REQUIRED_MOVE_CARD_PARAMS
|
|
150
|
+
end
|
|
151
|
+
params = arguments.params
|
|
152
|
+
|
|
153
|
+
params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA
|
|
154
|
+
|
|
155
|
+
post_request("/projects/columns/cards/#{arguments.card_id}/moves", params)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
@@ -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,195 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::PullRequests < API
|
|
7
|
+
|
|
8
|
+
require_all 'github_api/client/pull_requests', 'comments', 'reviews'
|
|
9
|
+
|
|
10
|
+
# Access to PullRequests::Comments API
|
|
11
|
+
namespace :comments
|
|
12
|
+
# Access to PullRequests::Reviews API
|
|
13
|
+
namespace :reviews
|
|
14
|
+
|
|
15
|
+
# List pull requests
|
|
16
|
+
#
|
|
17
|
+
# @example
|
|
18
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
19
|
+
# github.pull_requests.list
|
|
20
|
+
# github.pull_requests.list { |req| ... }
|
|
21
|
+
#
|
|
22
|
+
# @example
|
|
23
|
+
# pulls = Github::PullRequests.new
|
|
24
|
+
# pulls.pull_requests.list 'user-name', 'repo-name'
|
|
25
|
+
#
|
|
26
|
+
# @api public
|
|
27
|
+
def list(*args)
|
|
28
|
+
arguments(args, required: [:user, :repo])
|
|
29
|
+
|
|
30
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls",
|
|
31
|
+
arguments.params)
|
|
32
|
+
return response unless block_given?
|
|
33
|
+
response.each { |el| yield el }
|
|
34
|
+
end
|
|
35
|
+
alias_method :all, :list
|
|
36
|
+
|
|
37
|
+
# Get a single pull request
|
|
38
|
+
#
|
|
39
|
+
# = Examples
|
|
40
|
+
# github = Github.new
|
|
41
|
+
# github.pull_requests.get 'user-name', 'repo-name', 'number'
|
|
42
|
+
#
|
|
43
|
+
# pulls = Github::PullRequests.new
|
|
44
|
+
# pulls.get 'user-name', 'repo-name', 'number'
|
|
45
|
+
#
|
|
46
|
+
def get(*args)
|
|
47
|
+
arguments(args, required: [:user, :repo, :number])
|
|
48
|
+
|
|
49
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}", arguments.params)
|
|
50
|
+
end
|
|
51
|
+
alias_method :find, :get
|
|
52
|
+
|
|
53
|
+
# Create a pull request
|
|
54
|
+
#
|
|
55
|
+
# @param [Hash] params
|
|
56
|
+
# @option params [String] :title
|
|
57
|
+
# Required string
|
|
58
|
+
# @option params [String] :body
|
|
59
|
+
# Optional string
|
|
60
|
+
# @option params [String] :base
|
|
61
|
+
# Required string - The branch you want your changes pulled into.
|
|
62
|
+
# @option params [String] :head
|
|
63
|
+
# Required string - The branch where your changes are implemented.
|
|
64
|
+
#
|
|
65
|
+
# @note: head and base can be either a sha or a branch name.
|
|
66
|
+
# Typically you would namespace head with a user like this: username:branch.
|
|
67
|
+
#
|
|
68
|
+
# Alternative Input
|
|
69
|
+
# You can also create a Pull Request from an existing Issue by passing
|
|
70
|
+
# an Issue number instead of <tt>title</tt> and <tt>body</tt>.
|
|
71
|
+
# @option params [Numeric] :issue
|
|
72
|
+
# Required number - Issue number in this repository to turn into a Pull Request.
|
|
73
|
+
#
|
|
74
|
+
# @example
|
|
75
|
+
# github = Github.new oauth_token: '...'
|
|
76
|
+
# github.pull_requests.create 'user-name', 'repo-name',
|
|
77
|
+
# title: "Amazing new feature",
|
|
78
|
+
# body: "Please pull this in!",
|
|
79
|
+
# head: "octocat:new-feature",
|
|
80
|
+
# base: "master"
|
|
81
|
+
#
|
|
82
|
+
# @example
|
|
83
|
+
# github.pull_requests.create 'user-name', 'repo-name',
|
|
84
|
+
# issue: "5",
|
|
85
|
+
# head: "octocat:new-feature",
|
|
86
|
+
# base: "master"
|
|
87
|
+
#
|
|
88
|
+
# @api public
|
|
89
|
+
def create(*args)
|
|
90
|
+
arguments(args, required: [:user, :repo])
|
|
91
|
+
|
|
92
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls",
|
|
93
|
+
arguments.params)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Update a pull request
|
|
97
|
+
#
|
|
98
|
+
# @param [Hash] params
|
|
99
|
+
# @option params [String] :title
|
|
100
|
+
# Optional string
|
|
101
|
+
# @optoin params [String] :body
|
|
102
|
+
# Optional string
|
|
103
|
+
# @option params [String] :state
|
|
104
|
+
# Optional string - State of this Pull Request.
|
|
105
|
+
# Valid values are open and closed.
|
|
106
|
+
#
|
|
107
|
+
# @example
|
|
108
|
+
# github = Github.new oauth_token: '...'
|
|
109
|
+
# github.pull_requests.update 'user-name', 'repo-name', 'number'
|
|
110
|
+
# title: "Amazing new title",
|
|
111
|
+
# body: "Update body",
|
|
112
|
+
# state: "open"
|
|
113
|
+
#
|
|
114
|
+
# @api public
|
|
115
|
+
def update(*args)
|
|
116
|
+
arguments(args, required: [:user, :repo, :number])
|
|
117
|
+
|
|
118
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}", arguments.params)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# List commits on a pull request
|
|
122
|
+
#
|
|
123
|
+
# @example
|
|
124
|
+
# github = Github.new
|
|
125
|
+
# github.pull_requests.commits 'user-name', 'repo-name', 'number'
|
|
126
|
+
#
|
|
127
|
+
# @api public
|
|
128
|
+
def commits(*args)
|
|
129
|
+
arguments(args, required: [:user, :repo, :number])
|
|
130
|
+
|
|
131
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/commits", arguments.params)
|
|
132
|
+
return response unless block_given?
|
|
133
|
+
response.each { |el| yield el }
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# List pull requests files
|
|
137
|
+
#
|
|
138
|
+
# @example
|
|
139
|
+
# github = Github.new
|
|
140
|
+
# github.pull_requests.files 'user-name', 'repo-name', 'number'
|
|
141
|
+
#
|
|
142
|
+
# @api public
|
|
143
|
+
def files(*args)
|
|
144
|
+
arguments(args, required: [:user, :repo, :number])
|
|
145
|
+
|
|
146
|
+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/files", arguments.params)
|
|
147
|
+
return response unless block_given?
|
|
148
|
+
response.each { |el| yield el }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Check if pull request has been merged
|
|
152
|
+
#
|
|
153
|
+
# @example
|
|
154
|
+
# github = Github.new
|
|
155
|
+
# github.pull_requests.merged? 'user-name', 'repo-name', 'number'
|
|
156
|
+
#
|
|
157
|
+
# @api public
|
|
158
|
+
def merged?(*args)
|
|
159
|
+
arguments(args, required: [:user, :repo, :number])
|
|
160
|
+
|
|
161
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/merge", arguments.params)
|
|
162
|
+
true
|
|
163
|
+
rescue Github::Error::NotFound
|
|
164
|
+
false
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
PREVIEW_MEDIA = 'application/vnd.github.polaris-preview+json'.freeze # :nodoc:
|
|
168
|
+
|
|
169
|
+
# Merge a pull request(Merge Button)
|
|
170
|
+
#
|
|
171
|
+
# @param [Hash] params
|
|
172
|
+
# @option params [String] :commit_title
|
|
173
|
+
# Optional string - The first line of the message that will be used for the merge commit
|
|
174
|
+
# @option params [String] :commit_message
|
|
175
|
+
# Optional string - The message that will be used for the merge commit
|
|
176
|
+
# @option params [String] :sha
|
|
177
|
+
# Optional string - The SHA that pull request head must match to allow merge
|
|
178
|
+
# @option params [String] :merge_method
|
|
179
|
+
# Optional string - Merge method to use.
|
|
180
|
+
# Valid values are merge, squash, and rebase. Default is merge.
|
|
181
|
+
#
|
|
182
|
+
# @example
|
|
183
|
+
# github = Github.new
|
|
184
|
+
# github.pull_requests.merge 'user-name', 'repo-name', 'number'
|
|
185
|
+
#
|
|
186
|
+
# @api public
|
|
187
|
+
def merge(*args)
|
|
188
|
+
arguments(args, required: [:user, :repo, :number])
|
|
189
|
+
params = arguments.params
|
|
190
|
+
params['accept'] ||= PREVIEW_MEDIA
|
|
191
|
+
|
|
192
|
+
put_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/merge", params)
|
|
193
|
+
end
|
|
194
|
+
end # PullRequests
|
|
195
|
+
end # Github
|