octokit 4.22.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +113 -75
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +10 -9
- 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 +26 -26
- data/lib/octokit/client/checks.rb +18 -9
- data/lib/octokit/client/code_scanning.rb +53 -0
- data/lib/octokit/client/codespaces_secrets.rb +59 -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 +20 -21
- data/lib/octokit/client/dependabot_secrets.rb +59 -0
- data/lib/octokit/client/deployments.rb +6 -6
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -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 +0 -6
- 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/pub_sub_hubbub.rb +15 -15
- data/lib/octokit/client/pull_requests.rb +54 -42
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +13 -16
- data/lib/octokit/client/refs.rb +14 -17
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +49 -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 +27 -33
- data/lib/octokit/client.rb +40 -16
- data/lib/octokit/configurable.rb +34 -30
- data/lib/octokit/connection.rb +28 -21
- data/lib/octokit/default.rb +48 -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 +32 -32
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +45 -34
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/middleware/follow_redirects.rb +12 -11
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +8 -6
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +24 -24
- 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 +15 -8
- data/octokit.gemspec +12 -11
- metadata +20 -33
- data/lib/octokit/client/authorizations.rb +0 -182
- 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 Reviews API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/pulls/reviews/
|
7
8
|
module Reviews
|
8
|
-
|
9
9
|
# List reviews on a pull request
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -151,7 +151,7 @@ module Octokit
|
|
151
151
|
# @param number [Integer] Number ID of the pull request
|
152
152
|
# @param reviewers [Hash] :reviewers [Array<String>] An array of user logins
|
153
153
|
# @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
|
154
|
-
# @see https://developer.github.com/v3/pulls/review_requests/#
|
154
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request
|
155
155
|
#
|
156
156
|
# @example
|
157
157
|
# @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
|
@@ -161,9 +161,9 @@ module Octokit
|
|
161
161
|
# TODO(5.0): remove deprecated behavior
|
162
162
|
if reviewers.is_a?(Array)
|
163
163
|
octokit_warn(
|
164
|
-
|
164
|
+
'Deprecated: Octokit::Client#request_pull_request_review ' \
|
165
165
|
"no longer takes a separate :reviewers argument.\n" \
|
166
|
-
|
166
|
+
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
167
167
|
)
|
168
168
|
options = options.merge(reviewers: reviewers)
|
169
169
|
else
|
@@ -190,13 +190,13 @@ module Octokit
|
|
190
190
|
# @client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)
|
191
191
|
#
|
192
192
|
# @return [Sawyer::Resource>] Hash representing the pull request
|
193
|
-
def delete_pull_request_review_request(repo, id, reviewers={}, options = {})
|
193
|
+
def delete_pull_request_review_request(repo, id, reviewers = {}, options = {})
|
194
194
|
# TODO(5.0): remove deprecated behavior
|
195
195
|
if !reviewers.empty? && !options.empty?
|
196
196
|
octokit_warn(
|
197
|
-
|
197
|
+
'Deprecated: Octokit::Client#delete_pull_request_review_request ' \
|
198
198
|
"no longer takes a separate :reviewers argument.\n" \
|
199
|
-
|
199
|
+
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
200
200
|
)
|
201
201
|
end
|
202
202
|
# For backwards compatibility, this endpoint can be called with a separate reviewers hash.
|
data/lib/octokit/client/say.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the unpublished Octocat API
|
5
6
|
module Say
|
6
|
-
|
7
7
|
# Return a nifty ASCII Octocat with GitHub wisdom
|
8
8
|
# or your own
|
9
9
|
#
|
10
10
|
# @return [String]
|
11
11
|
def say(text = nil, options = {})
|
12
12
|
options[:s] = text if text
|
13
|
-
get
|
13
|
+
get 'octocat', options
|
14
14
|
end
|
15
|
-
alias
|
16
|
-
|
15
|
+
alias octocat say
|
17
16
|
end
|
18
17
|
end
|
19
18
|
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 Search API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/search/
|
7
8
|
module Search
|
8
|
-
|
9
9
|
# Search code
|
10
10
|
#
|
11
11
|
# @param query [String] Search term and qualifiers
|
@@ -17,7 +17,7 @@ module Octokit
|
|
17
17
|
# @return [Sawyer::Resource] Search results object
|
18
18
|
# @see https://developer.github.com/v3/search/#search-code
|
19
19
|
def search_code(query, options = {})
|
20
|
-
search
|
20
|
+
search 'search/code', query, options
|
21
21
|
end
|
22
22
|
|
23
23
|
# Search commits
|
@@ -31,8 +31,7 @@ module Octokit
|
|
31
31
|
# @return [Sawyer::Resource] Search results object
|
32
32
|
# @see https://developer.github.com/v3/search/#search-commits
|
33
33
|
def search_commits(query, options = {})
|
34
|
-
|
35
|
-
search "search/commits", query, options
|
34
|
+
search 'search/commits', query, options
|
36
35
|
end
|
37
36
|
|
38
37
|
# Search issues
|
@@ -45,8 +44,9 @@ module Octokit
|
|
45
44
|
# @option options [Integer] :per_page Number of items per page
|
46
45
|
# @return [Sawyer::Resource] Search results object
|
47
46
|
# @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
|
47
|
+
# @see https://docs.github.com/en/rest/search#limitations-on-query-length
|
48
48
|
def search_issues(query, options = {})
|
49
|
-
search
|
49
|
+
search 'search/issues', query, options
|
50
50
|
end
|
51
51
|
|
52
52
|
# Search repositories
|
@@ -60,9 +60,23 @@ module Octokit
|
|
60
60
|
# @return [Sawyer::Resource] Search results object
|
61
61
|
# @see https://developer.github.com/v3/search/#search-repositories
|
62
62
|
def search_repositories(query, options = {})
|
63
|
-
search
|
63
|
+
search 'search/repositories', query, options
|
64
|
+
end
|
65
|
+
alias search_repos search_repositories
|
66
|
+
|
67
|
+
# Search topics
|
68
|
+
#
|
69
|
+
# @param query [String] Search term and qualifiers
|
70
|
+
# @param options [Hash] Sort and pagination options
|
71
|
+
# @option options [String] :sort Sort field
|
72
|
+
# @option options [String] :order Sort order (asc or desc)
|
73
|
+
# @option options [Integer] :page Page of paginated results
|
74
|
+
# @option options [Integer] :per_page Number of items per page
|
75
|
+
# @return [Sawyer::Resource] Search results object
|
76
|
+
# @see https://developer.github.com/v3/search/#search-topics
|
77
|
+
def search_topics(query, options = {})
|
78
|
+
search 'search/topics', query, options
|
64
79
|
end
|
65
|
-
alias :search_repos :search_repositories
|
66
80
|
|
67
81
|
# Search users
|
68
82
|
#
|
@@ -75,13 +89,13 @@ module Octokit
|
|
75
89
|
# @return [Sawyer::Resource] Search results object
|
76
90
|
# @see https://developer.github.com/v3/search/#search-users
|
77
91
|
def search_users(query, options = {})
|
78
|
-
search
|
92
|
+
search 'search/users', query, options
|
79
93
|
end
|
80
94
|
|
81
95
|
private
|
82
96
|
|
83
97
|
def search(path, query, options = {})
|
84
|
-
opts = options.merge(:
|
98
|
+
opts = options.merge(q: query)
|
85
99
|
paginate(path, opts) do |data, last_response|
|
86
100
|
data.items.concat last_response.data.items
|
87
101
|
end
|
@@ -1,37 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the GitHub Status API
|
5
6
|
#
|
6
7
|
# @see https://status.github.com/api
|
7
8
|
module ServiceStatus
|
8
|
-
|
9
9
|
# Root for status API
|
10
10
|
# @private
|
11
|
-
|
11
|
+
SUMMARY_ROOT = 'https://www.githubstatus.com/api/v2/summary.json'
|
12
|
+
STATUS_ROOT = 'https://www.githubstatus.com/api/v2/status.json'
|
13
|
+
COMPONENTS_ROOT = 'https://www.githubstatus.com/api/v2/components.json'
|
14
|
+
|
15
|
+
# Returns a summary with the current status and the last status messages.
|
16
|
+
#
|
17
|
+
# @return [<Sawyer::Resource>] GitHub status summary
|
18
|
+
# @see https://www.githubstatus.com/api#summory
|
19
|
+
def github_status_summary
|
20
|
+
get(SUMMARY_ROOT)
|
21
|
+
end
|
12
22
|
|
13
23
|
# Returns the current system status
|
14
24
|
#
|
15
25
|
# @return [Sawyer::Resource] GitHub status
|
16
|
-
# @see https://
|
26
|
+
# @see https://www.githubstatus.com/api#status
|
17
27
|
def github_status
|
18
|
-
get(STATUS_ROOT)
|
28
|
+
get(STATUS_ROOT)
|
19
29
|
end
|
20
30
|
|
21
31
|
# Returns the last human communication, status, and timestamp.
|
22
32
|
#
|
23
33
|
# @return [Sawyer::Resource] GitHub status last message
|
24
|
-
# @see https://
|
34
|
+
# @see https://www.githubstatus.com/api/#components
|
25
35
|
def github_status_last_message
|
26
|
-
get(
|
36
|
+
get(COMPONENTS_ROOT).components.first
|
27
37
|
end
|
28
38
|
|
29
39
|
# Returns the most recent human communications with status and timestamp.
|
30
40
|
#
|
31
41
|
# @return [Array<Sawyer::Resource>] GitHub status messages
|
32
|
-
# @see https://
|
42
|
+
# @see https://www.githubstatus.com/api#components
|
33
43
|
def github_status_messages
|
34
|
-
get(
|
44
|
+
get(COMPONENTS_ROOT).components
|
35
45
|
end
|
36
46
|
end
|
37
47
|
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 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
|