dependabot-common 0.120.1 → 0.120.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e821980897c896e2168012ad53b0abfbef9d7f74b12da81c9fdcbbfbe7a979a3
4
- data.tar.gz: 4a0184cde0aaa924ebca0068094cf299f67d7c4bc51bdec4c467e84bc1c57823
3
+ metadata.gz: 83263fa7e5a3d1dbd38624d9476cab98b226ef442af42cd6e9324dcb61226476
4
+ data.tar.gz: a47175b2fb55cb804e95a1f438f21de893f73b3921b319bcb296e3ff7f0397da
5
5
  SHA512:
6
- metadata.gz: fe4f0b9234032f9728db6e8fe08269f001241dfd0012b99410678ab1a1c5ef1388d10d94fd4f7e27cb3329a7049d7de06659b09790dce9d16a95a6bc0fbc6f85
7
- data.tar.gz: 0f3139f4c4271e542c3ae30b231f909538caeace5a7d47bbd0da3873c2e9a3a13a2b768eadebe85ef4167b4834c305d7fb3decbc088dbfcba7b2f0a577a869c0
6
+ metadata.gz: c04da188b4d2914b86db40c0640074d45010ce6f0834117b3b6b9faf6371893af47bafd643b4d905a5db2f853c21e3c6cc8c40df38659b93281299820fb6b812
7
+ data.tar.gz: f6e8639ddfc7ffdd50926c3f32e1087076f3e66ad915eb074663669537b37b993df346dda6fc35144e0fd02aedba423b609e5d6eb596d35ecc67cace0c2c12f7
@@ -184,11 +184,12 @@ module Dependabot
184
184
  def get(url)
185
185
  response = Excon.get(
186
186
  url,
187
- headers: auth_header,
188
187
  user: credentials&.fetch("username", nil),
189
188
  password: credentials&.fetch("password", nil),
190
189
  idempotent: true,
191
- **SharedHelpers.excon_defaults
190
+ **SharedHelpers.excon_defaults(
191
+ headers: auth_header
192
+ )
192
193
  )
193
194
  raise NotFound if response.status == 404
194
195
 
@@ -198,16 +199,17 @@ module Dependabot
198
199
  def post(url, json)
199
200
  response = Excon.post(
200
201
  url,
201
- headers: auth_header.merge(
202
- {
203
- "Content-Type" => "application/json"
204
- }
205
- ),
206
202
  body: json,
207
203
  user: credentials&.fetch("username", nil),
208
204
  password: credentials&.fetch("password", nil),
209
205
  idempotent: true,
210
- **SharedHelpers.excon_defaults
206
+ **SharedHelpers.excon_defaults(
207
+ headers: auth_header.merge(
208
+ {
209
+ "Content-Type" => "application/json"
210
+ }
211
+ )
212
+ )
211
213
  )
212
214
  raise NotFound if response.status == 404
213
215
 
@@ -183,7 +183,7 @@ module Dependabot
183
183
 
184
184
  def excon_defaults
185
185
  # Some git hosts are slow when returning a large number of tags
186
- SharedHelpers.excon_defaults.merge(read_timeout: 20)
186
+ SharedHelpers.excon_defaults(read_timeout: 20)
187
187
  end
188
188
  end
189
189
  end
@@ -13,6 +13,10 @@ module Dependabot
13
13
  BUMP_TMP_FILE_PREFIX = "dependabot_"
14
14
  BUMP_TMP_DIR_PATH = "tmp"
15
15
  GIT_CONFIG_GLOBAL_PATH = File.expand_path("~/.gitconfig")
16
+ USER_AGENT = "dependabot-core/#{Dependabot::VERSION} "\
17
+ "#{Excon::USER_AGENT} ruby/#{RUBY_VERSION} "\
18
+ "(#{RUBY_PLATFORM}) "\
19
+ "(+https://github.com/dependabot/dependabot-core)"
16
20
 
17
21
  class ChildProcessFailed < StandardError
18
22
  attr_reader :error_class, :error_message, :error_backtrace
@@ -138,14 +142,23 @@ module Dependabot
138
142
  [Excon::Middleware::RedirectFollower]
139
143
  end
140
144
 
141
- def self.excon_defaults
145
+ def self.excon_headers(headers = nil)
146
+ headers ||= {}
147
+ {
148
+ "User-Agent" => USER_AGENT
149
+ }.merge(headers)
150
+ end
151
+
152
+ def self.excon_defaults(options = nil)
153
+ options ||= {}
142
154
  {
143
155
  connect_timeout: 5,
144
156
  write_timeout: 5,
145
157
  read_timeout: 20,
146
158
  omit_default_port: true,
147
- middlewares: excon_middleware
148
- }
159
+ middlewares: excon_middleware,
160
+ headers: excon_headers(options[:headers])
161
+ }.merge(options)
149
162
  end
150
163
 
151
164
  def self.with_git_configured(credentials:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.120.1"
4
+ VERSION = "0.120.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.120.1
4
+ version: 0.120.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot