octokit 4.24.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/Rakefile +5 -3
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +2 -2
  6. data/lib/octokit/authentication.rb +4 -5
  7. data/lib/octokit/client/actions_secrets.rb +2 -3
  8. data/lib/octokit/client/actions_workflow_runs.rb +2 -0
  9. data/lib/octokit/client/actions_workflows.rb +2 -1
  10. data/lib/octokit/client/apps.rb +26 -26
  11. data/lib/octokit/client/authorizations.rb +20 -17
  12. data/lib/octokit/client/checks.rb +5 -5
  13. data/lib/octokit/client/commit_branches.rb +2 -2
  14. data/lib/octokit/client/commit_comments.rb +8 -8
  15. data/lib/octokit/client/commit_pulls.rb +2 -2
  16. data/lib/octokit/client/commits.rb +25 -33
  17. data/lib/octokit/client/community_profile.rb +2 -2
  18. data/lib/octokit/client/contents.rb +20 -21
  19. data/lib/octokit/client/deployments.rb +6 -6
  20. data/lib/octokit/client/downloads.rb +5 -6
  21. data/lib/octokit/client/emojis.rb +3 -3
  22. data/lib/octokit/client/events.rb +4 -4
  23. data/lib/octokit/client/feeds.rb +4 -5
  24. data/lib/octokit/client/gists.rb +6 -6
  25. data/lib/octokit/client/gitignore.rb +3 -3
  26. data/lib/octokit/client/hooks.rb +10 -10
  27. data/lib/octokit/client/issues.rb +14 -14
  28. data/lib/octokit/client/labels.rb +6 -6
  29. data/lib/octokit/client/legacy_search.rb +3 -3
  30. data/lib/octokit/client/licenses.rb +3 -3
  31. data/lib/octokit/client/markdown.rb +3 -3
  32. data/lib/octokit/client/marketplace.rb +4 -4
  33. data/lib/octokit/client/meta.rb +4 -5
  34. data/lib/octokit/client/milestones.rb +5 -5
  35. data/lib/octokit/client/notifications.rb +6 -6
  36. data/lib/octokit/client/oauth_applications.rb +0 -2
  37. data/lib/octokit/client/objects.rb +14 -14
  38. data/lib/octokit/client/organizations.rb +42 -42
  39. data/lib/octokit/client/pages.rb +3 -3
  40. data/lib/octokit/client/projects.rb +18 -19
  41. data/lib/octokit/client/pub_sub_hubbub.rb +15 -15
  42. data/lib/octokit/client/pull_requests.rb +41 -42
  43. data/lib/octokit/client/rate_limit.rb +9 -11
  44. data/lib/octokit/client/reactions.rb +6 -6
  45. data/lib/octokit/client/refs.rb +13 -14
  46. data/lib/octokit/client/releases.rb +13 -13
  47. data/lib/octokit/client/repositories.rb +36 -36
  48. data/lib/octokit/client/repository_invitations.rb +3 -3
  49. data/lib/octokit/client/reviews.rb +7 -7
  50. data/lib/octokit/client/say.rb +4 -5
  51. data/lib/octokit/client/search.rb +9 -9
  52. data/lib/octokit/client/service_status.rb +2 -2
  53. data/lib/octokit/client/source_import.rb +6 -6
  54. data/lib/octokit/client/stats.rb +10 -9
  55. data/lib/octokit/client/statuses.rb +5 -5
  56. data/lib/octokit/client/traffic.rb +2 -3
  57. data/lib/octokit/client/users.rb +27 -26
  58. data/lib/octokit/client.rb +25 -11
  59. data/lib/octokit/configurable.rb +33 -27
  60. data/lib/octokit/connection.rb +19 -20
  61. data/lib/octokit/default.rb +16 -15
  62. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  63. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  64. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  65. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  66. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  67. data/lib/octokit/enterprise_admin_client.rb +9 -3
  68. data/lib/octokit/enterprise_management_console_client/management_console.rb +30 -30
  69. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  70. data/lib/octokit/error.rb +23 -21
  71. data/lib/octokit/gist.rb +2 -3
  72. data/lib/octokit/middleware/follow_redirects.rb +12 -11
  73. data/lib/octokit/organization.rb +3 -1
  74. data/lib/octokit/preview.rb +29 -29
  75. data/lib/octokit/rate_limit.rb +3 -3
  76. data/lib/octokit/repo_arguments.rb +2 -3
  77. data/lib/octokit/repository.rb +23 -24
  78. data/lib/octokit/response/base_middleware.rb +2 -0
  79. data/lib/octokit/response/feed_parser.rb +3 -5
  80. data/lib/octokit/response/raise_error.rb +2 -2
  81. data/lib/octokit/user.rb +4 -2
  82. data/lib/octokit/version.rb +4 -2
  83. data/lib/octokit/warnable.rb +3 -6
  84. data/lib/octokit.rb +14 -6
  85. data/octokit.gemspec +11 -9
  86. metadata +23 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1799b946b7c31e79fac5c7119b602d1722151236d02e732a664870a8227f218e
