lingfennan-github_api 0.18.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,113 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::GitData::Trees < API
|
7
|
+
|
8
|
+
VALID_TREE_PARAM_NAMES = %w[
|
9
|
+
base_tree
|
10
|
+
tree
|
11
|
+
path
|
12
|
+
mode
|
13
|
+
type
|
14
|
+
sha
|
15
|
+
content
|
16
|
+
url
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
VALID_TREE_PARAM_VALUES = {
|
20
|
+
'mode' => %w[ 100644 100755 040000 160000 120000 ],
|
21
|
+
'type' => %w[ blob tree commit ]
|
22
|
+
}
|
23
|
+
|
24
|
+
# Get a tree
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# github = Github.new
|
28
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha'
|
29
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha' do |file|
|
30
|
+
# file.path
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# Get a tree recursively
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# github = Github.new
|
37
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha', recursive: true
|
38
|
+
#
|
39
|
+
# @api public
|
40
|
+
def get(*args)
|
41
|
+
arguments(args, required: [:user, :repo, :sha])
|
42
|
+
user = arguments.user
|
43
|
+
repo = arguments.repo
|
44
|
+
sha = arguments.sha
|
45
|
+
params = arguments.params
|
46
|
+
|
47
|
+
response = if params['recursive']
|
48
|
+
params['recursive'] = 1
|
49
|
+
get_request("/repos/#{user}/#{repo}/git/trees/#{sha}", params)
|
50
|
+
else
|
51
|
+
get_request("/repos/#{user}/#{repo}/git/trees/#{sha.to_s}", params)
|
52
|
+
end
|
53
|
+
return response unless block_given?
|
54
|
+
response.tree.each { |el| yield el }
|
55
|
+
end
|
56
|
+
alias :find :get
|
57
|
+
|
58
|
+
# Create a tree
|
59
|
+
#
|
60
|
+
# The tree creation API will take nested entries as well.
|
61
|
+
# If both a tree and a nested path modifying that tree are specified,
|
62
|
+
# it will overwrite the contents of that tree with the new path contents
|
63
|
+
# and write a new tree out.
|
64
|
+
#
|
65
|
+
# @param [Hash] params
|
66
|
+
# @input params [String] :base_tree
|
67
|
+
# The SHA1 of the tree you want to update with new data
|
68
|
+
# @input params [Array[Hash]] :tree
|
69
|
+
# Required. Objects (of path, mode, type, and sha)
|
70
|
+
# specifying a tree structure
|
71
|
+
#
|
72
|
+
# The tree parameter takes the following keys:
|
73
|
+
# @input tree [String] :path
|
74
|
+
# The file referenced in the tree
|
75
|
+
# @input tree [String] :mode
|
76
|
+
# The file mode; one of 100644 for file (blob), 100755 for
|
77
|
+
# executable (blob), 040000 for subdirectory (tree), 160000 for
|
78
|
+
# submodule (commit), or 120000 for a blob that specifies
|
79
|
+
# the path of a symlink
|
80
|
+
# @input tree [String] :type
|
81
|
+
# Either blob, tree, or commit
|
82
|
+
# @input tree [String] :sha
|
83
|
+
# The SHA1 checksum ID of the object in the tree
|
84
|
+
# @input tree [String] :content
|
85
|
+
# The content you want this file to have - GitHub will write
|
86
|
+
# this blob out and use the SHA for this entry.
|
87
|
+
# Use either this or <tt>tree.sha</tt>
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# github = Github.new
|
91
|
+
# github.git_data.trees.create 'user-name', 'repo-name',
|
92
|
+
# tree: [
|
93
|
+
# {
|
94
|
+
# path: "file.rb",
|
95
|
+
# mode: "100644",
|
96
|
+
# type: "blob",
|
97
|
+
# sha: "44b4fc6d56897b048c772eb4087f854f46256132"
|
98
|
+
# },
|
99
|
+
# ...
|
100
|
+
# ]
|
101
|
+
#
|
102
|
+
# @api public
|
103
|
+
def create(*args)
|
104
|
+
arguments(args, required: [:user, :repo]) do
|
105
|
+
assert_required %w[ tree ]
|
106
|
+
permit VALID_TREE_PARAM_NAMES, 'tree', { recursive: true }
|
107
|
+
assert_values VALID_TREE_PARAM_VALUES, 'tree'
|
108
|
+
end
|
109
|
+
|
110
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/git/trees", arguments.params)
|
111
|
+
end
|
112
|
+
end # GitData::Trees
|
113
|
+
end # Github
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
# When you create a new GitHub repository via the API, you can specify a
|
7
|
+
# .gitignore template to apply to the repository upon creation.
|
8
|
+
class Client::Gitignore < API
|
9
|
+
# List all templates available to pass as an option
|
10
|
+
# when creating a repository.
|
11
|
+
#
|
12
|
+
# @see https://developer.github.com/v3/gitignore/#listing-available-templates
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# github = Github.new
|
16
|
+
# github.gitignore.list
|
17
|
+
# github.gitignore.list { |template| ... }
|
18
|
+
#
|
19
|
+
# @api public
|
20
|
+
def list(*args)
|
21
|
+
arguments(args)
|
22
|
+
|
23
|
+
response = get_request("/gitignore/templates", arguments.params)
|
24
|
+
return response unless block_given?
|
25
|
+
response.each { |el| yield el }
|
26
|
+
end
|
27
|
+
alias :all :list
|
28
|
+
|
29
|
+
# Get a single template
|
30
|
+
#
|
31
|
+
# @see https://developer.github.com/v3/gitignore/#get-a-single-template
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# github = Github.new
|
35
|
+
# github.gitignore.get "template-name"
|
36
|
+
#
|
37
|
+
# Use the raw media type to get the raw contents.
|
38
|
+
#
|
39
|
+
# @examples
|
40
|
+
# github = Github.new
|
41
|
+
# github.gitignore.get "template-name", accept: 'applicatin/vnd.github.raw'
|
42
|
+
#
|
43
|
+
# @api public
|
44
|
+
def get(*args)
|
45
|
+
arguments(args, required: [:name])
|
46
|
+
params = arguments.params
|
47
|
+
|
48
|
+
if (media = params.delete('accept'))
|
49
|
+
params['accept'] = media
|
50
|
+
params['raw'] = true
|
51
|
+
end
|
52
|
+
|
53
|
+
get_request("/gitignore/templates/#{arguments.name}", params)
|
54
|
+
end
|
55
|
+
alias :find :get
|
56
|
+
end # Client::Gitignore
|
57
|
+
end # Github
|
@@ -0,0 +1,248 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::Issues < API
|
7
|
+
|
8
|
+
require_all 'github_api/client/issues',
|
9
|
+
'assignees',
|
10
|
+
'comments',
|
11
|
+
'events',
|
12
|
+
'labels',
|
13
|
+
'milestones'
|
14
|
+
|
15
|
+
VALID_ISSUE_PARAM_NAMES = %w[
|
16
|
+
assignee
|
17
|
+
body
|
18
|
+
creator
|
19
|
+
direction
|
20
|
+
filter
|
21
|
+
labels
|
22
|
+
milestone
|
23
|
+
mentioned
|
24
|
+
mime_type
|
25
|
+
org
|
26
|
+
resource
|
27
|
+
since
|
28
|
+
sort
|
29
|
+
state
|
30
|
+
title
|
31
|
+
].freeze
|
32
|
+
|
33
|
+
VALID_ISSUE_PARAM_VALUES = {
|
34
|
+
'filter' => %w[ assigned created mentioned subscribed all ],
|
35
|
+
'state' => %w[ open closed all ],
|
36
|
+
'sort' => %w[ created updated comments ],
|
37
|
+
'direction' => %w[ desc asc ],
|
38
|
+
'since' => %r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z}
|
39
|
+
}
|
40
|
+
|
41
|
+
# Access to Issues::Assignees API
|
42
|
+
namespace :assignees
|
43
|
+
|
44
|
+
# Access to Issues::Comments API
|
45
|
+
namespace :comments
|
46
|
+
|
47
|
+
# Access to Issues::Events API
|
48
|
+
namespace :events
|
49
|
+
|
50
|
+
# Access to Issues::Comments API
|
51
|
+
namespace :labels
|
52
|
+
|
53
|
+
# Access to Issues::Comments API
|
54
|
+
namespace :milestones
|
55
|
+
|
56
|
+
# List your issues
|
57
|
+
#
|
58
|
+
# List all issues across all the authenticated user’s visible repositories
|
59
|
+
# including owned repositories, member repositories,
|
60
|
+
# and organization repositories.
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# github = Github.new oauth_token: '...'
|
64
|
+
# github.issues.list
|
65
|
+
#
|
66
|
+
# List all issues across owned and member repositories for the
|
67
|
+
# authenticated user.
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# github = Github.new oauth_token: '...'
|
71
|
+
# github.issues.list :user
|
72
|
+
#
|
73
|
+
# List all issues for a given organization for the authenticated user.
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# github = Github.new oauth_token: '...'
|
77
|
+
# github.issues.list org: 'org-name'
|
78
|
+
#
|
79
|
+
# List issues for a repository
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# github = Github.new
|
83
|
+
# github.issues.list user: 'user-name', repo: 'repo-name'
|
84
|
+
#
|
85
|
+
# @param [Hash] params
|
86
|
+
# @option params [String] :filter
|
87
|
+
# * assigned Issues assigned to you (default)
|
88
|
+
# * created Issues created by you
|
89
|
+
# * mentioned Issues mentioning you
|
90
|
+
# * subscribed Issues you've subscribed to updates for
|
91
|
+
# * all All issues the user can see
|
92
|
+
# @option params [String] :milestone
|
93
|
+
# * Integer Milestone number
|
94
|
+
# * none for Issues with no Milestone.
|
95
|
+
# * * for Issues with any Milestone
|
96
|
+
# @option params [String] :state
|
97
|
+
# open, closed, default: open
|
98
|
+
# @option params [String] :labels
|
99
|
+
# String list of comma separated Label names. Example: bug,ui,@high
|
100
|
+
# @option params [String] :assignee
|
101
|
+
# * String User login
|
102
|
+
# * <tt>none</tt> for Issues with no assigned User.
|
103
|
+
# * <tt>*</tt> for Issues with any assigned User.
|
104
|
+
# @option params [String] :creator
|
105
|
+
# String User login
|
106
|
+
# @option params [String] :mentioned
|
107
|
+
# String User login
|
108
|
+
# @option params [String] :sort
|
109
|
+
# created, updated, comments, default: <tt>created</tt>
|
110
|
+
# @option params [String] :direction
|
111
|
+
# asc, desc, default: desc
|
112
|
+
# @option params [String] :since
|
113
|
+
# Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# github = Github.new oauth_token: '...'
|
117
|
+
# github.issues.list since: '2011-04-12T12:12:12Z',
|
118
|
+
# filter: 'created',
|
119
|
+
# state: 'open',
|
120
|
+
# labels: "bug,ui,bla",
|
121
|
+
# sort: 'comments',
|
122
|
+
# direction: 'asc'
|
123
|
+
#
|
124
|
+
# @api public
|
125
|
+
def list(*args)
|
126
|
+
params = arguments(args) do
|
127
|
+
assert_values VALID_ISSUE_PARAM_VALUES
|
128
|
+
end.params
|
129
|
+
|
130
|
+
response = if (org = params.delete('org'))
|
131
|
+
get_request("/orgs/#{org}/issues", params)
|
132
|
+
|
133
|
+
elsif (user_name = params.delete('user')) &&
|
134
|
+
(repo_name = params.delete('repo'))
|
135
|
+
|
136
|
+
list_repo user_name, repo_name
|
137
|
+
elsif args.include? :user
|
138
|
+
get_request("/user/issues", params)
|
139
|
+
else
|
140
|
+
get_request("/issues", params)
|
141
|
+
end
|
142
|
+
return response unless block_given?
|
143
|
+
response.each { |el| yield el }
|
144
|
+
end
|
145
|
+
alias :all :list
|
146
|
+
|
147
|
+
# List issues for a repository
|
148
|
+
#
|
149
|
+
# def list_repo(user_name, repo_name, params)
|
150
|
+
def list_repo(user, repo)
|
151
|
+
get_request("/repos/#{user}/#{repo}/issues", arguments.params)
|
152
|
+
end
|
153
|
+
private :list_repo
|
154
|
+
|
155
|
+
# Get a single issue
|
156
|
+
#
|
157
|
+
# @example
|
158
|
+
# github = Github.new
|
159
|
+
# github.issues.get 'user-name', 'repo-name', 'number'
|
160
|
+
#
|
161
|
+
def get(*args)
|
162
|
+
arguments(args, required: [:user, :repo, :number])
|
163
|
+
|
164
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}", arguments.params)
|
165
|
+
end
|
166
|
+
alias :find :get
|
167
|
+
|
168
|
+
# Create an issue
|
169
|
+
#
|
170
|
+
# @param [Hash] params
|
171
|
+
# @option params [String] :title
|
172
|
+
# Required string
|
173
|
+
# @option params [String] :body
|
174
|
+
# Optional string
|
175
|
+
# @option params [String] :assignee
|
176
|
+
# Optional string - Login for the user that this issue should be
|
177
|
+
# assigned to. Only users with push access can set the assignee for
|
178
|
+
# new issues. The assignee is silently dropped otherwise.
|
179
|
+
# @option params [Number] :milestone
|
180
|
+
# Optional number - Milestone to associate this issue with.
|
181
|
+
# Only users with push access can set the milestone for new issues.
|
182
|
+
# The milestone is silently dropped otherwise.
|
183
|
+
# @option params [Array[String]] :labels
|
184
|
+
# Optional array of strings - Labels to associate with this issue
|
185
|
+
# Only users with push access can set labels for new issues.
|
186
|
+
# Labels are silently dropped otherwise.
|
187
|
+
#
|
188
|
+
# @example
|
189
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
190
|
+
# github.issues.create
|
191
|
+
# title: "Found a bug",
|
192
|
+
# body: "I'm having a problem with this.",
|
193
|
+
# assignee: "octocat",
|
194
|
+
# milestone: 1,
|
195
|
+
# labels: [
|
196
|
+
# "Label1",
|
197
|
+
# "Label2"
|
198
|
+
# ]
|
199
|
+
#
|
200
|
+
def create(*args)
|
201
|
+
arguments(args, required: [:user, :repo]) do
|
202
|
+
permit VALID_ISSUE_PARAM_NAMES
|
203
|
+
assert_required %w[ title ]
|
204
|
+
end
|
205
|
+
|
206
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues", arguments.params)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Edit an issue
|
210
|
+
#
|
211
|
+
# @param [Hash] params
|
212
|
+
# @option params [String] :title
|
213
|
+
# Optional string
|
214
|
+
# @option params [String] :body
|
215
|
+
# Optional string
|
216
|
+
# @option params [String] :assignee
|
217
|
+
# Optional string - Login for the user that this issue should be assigned to.
|
218
|
+
# @option params [String] :state
|
219
|
+
# Optional string - State of the issue: open or closed
|
220
|
+
# @option params [Number] :milestone
|
221
|
+
# Optional number - Milestone to associate this issue with
|
222
|
+
# @option params [Array[String]] :labels
|
223
|
+
# Optional array of strings - Labels to associate with this issue.
|
224
|
+
# Pass one or more Labels to replace the set of Labels on this Issue.
|
225
|
+
# Send an empty array ([]) to clear all Labels from the Issue.
|
226
|
+
#
|
227
|
+
# @example
|
228
|
+
# github = Github.new
|
229
|
+
# github.issues.edit 'user-name', 'repo-name', 'number'
|
230
|
+
# title: "Found a bug",
|
231
|
+
# body: "I'm having a problem with this.",
|
232
|
+
# assignee: "octocat",
|
233
|
+
# milestone: 1,
|
234
|
+
# labels": [
|
235
|
+
# "Label1",
|
236
|
+
# "Label2"
|
237
|
+
# ]
|
238
|
+
#
|
239
|
+
# @api public
|
240
|
+
def edit(*args)
|
241
|
+
arguments(args, required: [:user, :repo, :number]) do
|
242
|
+
permit VALID_ISSUE_PARAM_NAMES
|
243
|
+
end
|
244
|
+
|
245
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}", arguments.params)
|
246
|
+
end
|
247
|
+
end # Issues
|
248
|
+
end # Github
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../../api'
|
4
|
+
|
5
|
+
module Github
|
6
|
+
class Client::Issues::Assignees < API
|
7
|
+
# Lists all the available assignees (owner + collaborators)
|
8
|
+
# to which issues may be assigned.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# Github.issues.assignees.list 'owner', 'repo'
|
12
|
+
# Github.issues.assignees.list 'owner', 'repo' { |assignee| ... }
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
def list(*args)
|
16
|
+
arguments(args, required: [:owner, :repo])
|
17
|
+
|
18
|
+
response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/assignees", arguments.params)
|
19
|
+
return response unless block_given?
|
20
|
+
response.each { |el| yield el }
|
21
|
+
end
|
22
|
+
alias :all :list
|
23
|
+
|
24
|
+
# Check to see if a particular user is an assignee for a repository.
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Github.issues.assignees.check 'user', 'repo', 'assignee'
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
31
|
+
# github.issues.assignees.check 'assignee'
|
32
|
+
#
|
33
|
+
# @api public
|
34
|
+
def check(*args)
|
35
|
+
arguments(args, required: [:owner, :repo, :assignee])
|
36
|
+
params = arguments.params
|
37
|
+
|
38
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/assignees/#{arguments.assignee}",params)
|
39
|
+
true
|
40
|
+
rescue Github::Error::NotFound
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add assignees to an issue
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# github = Github.new
|
48
|
+
# github.issues.assignees.add 'user', 'repo', 'issue-number',
|
49
|
+
# 'hubot', 'other_assignee', ...
|
50
|
+
#
|
51
|
+
# @api public
|
52
|
+
def add(*args)
|
53
|
+
arguments(args, required: [:user, :repo, :number])
|
54
|
+
params = arguments.params
|
55
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
56
|
+
|
57
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
58
|
+
end
|
59
|
+
alias :<< :add
|
60
|
+
|
61
|
+
# Remove a assignees from an issue
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# github = Github.new
|
65
|
+
# github.issues.assignees.remove 'user', 'repo', 'issue-number',
|
66
|
+
# 'hubot', 'other_assignee'
|
67
|
+
#
|
68
|
+
# @api public
|
69
|
+
def remove(*args)
|
70
|
+
arguments(args, required: [:user, :repo, :number])
|
71
|
+
params = arguments.params
|
72
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
73
|
+
|
74
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
75
|
+
end
|
76
|
+
end # Issues::Assignees
|
77
|
+
end # Github
|