firespring_dev_commands 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 599f3f484514462356186c8d52adfac32e8aa925f7aeaa488bb5fa109db678f3
4
- data.tar.gz: 3dffab80edf84b75d073adfc21c1a2c3e0d9dcc666a526f2bda2d5471ff24d6e
3
+ metadata.gz: d8423e2a17f9e8a139792033ae83b26554120e41dcca5c16f2060bfc5abbf174
4
+ data.tar.gz: bd7d8d48505e4a81d025aab930d699b8684f585015347ee3f5fb18f3f6744d7f
5
5
  SHA512:
6
- metadata.gz: 0ea2c7d6d09e1e5ad6a85ee3d7d3e90826018bee1afc7c1ce1a206ca8514b658c8ef29534dc5b4082bf185d1540a9292218eb3836f6c3405b44d3ff10d98b484
7
- data.tar.gz: c06fa865de8acedba8ec7b2934094f7a03fb46e2e1d5a116fc2b12fa4febcf6874940771a843bb022f5f571d5b77e9d4f00d5b3f4930f4cd2f16aa44293a66dd
6
+ metadata.gz: 617153db6a841f9b95e7406d2bf0b32a2936af106a7c40f3dd36d4b4a28f75c3c9dd7fa1af482f3192d7f500aa2d7f2da9b18f121de9cccadaada54a9f589084
7
+ data.tar.gz: 1cc7768227e3f5589b1485306ac411016088bd7bad19cfb13af1c4fc7bb22692564e5f68ef1a1f7a48b38bce98f63844a302966f58e0ea8aae1e7620a8325f28
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'git'
3
+ require 'octokit'
3
4
 
4
5
  module Dev
5
6
  # Class for performing git functions
@@ -408,7 +409,10 @@ module Dev
408
409
  # Clones the repo_name into the dir
409
410
  # Optionally specify a repo_org
410
411
  # Optionally specify a branch to check out (defaults to the repository default branch)
411
- def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil, depth: nil)
412
+ def clone_repo(dir:, repo_name:, repo_org: nil, branch: nil, depth: nil)
413
+ # TODO: Split out the default of 'firespring' into a configuration variable
414
+ repo_org = 'firespring' if repo_org.to_s.strip.empty?
415
+
412
416
  if Dir.exist?("#{dir}/.git")
413
417
  puts "#{dir} already cloned".light_green
414
418
  return
@@ -425,6 +429,19 @@ module Dev
425
429
  g.fetch('origin', prune: true)
426
430
  end
427
431
 
432
+ def commit_status(token:, repo_name:, commit_id:, status:, repo_org: nil, options: {})
433
+ # TODO: Split out the default of 'firespring' into a configuration variable
434
+ repo_org = 'firespring' if repo_org.to_s.strip.empty?
435
+ repo = "#{repo_org}/#{repo_name}"
436
+
437
+ # Set up the GitHub client
438
+ client = Octokit::Client.new(access_token: token)
439
+
440
+ # Create the commit status
441
+ puts "Tagging commit #{commit_id} in #{repo} as #{status} for #{options[:context]}"
442
+ client.create_status(repo, commit_id, status, options)
443
+ end
444
+
428
445
  # Builds an ssh repo URL using the org and repo name given
429
446
  def ssh_repo_url(name, org)
430
447
  "git@github.com:#{org}/#{name}.git"
@@ -159,6 +159,154 @@ module Dev
159
159
  end
160
160
  end
161
161
  end