4
- data.tar.gz: 21496697905a025d01e370816a828ddb7ac4201a9ec845ec0d1290d77c44f858
3
+ metadata.gz: dea88415ddb72dde720faee8a6616de5626c6cca81ec294515b96629c2bc8577
4
+ data.tar.gz: 29fdb600f3f18770d7966c03bfa87d2331f06652247698b965d2c9237f38ab16
5
5
  SHA512:
6
- metadata.gz: 0ad2e6793ef84011dd8e290d18773a0c8c5f24e3a584ccdc24d64696382cd6bfca146cd07f6fe7e8b1ee40b9f564a4a2298453bd0c548374c01c7b9e47150bd7
7
- data.tar.gz: 9ef11f4b675a4b08d7d5fafbbccad82b2c1f05488c89604c59af6488222e44e55952a286166e8a3f9658523c3707b6ce35c8942d83dbcbbfae8a6f0b360e8940
6
+ metadata.gz: 334851882f7dc5fd9a3da94926cd64e5ef18ad033e5f1038a71589b77d7c27ddf2c2e28ba3ff7b701750eeb69548080bfc4318056f0a88c690c763947a7453bb
7
+ data.tar.gz: 23724a2b503a15def78f79c03e21659658274a33c6f2f20cb6cc5fa35064dab3e30bb6862cc4164fe040eb3ac890ee63b79171ad2ed79fdad5de8ef323c62811
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Octokit
2
2
 
3
+ > **Note**
4
+ > We've recently renamed the `4-stable` branch to `main`. This might affect you if you're making changes to Octokit's code locally. For more details and for the steps to reconfigure your local clone for the new branch name, check out [this post](https://github.com/octokit/octokit.rb/discussions/1455).
5
+
3
6
  Ruby toolkit for the GitHub API.
4
7
 
5
8
  ![logo](https://docs.github.com/assets/images/gundamcat.png)
@@ -740,8 +743,6 @@ when writing new specs.
740
743
  This library aims to support and is [tested against][actions] the following Ruby
741
744
  implementations:
742
745
 
743
- * Ruby 2.5
744
- * Ruby 2.6
745
746
  * Ruby 2.7
746
747
  * Ruby 3.0
747
748
  * Ruby 3.1
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
4
6
  require 'rspec/core/rake_task'
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
 
7
- task :test => :spec
8
- task :default => :spec
9
+ task test: :spec
10
+ task default: :spec
9
11
 
10
12
  namespace :doc do
11
13
  begin
@@ -14,7 +16,7 @@ namespace :doc do
14
16
  task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
15
17
  task.options = [
16
18
  '--output-dir', 'doc/yard',
17
- '--markup', 'markdown',
19
+ '--markup', 'markdown'
18
20
  ]
19
21
  end
20
22
  rescue LoadError
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sawyer'
2
4
 
3
5
  patch = Module.new do
4
- def href(options=nil)
6
+ def href(options = nil)
5
7
  # Temporary workaround for: https://github.com/octokit/octokit.rb/issues/727
6
- name.to_s == "ssh" ? @href : super
8
+ name.to_s == 'ssh' ? @href : super
7
9
  end
8
10
  end
9
11
 
@@ -1,5 +1,6 @@
1
- module Octokit
1
+ # frozen_string_literal: true
2
2
 
3
+ module Octokit
3
4
  # Extracts options from method arguments
4
5
  # @private
5
6
  class Arguments < Array
@@ -9,6 +10,5 @@ module Octokit
9
10
  @options = args.last.is_a?(::Hash) ? args.pop : {}
10
11
  super(args)
11
12
  end
12
-
13
13
  end
14
14
  end
@@ -1,12 +1,12 @@
1
- module Octokit
1
+ # frozen_string_literal: true
2
2
 
3
+ module Octokit
3
4
  # Authentication methods for {Octokit::Client}
4
5
  module Authentication
5
-
6
6
  # In Faraday 2.x, the authorization middleware uses new interface
7
7
  FARADAY_BASIC_AUTH_KEYS =
8
8
  if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
9
- [:authorization, :basic]
9
+ %i[authorization basic]
10
10
  else
11
11
  [:basic_auth]
12
12
  end
@@ -74,8 +74,7 @@ module Octokit
74
74
  self.password = creds.shift
75
75
  end
76
76
  rescue LoadError
77
- octokit_warn "Please install netrc gem for .netrc support"
77
+ octokit_warn 'Please install netrc gem for .netrc support'
78
78
  end
79
-
80
79
  end
81
80
  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 Actions Secrets API
5
6
  #
6
7
  # @see https://developer.github.com/v3/actions/secrets/
7
8
  module ActionsSecrets
8
-
9
9
  # Get public key for secrets encryption
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -15,7 +15,6 @@ module Octokit
15
15
  get "#{Repository.path repo}/actions/secrets/public-key"
16
16
  end
17
17
 
18
-
19
18
  # List secrets
20
19
  #
21
20
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
5
  module ActionsWorkflowRuns
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
5
  # Methods for the Actions Workflows API
4
6
  #
5
7
  # @see https://developer.github.com/v3/actions/workflows
6
8
  module ActionsWorkflows
7
-
8
9
  # Get the workflows in a repository
9
10
  #
10
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Apps API
5
6
  module Apps
6
-
7
7
  # Get the authenticated App
8
8
  #
9
9
  # @param options [Hash] A customizable set of options
@@ -12,7 +12,7 @@ module Octokit
12
12
  #
13
13
  # @return [Sawyer::Resource] App information
14
14
  def app(options = {})
15
- get "app", options
15
+ get 'app', options
16
16
  end
17
17
 
18
18
  # Find all installations that belong to an App
@@ -23,16 +23,16 @@ module Octokit
23
23
  #
24
24
  # @return [Array<Sawyer::Resource>] the total_count and an array of installations
25
25
  def find_app_installations(options = {})
26
- paginate "app/installations", options
26
+ paginate 'app/installations', options
27
27
  end
28
28
  alias find_installations find_app_installations
29
29
 
30
30
  def find_integration_installations(options = {})
31
31
  octokit_warn(
32
- "Deprecated: Octokit::Client::Apps#find_integration_installations "\
33
- "method is deprecated. Please update your call to use "\
34
- "Octokit::Client::Apps#find_app_installations before the next major "\
35
- "Octokit version update."
32
+ 'Deprecated: Octokit::Client::Apps#find_integration_installations '\
33
+ 'method is deprecated. Please update your call to use '\
34
+ 'Octokit::Client::Apps#find_app_installations before the next major '\
35
+ 'Octokit version update.'
36
36
  )
37
37
  find_app_installations(options)
38
38
  end
@@ -45,7 +45,7 @@ module Octokit
45
45
  #
46
46
  # @return [Sawyer::Resource] the total_count and an array of installations
47
47
  def find_user_installations(options = {})
48
- paginate("user/installations", options) do |data, last_response|
48
+ paginate('user/installations', options) do |data, last_response|
49
49
  data.installations.concat last_response.data.installations
50
50
  end
51
51
  end
@@ -76,10 +76,10 @@ module Octokit
76
76
 
77
77
  def create_integration_installation_access_token(installation, options = {})
78
78
  octokit_warn(
79
- "Deprecated: Octokit::Client::Apps#create_integration_installation_access_token "\
80
- "method is deprecated. Please update your call to use "\
81
- "Octokit::Client::Apps#create_app_installation_access_token before the next major "\
82
- "Octokit version update."
79
+ 'Deprecated: Octokit::Client::Apps#create_integration_installation_access_token '\
80
+ 'method is deprecated. Please update your call to use '\
81
+ 'Octokit::Client::Apps#create_app_installation_access_token before the next major '\
82
+ 'Octokit version update.'
83
83
  )
84
84
  create_app_installation_access_token(installation, options)
85
85
  end
@@ -128,7 +128,7 @@ module Octokit
128
128
  #
129
129
  # @return [Sawyer::Resource] the total_count and an array of repositories
130
130
  def list_app_installation_repositories(options = {})
131
- paginate("installation/repositories", options) do |data, last_response|
131
+ paginate('installation/repositories', options) do |data, last_response|
132
132
  data.repositories.concat last_response.data.repositories
133
133
  end
134
134
  end
@@ -136,10 +136,10 @@ module Octokit
136
136
 
137
137
  def list_integration_installation_repositories(options = {})
138
138
  octokit_warn(
139
- "Deprecated: Octokit::Client::Apps#list_integration_installation_repositories "\
140
- "method is deprecated. Please update your call to use "\
141
- "Octokit::Client::Apps#list_app_installation_repositories before the next major "\
142
- "Octokit version update."
139
+ 'Deprecated: Octokit::Client::Apps#list_integration_installation_repositories '\
140
+ 'method is deprecated. Please update your call to use '\
141
+ 'Octokit::Client::Apps#list_app_installation_repositories before the next major '\
142
+ 'Octokit version update.'
143
143
  )
144
144
  list_app_installation_repositories(options)
145
145
  end
@@ -160,10 +160,10 @@ module Octokit
160
160
 
161
161
  def add_repository_to_integration_installation(installation, repo, options = {})
162
162
  octokit_warn(
163
- "Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation "\
164
- "method is deprecated. Please update your call to use "\
165
- "Octokit::Client::Apps#add_repository_to_app_installation before the next major "\
166
- "Octokit version update."
163
+ 'Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation '\
164
+ 'method is deprecated. Please update your call to use '\
165
+ 'Octokit::Client::Apps#add_repository_to_app_installation before the next major '\
166
+ 'Octokit version update.'
167
167
  )
168
168
  add_repository_to_app_installation(installation, repo, options)
169
169
  end
@@ -184,10 +184,10 @@ module Octokit
184
184
 
185
185
  def remove_repository_from_integration_installation(installation, repo, options = {})
186
186
  octokit_warn(
187
- "Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation "\
188
- "method is deprecated. Please update your call to use "\
189
- "Octokit::Client::Apps#remove_repository_from_app_installation before the next major "\
190
- "Octokit version update."
187
+ 'Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation '\
188
+ 'method is deprecated. Please update your call to use '\
189
+ 'Octokit::Client::Apps#remove_repository_from_app_installation before the next major '\
190
+ 'Octokit version update.'
191
191
  )
192
192
  remove_repository_from_app_installation(installation, repo, options)
193
193
  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 Authorizations API
5
6
  #
6
7
  # @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
7
8
  module Authorizations
8
-
9
9
  # List the authenticated user's authorizations
10
10
  #
11
11
  # API for users to manage their own tokens.
@@ -64,16 +64,18 @@ module Octokit
64
64
  options = options.dup
65
65
  if options.delete :idempotent
66
66
  client_id, client_secret = fetch_client_id_and_secret(options)
67
- raise ArgumentError.new("Client ID and Secret required for idempotent authorizations") unless client_id && client_secret
67
+ unless client_id && client_secret
68
+ raise ArgumentError, 'Client ID and Secret required for idempotent authorizations'
69
+ end
68
70
 
69
71
  # Remove the client_id from the body otherwise
70
72
  # this will result in a 422.
71
73
  options.delete(:client_id)
72
74
 
73
75
  if (fingerprint = options.delete(:fingerprint))
74
- put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(:client_secret => client_secret)
76
+ put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(client_secret: client_secret)
75
77
  else
76
- put "authorizations/clients/#{client_id}", options.merge(:client_secret => client_secret)
78
+ put "authorizations/clients/#{client_id}", options.merge(client_secret: client_secret)
77
79
  end
78
80
 
79
81
  else
@@ -126,18 +128,18 @@ module Octokit
126
128
  # @return [Array<String>] OAuth scopes
127
129
  # @see https://developer.github.com/v3/oauth/#scopes
128
130
  def scopes(token = @access_token, options = {})
129
- options= options.dup
130
- raise ArgumentError.new("Access token required") if token.nil?
131
+ options = options.dup
132
+ raise ArgumentError, 'Access token required' if token.nil?
131
133
 
132
- auth = { "Authorization" => "token #{token}" }
134
+ auth = { 'Authorization' => "token #{token}" }
133
135
  headers = (options.delete(:headers) || {}).merge(auth)
134
136
 
135
- agent.call(:get, "user", :headers => headers).
136
- headers['X-OAuth-Scopes'].
137
- to_s.
138
- split(',').
139
- map(&:strip).
140
- sort
137
+ agent.call(:get, 'user', headers: headers)
138
+ .headers['X-OAuth-Scopes']
139
+ .to_s
140
+ .split(',')
141
+ .map(&:strip)
142
+ .sort
141
143
  end
142
144
 
143
145
  # Revoke all tokens for an app
@@ -146,8 +148,8 @@ module Octokit
146
148
  #
147
149
  # @deprecated As of January 25th, 2016: https://developer.github.com/changes/2014-04-08-reset-api-tokens/
148
150
  # @return [Boolean] false
149
- def revoke_all_application_authorizations(options = {})
150
- octokit_warn("Deprecated: If you need to revoke all tokens for your application, you can do so via the settings page for your application.")
151
+ def revoke_all_application_authorizations(_options = {})
152
+ octokit_warn('Deprecated: If you need to revoke all tokens for your application, you can do so via the settings page for your application.')
151
153
  false
152
154
  end
153
155
 
@@ -165,8 +167,9 @@ module Octokit
165
167
  def authorize_url(app_id = client_id, options = {})
166
168
  opts = options.dup
167
169
  if app_id.to_s.empty?
168
- raise Octokit::ApplicationCredentialsRequired, "client_id required"
170
+ raise Octokit::ApplicationCredentialsRequired, 'client_id required'
169
171
  end
172
+
170
173
  authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
171
174
  authorize_url << "login/oauth/authorize?client_id=#{app_id}"
172
175
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Checks API
5
6
  #
6
7
  # @see https://developer.github.com/v3/checks/
7
8
  module Checks
8
-
9
9
  # Methods for Check Runs
10
10
  #
11
11
  # @see https://developer.github.com/v3/checks/runs/
@@ -65,7 +65,7 @@ module Octokit
65
65
  data.total_count += last_response.data.total_count
66
66
  end
67
67
  end
68
- alias :list_check_runs_for_ref :check_runs_for_ref
68
+ alias list_check_runs_for_ref check_runs_for_ref
69
69
 
70
70
  # List check runs in a check suite
71
71
  #
@@ -89,7 +89,7 @@ module Octokit
89
89
  data.total_count += last_response.data.total_count
90
90
  end
91
91
  end
92
- alias :list_check_runs_for_check_suite :check_runs_for_check_suite
92
+ alias list_check_runs_for_check_suite check_runs_for_check_suite
93
93
 
94
94
  # Get a single check run
95
95
  #
@@ -151,7 +151,7 @@ module Octokit
151
151
  data.total_count += last_response.data.total_count
152
152
  end
153
153
  end
154
- alias :list_check_suites_for_ref :check_suites_for_ref
154
+ alias list_check_suites_for_ref check_suites_for_ref
155
155
 
156
156
  # Set preferences for check suites on a repository
157
157
  #
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Branches for HEAD API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/commits/
7
8
  module CommitBranches
8
-
9
9
  # List branches for a single HEAD commit
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -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 Comments API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/comments/
7
8
  module CommitComments
8
-
9
9
  # List all commit comments
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -53,12 +53,12 @@ module Octokit
53
53
  # comment.path # => "README.md"
54
54
  # comment.line # => 10
55
55
  # comment.position # => 1
56
- def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options = {})
56
+ def create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {})
57
57
  params = {
58
- :body => body,
59
- :path => path,
60
- :line => line,
61
- :position => position
58
+ body: body,
59
+ path: path,
60
+ line: line,
61
+ position: position
62
62
  }
