octokit 4.22.0 → 9.2.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 +4 -4
- data/README.md +117 -95
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +111 -8
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +23 -3
- data/lib/octokit/client/actions_workflows.rb +27 -2
- data/lib/octokit/client/apps.rb +63 -26
- data/lib/octokit/client/checks.rb +18 -9
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +2 -2
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +2 -2
- data/lib/octokit/client/commits.rb +25 -33
- data/lib/octokit/client/community_profile.rb +2 -3
- data/lib/octokit/client/contents.rb +19 -22
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +8 -8
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -5
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +6 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +14 -15
- data/lib/octokit/client/labels.rb +10 -10
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +3 -6
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +4 -4
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -6
- data/lib/octokit/client/oauth_applications.rb +1 -7
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +100 -56
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +44 -64
- data/lib/octokit/client/pull_requests.rb +66 -45
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +62 -16
- data/lib/octokit/client/refs.rb +14 -17
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +92 -69
- data/lib/octokit/client/repository_invitations.rb +3 -3
- data/lib/octokit/client/reviews.rb +8 -8
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +24 -10
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +7 -12
- data/lib/octokit/client/stats.rb +10 -9
- data/lib/octokit/client/statuses.rb +5 -5
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +54 -33
- data/lib/octokit/client.rb +42 -18
- data/lib/octokit/configurable.rb +51 -31
- data/lib/octokit/connection.rb +30 -21
- data/lib/octokit/default.rb +66 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
- data/lib/octokit/enterprise_admin_client/license.rb +3 -4
- data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
- data/lib/octokit/enterprise_admin_client/users.rb +5 -4
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +51 -33
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +51 -34
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +13 -12
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +8 -6
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +32 -25
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -7
- data/lib/octokit/response/raise_error.rb +4 -4
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +4 -2
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -11
- metadata +19 -31
- data/lib/octokit/client/authorizations.rb +0 -182
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -46
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Source Import API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/migration/source_imports
|
7
8
|
module SourceImport
|
8
|
-
|
9
9
|
# Start a source import to a GitHub repository using GitHub Importer.
|
10
10
|
#
|
11
11
|
# @overload start_source_import(repo, vcs, vcs_url, options = {})
|
@@ -39,10 +39,10 @@ module Octokit
|
|
39
39
|
vcs_url = arguments.pop
|
40
40
|
vcs = arguments.pop
|
41
41
|
if vcs
|
42
|
-
octokit_warn
|
43
|
-
arguments.options.merge!(:
|
42
|
+
octokit_warn 'Octokit#start_source_import vcs parameter is now an option, please update your call before the next major Octokit version update.'
|
43
|
+
arguments.options.merge!(vcs: vcs)
|
44
44
|
end
|
45
|
-
options =
|
45
|
+
options = arguments.options.merge(vcs_url: vcs_url)
|
46
46
|
put "#{Repository.path arguments.repo}/import", options
|
47
47
|
end
|
48
48
|
|
@@ -55,7 +55,6 @@ module Octokit
|
|
55
55
|
# @example
|
56
56
|
# @client.source_import_progress("octokit/octokit.rb")
|
57
57
|
def source_import_progress(repo, options = {})
|
58
|
-
options = ensure_api_media_type(:source_imports, options)
|
59
58
|
get "#{Repository.path repo}/import", options
|
60
59
|
end
|
61
60
|
|
@@ -76,7 +75,6 @@ module Octokit
|
|
76
75
|
# :vcs_password => "secret"
|
77
76
|
# })
|
78
77
|
def update_source_import(repo, options = {})
|
79
|
-
options = ensure_api_media_type(:source_imports, options)
|
80
78
|
patch "#{Repository.path repo}/import", options
|
81
79
|
end
|
82
80
|
|
@@ -91,7 +89,6 @@ module Octokit
|
|
91
89
|
# @example
|
92
90
|
# @client.source_import_commit_authors("octokit/octokit.rb")
|
93
91
|
def source_import_commit_authors(repo, options = {})
|
94
|
-
options = ensure_api_media_type(:source_imports, options)
|
95
92
|
get "#{Repository.path repo}/import/authors", options
|
96
93
|
end
|
97
94
|
|
@@ -111,7 +108,7 @@ module Octokit
|
|
111
108
|
# :name => "Hubot the Robot"
|
112
109
|
# })
|
113
110
|
def map_source_import_commit_author(author_url, values, options = {})
|
114
|
-
options =
|
111
|
+
options = options.merge(values)
|
115
112
|
patch author_url, options
|
116
113
|
end
|
117
114
|
|
@@ -124,7 +121,6 @@ module Octokit
|
|
124
121
|
# @example
|
125
122
|
# @client.cancel_source_import("octokit/octokit.rb")
|
126
123
|
def cancel_source_import(repo, options = {})
|
127
|
-
options = ensure_api_media_type(:source_imports, options)
|
128
124
|
boolean_from_response :delete, "#{Repository.path repo}/import", options
|
129
125
|
end
|
130
126
|
|
@@ -139,7 +135,6 @@ module Octokit
|
|
139
135
|
# @example
|
140
136
|
# @client.source_import_large_files("octokit/octokit.rb")
|
141
137
|
def source_import_large_files(repo, options = {})
|
142
|
-
options = ensure_api_media_type(:source_imports, options)
|
143
138
|
get "#{Repository.path repo}/import/large_files", options
|
144
139
|
end
|
145
140
|
|
@@ -153,7 +148,7 @@ module Octokit
|
|
153
148
|
# @example
|
154
149
|
# @client.opt_in_source_import_lfs("octokit/octokit.rb", "opt_in")
|
155
150
|
def set_source_import_lfs_preference(repo, use_lfs, options = {})
|
156
|
-
options =
|
151
|
+
options = options.merge(use_lfs: use_lfs)
|
157
152
|
patch "#{Repository.path repo}/import/lfs", options
|
158
153
|
end
|
159
154
|
end
|
data/lib/octokit/client/stats.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Repository Statistics API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/statistics/
|
7
8
|
module Stats
|
8
|
-
|
9
9
|
# Get contributors list with additions, deletions, and commit counts
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -16,9 +16,9 @@ module Octokit
|
|
16
16
|
# @example Get contributor stats for octokit
|
17
17
|
# @client.contributors_stats('octokit/octokit.rb')
|
18
18
|
def contributors_stats(repo, options = {})
|
19
|
-
get_stats(repo,
|
19
|
+
get_stats(repo, 'contributors', options)
|
20
20
|
end
|
21
|
-
alias
|
21
|
+
alias contributor_stats contributors_stats
|
22
22
|
|
23
23
|
# Get the last year of commit activity data
|
24
24
|
#
|
@@ -31,7 +31,7 @@ module Octokit
|
|
31
31
|
# @example Get commit activity for octokit
|
32
32
|
# @client.commit_activity_stats('octokit/octokit.rb')
|
33
33
|
def commit_activity_stats(repo, options = {})
|
34
|
-
get_stats(repo,
|
34
|
+
get_stats(repo, 'commit_activity', options)
|
35
35
|
end
|
36
36
|
|
37
37
|
# Get the number of additions and deletions per week
|
@@ -45,7 +45,7 @@ module Octokit
|
|
45
45
|
# @example Get code frequency stats for octokit
|
46
46
|
# @client.code_frequency_stats('octokit/octokit.rb')
|
47
47
|
def code_frequency_stats(repo, options = {})
|
48
|
-
get_stats(repo,
|
48
|
+
get_stats(repo, 'code_frequency', options)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Get the weekly commit count for the repo owner and everyone else
|
@@ -61,7 +61,7 @@ module Octokit
|
|
61
61
|
# @example Get weekly commit counts for octokit
|
62
62
|
# @client.participation_stats("octokit/octokit.rb")
|
63
63
|
def participation_stats(repo, options = {})
|
64
|
-
get_stats(repo,
|
64
|
+
get_stats(repo, 'participation', options)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Get the number of commits per hour in each day
|
@@ -75,9 +75,9 @@ module Octokit
|
|
75
75
|
# @example Get octokit punch card
|
76
76
|
# @octokit.punch_card_stats
|
77
77
|
def punch_card_stats(repo, options = {})
|
78
|
-
get_stats(repo,
|
78
|
+
get_stats(repo, 'punch_card', options)
|
79
79
|
end
|
80
|
-
alias
|
80
|
+
alias punch_card punch_card_stats
|
81
81
|
|
82
82
|
private
|
83
83
|
|
@@ -99,6 +99,7 @@ module Octokit
|
|
99
99
|
return [] if last_response.status == 204
|
100
100
|
return nil unless retry_timeout
|
101
101
|
return nil if Time.now >= timeout
|
102
|
+
|
102
103
|
sleep retry_wait if retry_wait
|
103
104
|
end
|
104
105
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Commit Statuses API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/statuses/
|
7
8
|
module Statuses
|
8
|
-
|
9
9
|
# List all statuses for a given commit
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -15,7 +15,7 @@ module Octokit
|
|
15
15
|
def statuses(repo, sha, options = {})
|
16
16
|
paginate "#{Repository.path repo}/statuses/#{sha}", options
|
17
17
|
end
|
18
|
-
alias
|
18
|
+
alias list_statuses statuses
|
19
19
|
|
20
20
|
# Get the combined status for a ref
|
21
21
|
#
|
@@ -26,7 +26,7 @@ module Octokit
|
|
26
26
|
def combined_status(repo, ref, options = {})
|
27
27
|
get "#{Repository.path repo}/commits/#{ref}/status", options
|
28
28
|
end
|
29
|
-
alias
|
29
|
+
alias status combined_status
|
30
30
|
|
31
31
|
# Create status for a commit
|
32
32
|
#
|
@@ -39,7 +39,7 @@ module Octokit
|
|
39
39
|
# @return [Sawyer::Resource] A status
|
40
40
|
# @see https://developer.github.com/v3/repos/statuses/#create-a-status
|
41
41
|
def create_status(repo, sha, state, options = {})
|
42
|
-
options = options.merge(:
|
42
|
+
options = options.merge(state: state)
|
43
43
|
post "#{Repository.path repo}/statuses/#{sha}", options
|
44
44
|
end
|
45
45
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Method to check scopes
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
|
8
|
+
module Tokens
|
9
|
+
# Check scopes for a token
|
10
|
+
#
|
11
|
+
# @param token [String] GitHub OAuth token
|
12
|
+
# @param options [Hash] Header params for request
|
13
|
+
# @return [Array<String>] OAuth scopes
|
14
|
+
# @see https://developer.github.com/v3/oauth/#scopes
|
15
|
+
def scopes(token = @access_token, options = {})
|
16
|
+
options = options.dup
|
17
|
+
raise ArgumentError, 'Access token required' if token.nil?
|
18
|
+
|
19
|
+
auth = { 'Authorization' => "token #{token}" }
|
20
|
+
headers = (options.delete(:headers) || {}).merge(auth)
|
21
|
+
|
22
|
+
agent.call(:get, 'user', headers: headers)
|
23
|
+
.headers['X-OAuth-Scopes']
|
24
|
+
.to_s
|
25
|
+
.split(',')
|
26
|
+
.map(&:strip)
|
27
|
+
.sort
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Traffic API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/traffic/
|
7
8
|
module Traffic
|
8
|
-
|
9
9
|
# Get the top 10 referrers over the last 14 days
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -14,8 +14,7 @@ module Octokit
|
|
14
14
|
# @example
|
15
15
|
# @client.top_referrers('octokit/octokit.rb')
|
16
16
|
def top_referrers(repo, options = {})
|
17
|
-
|
18
|
-
get "#{Repository.path repo}/traffic/popular/referrers", opts
|
17
|
+
get "#{Repository.path repo}/traffic/popular/referrers", options
|
19
18
|
end
|
20
19
|
|
21
20
|
# Get the top 10 popular contents over the last 14 days
|
@@ -26,8 +25,7 @@ module Octokit
|
|
26
25
|
# @example
|
27
26
|
# @client.top_paths('octokit/octokit.rb')
|
28
27
|
def top_paths(repo, options = {})
|
29
|
-
|
30
|
-
get "#{Repository.path repo}/traffic/popular/paths", opts
|
28
|
+
get "#{Repository.path repo}/traffic/popular/paths", options
|
31
29
|
end
|
32
30
|
|
33
31
|
# Get the total number of views and breakdown per day or week for the
|
@@ -43,8 +41,7 @@ module Octokit
|
|
43
41
|
# @example Views per week
|
44
42
|
# @client.views('octokit/octokit.rb', per: 'week')
|
45
43
|
def views(repo, options = {})
|
46
|
-
|
47
|
-
get "#{Repository.path repo}/traffic/views", opts
|
44
|
+
get "#{Repository.path repo}/traffic/views", options
|
48
45
|
end
|
49
46
|
|
50
47
|
# Get the total number of clones and breakdown per day or week for the
|
@@ -60,10 +57,8 @@ module Octokit
|
|
60
57
|
# @example Clones per week
|
61
58
|
# @client.clones('octokit/octokit.rb', per: 'week')
|
62
59
|
def clones(repo, options = {})
|
63
|
-
|
64
|
-
get "#{Repository.path repo}/traffic/clones", opts
|
60
|
+
get "#{Repository.path repo}/traffic/clones", options
|
65
61
|
end
|
66
|
-
|
67
62
|
end
|
68
63
|
end
|
69
64
|
end
|
data/lib/octokit/client/users.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Users API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/users/
|
7
8
|
module Users
|
8
|
-
|
9
9
|
# List all GitHub users
|
10
10
|
#
|
11
11
|
# This provides a list of every user, in the order that they signed up
|
@@ -19,7 +19,7 @@ module Octokit
|
|
19
19
|
#
|
20
20
|
# @return [Array<Sawyer::Resource>] List of GitHub users.
|
21
21
|
def all_users(options = {})
|
22
|
-
paginate
|
22
|
+
paginate 'users', options
|
23
23
|
end
|
24
24
|
|
25
25
|
# Get a single user
|
@@ -30,7 +30,7 @@ module Octokit
|
|
30
30
|
# @see https://developer.github.com/v3/users/#get-the-authenticated-user
|
31
31
|
# @example
|
32
32
|
# Octokit.user("sferik")
|
33
|
-
def user(user=nil, options = {})
|
33
|
+
def user(user = nil, options = {})
|
34
34
|
get User.path(user), options
|
35
35
|
end
|
36
36
|
|
@@ -45,14 +45,41 @@ module Octokit
|
|
45
45
|
# Octokit.exchange_code_for_token('aaaa', 'xxxx', 'yyyy', {:accept => 'application/json'})
|
46
46
|
def exchange_code_for_token(code, app_id = client_id, app_secret = client_secret, options = {})
|
47
47
|
options = options.merge({
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
code: code,
|
49
|
+
client_id: app_id,
|
50
|
+
client_secret: app_secret,
|
51
|
+
headers: {
|
52
|
+
content_type: 'application/json',
|
53
|
+
accept: 'application/json'
|
54
|
+
}
|
55
|
+
})
|
56
|
+
|
57
|
+
post "#{web_endpoint}login/oauth/access_token", options
|
58
|
+
end
|
59
|
+
|
60
|
+
# Refresh a user's access token with a refresh token.
|
61
|
+
#
|
62
|
+
# Applications can refresh an access token without requiring a user to re-authorize using refresh access token.
|
63
|
+
#
|
64
|
+
# @param code [String] 40 character GitHub OAuth refresh access token
|
65
|
+
#
|
66
|
+
# @return [Sawyer::Resource]
|
67
|
+
# @see https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens#refreshing-a-user-access-token-with-a-refresh-token
|
68
|
+
#
|
69
|
+
# @example
|
70
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
71
|
+
# client.refresh_access_token('40-character-refresh-token')
|
72
|
+
def refresh_access_token(code, app_id = client_id, app_secret = client_secret, options = {})
|
73
|
+
options = options.merge({
|
74
|
+
refresh_token: code,
|
75
|
+
client_id: app_id,
|
76
|
+
client_secret: app_secret,
|
77
|
+
grant_type: 'refresh_token',
|
78
|
+
headers: {
|
79
|
+
content_type: 'application/json',
|
80
|
+
accept: 'application/json'
|
81
|
+
}
|
82
|
+
})
|
56
83
|
|
57
84
|
post "#{web_endpoint}login/oauth/access_token", options
|
58
85
|
end
|
@@ -84,7 +111,7 @@ module Octokit
|
|
84
111
|
# @example
|
85
112
|
# Octokit.update_user(:name => "Erik Michaels-Ober", :email => "sferik@gmail.com", :company => "Code for America", :location => "San Francisco", :hireable => false)
|
86
113
|
def update_user(options)
|
87
|
-
patch
|
114
|
+
patch 'user', options
|
88
115
|
end
|
89
116
|
|
90
117
|
# Get a user's followers.
|
@@ -96,7 +123,7 @@ module Octokit
|
|
96
123
|
# @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user
|
97
124
|
# @example
|
98
125
|
# Octokit.followers('pengwynn')
|
99
|
-
def followers(user=login, options = {})
|
126
|
+
def followers(user = login, options = {})
|
100
127
|
paginate "#{User.path user}/followers", options
|
101
128
|
end
|
102
129
|
|
@@ -109,7 +136,7 @@ module Octokit
|
|
109
136
|
# @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
|
110
137
|
# @example
|
111
138
|
# Octokit.following('pengwynn')
|
112
|
-
def following(user=login, options = {})
|
139
|
+
def following(user = login, options = {})
|
113
140
|
paginate "#{User.path user}/following", options
|
114
141
|
end
|
115
142
|
|
@@ -174,7 +201,7 @@ module Octokit
|
|
174
201
|
# @see https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
|
175
202
|
# @example
|
176
203
|
# Octokit.starred('pengwynn')
|
177
|
-
def starred(user=login, options = {})
|
204
|
+
def starred(user = login, options = {})
|
178
205
|
paginate user_path(user, 'starred'), options
|
179
206
|
end
|
180
207
|
|
@@ -227,7 +254,7 @@ module Octokit
|
|
227
254
|
# @example
|
228
255
|
# @client.keys
|
229
256
|
def keys(options = {})
|
230
|
-
paginate
|
257
|
+
paginate 'user/keys', options
|
231
258
|
end
|
232
259
|
|
233
260
|
# Get list of public keys for user.
|
@@ -253,7 +280,7 @@ module Octokit
|
|
253
280
|
# @example
|
254
281
|
# @client.add_key('Personal projects key', 'ssh-rsa AAA...')
|
255
282
|
def add_key(title, key, options = {})
|
256
|
-
post
|
283
|
+
post 'user/keys', options.merge({ title: title, key: key })
|
257
284
|
end
|
258
285
|
|
259
286
|
# Update a public key
|
@@ -297,7 +324,7 @@ module Octokit
|
|
297
324
|
# @example
|
298
325
|
# @client.emails
|
299
326
|
def emails(options = {})
|
300
|
-
paginate
|
327
|
+
paginate 'user/emails', options
|
301
328
|
end
|
302
329
|
|
303
330
|
# Add email address to user.
|
@@ -309,9 +336,9 @@ module Octokit
|
|
309
336
|
# @see https://developer.github.com/v3/users/emails/#add-email-addresses
|
310
337
|
# @example
|
311
338
|
# @client.add_email('new_email@user.com')
|
312
|
-
def add_email(email,
|
339
|
+
def add_email(email, _options = {})
|
313
340
|
email = Array(email)
|
314
|
-
post
|
341
|
+
post 'user/emails', email
|
315
342
|
end
|
316
343
|
|
317
344
|
# Remove email from user.
|
@@ -325,7 +352,7 @@ module Octokit
|
|
325
352
|
# @client.remove_email('old_email@user.com')
|
326
353
|
def remove_email(email)
|
327
354
|
email = Array(email)
|
328
|
-
boolean_from_response :delete,
|
355
|
+
boolean_from_response :delete, 'user/emails', email
|
329
356
|
end
|
330
357
|
|
331
358
|
# List repositories being watched by a user.
|
@@ -335,10 +362,10 @@ module Octokit
|
|
335
362
|
# @see https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
|
336
363
|
# @example
|
337
364
|
# @client.subscriptions("pengwynn")
|
338
|
-
def subscriptions(user=login, options = {})
|
365
|
+
def subscriptions(user = login, options = {})
|
339
366
|
paginate user_path(user, 'subscriptions'), options
|
340
367
|
end
|
341
|
-
alias
|
368
|
+
alias watched subscriptions
|
342
369
|
|
343
370
|
# Initiates the generation of a migration archive.
|
344
371
|
#
|
@@ -352,9 +379,8 @@ module Octokit
|
|
352
379
|
# @client.start_migration(['octocat/hello-world'])
|
353
380
|
# @see https://docs.github.com/en/rest/reference/migrations#start-a-user-migration
|
354
381
|
def start_user_migration(repositories, options = {})
|
355
|
-
options = ensure_api_media_type(:migrations, options)
|
356
382
|
options[:repositories] = repositories
|
357
|
-
post
|
383
|
+
post 'user/migrations', options
|
358
384
|
end
|
359
385
|
|
360
386
|
# Lists the most recent migrations.
|
@@ -364,8 +390,7 @@ module Octokit
|
|
364
390
|
# @return [Array<Sawyer::Resource>] Array of migration resources.
|
365
391
|
# @see https://docs.github.com/en/rest/reference/migrations#list-user-migrations
|
366
392
|
def user_migrations(options = {})
|
367
|
-
|
368
|
-
paginate "user/migrations", options
|
393
|
+
paginate 'user/migrations', options
|
369
394
|
end
|
370
395
|
|
371
396
|
# Fetches the status of a migration.
|
@@ -375,7 +400,6 @@ module Octokit
|
|
375
400
|
# @param id [Integer] ID number of the migration.
|
376
401
|
# @see https://docs.github.com/en/rest/reference/migrations#get-a-user-migration-status
|
377
402
|
def user_migration_status(id, options = {})
|
378
|
-
options = ensure_api_media_type(:migrations, options)
|
379
403
|
get "user/migrations/#{id}", options
|
380
404
|
end
|
381
405
|
|
@@ -386,7 +410,6 @@ module Octokit
|
|
386
410
|
# @param id [Integer] ID number of the migration.
|
387
411
|
# @see https://docs.github.com/en/rest/reference/migrations#download-a-user-migration-archive
|
388
412
|
def user_migration_archive_url(id, options = {})
|
389
|
-
options = ensure_api_media_type(:migrations, options)
|
390
413
|
url = "user/migrations/#{id}/archive"
|
391
414
|
|
392
415
|
response = client_without_redirects(options).get(url)
|
@@ -400,7 +423,6 @@ module Octokit
|
|
400
423
|
# @param id [Integer] ID number of the migration.
|
401
424
|
# @see https://docs.github.com/en/rest/reference/migrations#delete-a-user-migration-archive
|
402
425
|
def delete_user_migration_archive(id, options = {})
|
403
|
-
options = ensure_api_media_type(:migrations, options)
|
404
426
|
delete "user/migrations/#{id}/archive", options
|
405
427
|
end
|
406
428
|
|
@@ -411,7 +433,6 @@ module Octokit
|
|
411
433
|
# @param id [Integer] ID number of the migration.
|
412
434
|
# @see https://docs.github.com/en/rest/reference/migrations#list-repositories-for-a-user-migration
|
413
435
|
def user_migration_repositories(id, options = {})
|
414
|
-
options = ensure_api_media_type(:migrations, options)
|
415
436
|
get "user/migrations/#{id}/repositories", options
|
416
437
|
end
|
417
438
|
|
@@ -423,12 +444,12 @@ module Octokit
|
|
423
444
|
# @param repo [String] Name of the repository.
|
424
445
|
# @see https://docs.github.com/en/rest/reference/migrations#unlock-a-user-repository
|
425
446
|
def unlock_user_repository(id, repo, options = {})
|
426
|
-
options = ensure_api_media_type(:migrations, options)
|
427
447
|
delete "user/migrations/#{id}/repos/#{repo}/lock", options
|
428
448
|
end
|
429
449
|
end
|
430
450
|
|
431
451
|
private
|
452
|
+
|
432
453
|
# convenience method for constructing a user specific path, if the user is logged in
|
433
454
|
def user_path(user, path)
|
434
455
|
if user == login && user_authenticated?
|