162
+
163
+ # Create the rake task for the git commit status pending task.
164
+ def create_commit_status_pending_task!
165
+ # Have to set a local variable to be accessible inside of the instance_eval block
166
+ exclude = @exclude
167
+
168
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
169
+ namespace :git do
170
+ return if exclude.include?(:commit_status)
171
+
172
+ namespace :commit_status do
173
+ desc 'Add pending status to commit' \
174
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
175
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
176
+ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
177
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
178
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
179
+ task :pending do
180
+ status = 'pending'
181
+ token = ENV['GITHUB_TOKEN'].to_s.strip
182
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
183
+ commit_id = ENV['COMMIT_ID'].to_s.strip
184
+
185
+ raise 'GITHUB_TOKEN is required' unless token
186
+ raise 'REPOSITORY is required' unless repo_name
187
+ raise 'COMMIT_ID is required' unless commit_id
188
+
189
+ options = {}
190
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
191
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
192
+
193
+ Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+
200
+ # Create the rake task for the git commit status success task.
201
+ def create_commit_status_success_task!
202
+ # Have to set a local variable to be accessible inside of the instance_eval block
203
+ exclude = @exclude
204
+
205
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
206
+ namespace :git do
207
+ return if exclude.include?(:commit_status)
208
+
209
+ namespace :commit_status do
210
+ desc 'Add success status to commit' \
211
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
212
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
213
+ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
214
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
215
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
216
+ task :success do
217
+ status = 'success'
218
+ token = ENV['GITHUB_TOKEN'].to_s.strip
219
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
220
+ commit_id = ENV['COMMIT_ID'].to_s.strip
221
+
222
+ raise 'GITHUB_TOKEN is required' unless token
223
+ raise 'REPOSITORY is required' unless repo_name
224
+ raise 'COMMIT_ID is required' unless commit_id
225
+
226
+ options = {}
227
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
228
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
229
+
230
+ Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
236
+
237
+ # Create the rake task for the git commit status error task.
238
+ def create_commit_status_error_task!
239
+ # Have to set a local variable to be accessible inside of the instance_eval block
240
+ exclude = @exclude
241
+
242
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
243
+ namespace :git do
244
+ return if exclude.include?(:commit_status)
245
+
246
+ namespace :commit_status do
247
+ desc 'Add error status to commit' \
248
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
249
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
250
+ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
251
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
252
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
253
+ task :error do
254
+ status = 'error'
255
+ token = ENV['GITHUB_TOKEN'].to_s.strip
256
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
257
+ commit_id = ENV['COMMIT_ID'].to_s.strip
258
+
259
+ raise 'GITHUB_TOKEN is required' unless token
260
+ raise 'REPOSITORY is required' unless repo_name
261
+ raise 'COMMIT_ID is required' unless commit_id
262
+
263
+ options = {}
264
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
265
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
266
+
267
+ Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ # Create the rake task for the git commit status failure task.
275
+ def create_commit_status_failure_task!
276
+ # Have to set a local variable to be accessible inside of the instance_eval block
277
+ exclude = @exclude
278
+
279
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
280
+ namespace :git do
281
+ return if exclude.include?(:commit_status)
282
+
283
+ namespace :commit_status do
284
+ desc 'Add failure status to commit' \
285
+ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
286
+ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
287
+ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \
288
+ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
289
+ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
290
+ task :failure do
291
+ status = 'failure'
292
+ token = ENV['GITHUB_TOKEN'].to_s.strip
293
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
294
+ commit_id = ENV['COMMIT_ID'].to_s.strip
295
+
296
+ raise 'GITHUB_TOKEN is required' unless token
297
+ raise 'REPOSITORY is required' unless repo_name
298
+ raise 'COMMIT_ID is required' unless commit_id
299
+
300
+ options = {}
301
+ options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
302
+ options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
303
+
304
+ Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:)
305
+ end
306
+ end
307
+ end
308
+ end
309
+ end
162
310
  end
163
311
  end
164
312
  end
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.2.3'.freeze
9
+ VERSION = '2.2.4'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-02 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: 2.8.1
223
+ - !ruby/object:Gem::Dependency
224
+ name: faraday-retry
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '2.0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '2.0'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: git
225
239
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +276,20 @@ dependencies:
262
276
  - - "~>"
263
277
  - !ruby/object:Gem::Version
264
278
  version: 2.3.0
279
+ - !ruby/object:Gem::Dependency
280
+ name: octokit
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '8.1'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '8.1'
265
293
  - !ruby/object:Gem::Dependency
266
294
  name: ox
267
295
  requirement: !ruby/object:Gem::Requirement