63
63
  post "#{Repository.path repo}/commits/#{sha}/comments", options.merge(params)
64
64
  end
@@ -76,7 +76,7 @@ module Octokit
76
76
  # comment.body # => "Updated commit comment"
77
77
  def update_commit_comment(repo, id, body, options = {})
78
78
  params = {
79
- :body => body
79
+ body: body
80
80
  }
81
81
  patch "#{Repository.path repo}/comments/#{id}", options.merge(params)
82
82
  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 Pulls API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/comments/
7
8
  module CommitPulls
8
-
9
9
  # List pulls for a single commit
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -1,13 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
 
3
5
  module Octokit
4
6
  class Client
5
-
6
7
  # Methods for the Commits API
7
8
  #
8
9
  # @see https://developer.github.com/v3/repos/commits/
9
10
  module Commits
10
-
11
11
  # List commits
12
12
  #
13
13
  # @overload commits(repo, sha_or_branch, options = {})
@@ -23,12 +23,10 @@ module Octokit
23
23
  def commits(*args)
24
24
  arguments = Octokit::RepoArguments.new(args)
25
25
  sha_or_branch = arguments.pop
26
- if sha_or_branch
27
- arguments.options[:sha] = sha_or_branch
28
- end
26
+ arguments.options[:sha] = sha_or_branch if sha_or_branch
29
27
  paginate "#{Repository.new(arguments.repo).path}/commits", arguments.options
30
28
  end
31
- alias :list_commits :commits
29
+ alias list_commits commits
32
30
 
33
31
  # Get commits after a specified date
34
32
  #
@@ -48,13 +46,11 @@ module Octokit
48
46
  # Octokit.commits_since('octokit/octokit.rb', '2012-10-01')
49
47
  def commits_since(*args)
50
48
  arguments = Octokit::RepoArguments.new(args)
51
- date = parse_date(arguments.shift)
49
+ date = parse_date(arguments.shift)
52
50
  params = arguments.options
53
- params.merge!(:since => iso8601(date))
51
+ params.merge!(since: iso8601(date))
54
52
  sha_or_branch = arguments.pop
55
- if sha_or_branch
56
- params[:sha] = sha_or_branch
57
- end
53
+ params[:sha] = sha_or_branch if sha_or_branch
58
54
  commits(arguments.repo, params)
59
55
  end
60
56
 
@@ -74,13 +70,11 @@ module Octokit
74
70
  # Octokit.commits_before('octokit/octokit.rb', '2012-10-01')
75
71
  def commits_before(*args)
76
72
  arguments = Octokit::RepoArguments.new(args)
77
- date = parse_date(arguments.shift)
73
+ date = parse_date(arguments.shift)
78
74
  params = arguments.options
79
- params.merge!(:until => iso8601(date))
75
+ params.merge!(until: iso8601(date))
80
76
  sha_or_branch = arguments.pop
81
- if sha_or_branch
82
- params[:sha] = sha_or_branch
83
- end
77
+ params[:sha] = sha_or_branch if sha_or_branch
84
78
  commits(arguments.repo, params)
85
79
  end
86
80
 
@@ -100,14 +94,12 @@ module Octokit
100
94
  # Octokit.commits_on('octokit/octokit.rb', '2012-10-01')
101
95
  def commits_on(*args)
102
96
  arguments = Octokit::RepoArguments.new(args)
103
- date = parse_date(arguments.shift)
97
+ date = parse_date(arguments.shift)
104
98
  params = arguments.options
105
99
  end_date = date + 1
106
- params.merge!(:since => iso8601(date), :until => iso8601(end_date))
100
+ params.merge!(since: iso8601(date), until: iso8601(end_date))
107
101
  sha_or_branch = arguments.pop
108
- if sha_or_branch
109
- params[:sha] = sha_or_branch
110
- end
102
+ params[:sha] = sha_or_branch if sha_or_branch
111
103
  commits(arguments.repo, params)
112
104
  end
113
105
 
@@ -129,16 +121,16 @@ module Octokit
129
121
  # Octokit.commits_between('octokit/octokit.rb', '2012-10-01', '2012-11-01')
130
122
  def commits_between(*args)
131
123
  arguments = Octokit::RepoArguments.new(args)
132
- date = parse_date(arguments.shift)
133
- end_date = parse_date(arguments.shift)
134
- raise ArgumentError, "Start date #{date} does not precede #{end_date}" if date > end_date
124
+ date = parse_date(arguments.shift)
125
+ end_date = parse_date(arguments.shift)
126
+ if date > end_date
127
+ raise ArgumentError, "Start date #{date} does not precede #{end_date}"
128
+ end
135
129
 
136
130
  params = arguments.options
137
- params.merge!(:since => iso8601(date), :until => iso8601(end_date))
131
+ params.merge!(since: iso8601(date), until: iso8601(end_date))
138
132
  sha_or_branch = arguments.pop
139
- if sha_or_branch
140
- params[:sha] = sha_or_branch
141
- end
133
+ params[:sha] = sha_or_branch if sha_or_branch
142
134
  commits(arguments.repo, params)
143
135
  end
144
136
 
@@ -181,8 +173,8 @@ module Octokit
181
173
  # commit.tree.sha # => "827efc6d56897b048c772eb4087f854f46256132"
182
174
  # commit.message # => "My commit message"
183
175
  # commit.committer # => { "name" => "Wynn Netherland", "email" => "wynn@github.com", ... }
184
- def create_commit(repo, message, tree, parents=nil, options = {})
185
- params = { :message => message, :tree => tree }
176
+ def create_commit(repo, message, tree, parents = nil, options = {})
177
+ params = { message: message, tree: tree }
186
178
  params[:parents] = [parents].flatten if parents
187
179
  post "#{Repository.path repo}/git/commits", options.merge(params)
188
180
  end
@@ -213,8 +205,8 @@ module Octokit
213
205
  # @see https://developer.github.com/v3/repos/merging/#perform-a-merge
214
206
  def merge(repo, base, head, options = {})
215
207
  params = {
216
- :base => base,
217
- :head => head
208
+ base: base,
209
+ head: head
218
210
  }.merge(options)
219
211
  post "#{Repository.path repo}/merges", params
220
212
  end
@@ -225,7 +217,7 @@ module Octokit
225
217
  if date.respond_to?(:iso8601)
226
218
  date.iso8601
227
219
  else
228
- date.strftime("%Y-%m-%dT%H:%M:%S%Z")
220
+ date.strftime('%Y-%m-%dT%H:%M:%S%Z')
229
221
  end
230
222
  end
231
223
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Community Profile API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/community/
7
8
  module CommunityProfile
8
-
9
9
  # Get community profile metrics for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository