firespring_dev_commands 2.2.1.pre.alpha.2 → 2.2.1.pre.alpha.3

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: 80f7cbb7c7fd0fa661779ae3693d16d3b2a9be96f836c998eac45b9163282212
4
- data.tar.gz: 6633fe3fe43c94b4da08743e629c7e7a16c92376f8350b0bf121ab79fc7f08e8
3
+ metadata.gz: 7f7ee4edb84fcf55633780edce93e62119ba287da59fd45ce4a7b06109ce9e75
4
+ data.tar.gz: 3344e8910159e5b5df252b807b006c366956ce0220b2b65d6e5a92be9e958484
5
5
  SHA512:
6
- metadata.gz: e7c4cf41cbf9dd669c9c2cc05550335e33d873105b3e37a1099a95560f16e9d920719b170de3719c67f5981c42d7e48f445e18cf35aed4dd1bd00194d6b00c26
7
- data.tar.gz: 9e0f0898fad325bd3903fd773584ce5e4ef16114a8fd4fb60530db07a585a2b4cedd4900b53e43d4e74fd42ec0db0d3040770d7d836f7555500d0a39b8ac3f59
6
+ metadata.gz: 6f93bd21df947af3689c965be24f664fe23841c522ab2a90c2fe0b1b4642f774805426da93ffab856c03ec99e77bd06e4b5af5a83d40c833fb217826c991566a
7
+ data.tar.gz: 80cd78d0f4f92c7334c2908d317596782b2bec357d556983388ee6cf97e623f9210853a928f1e4823fa2536cbec0dd97af3f9243ecb3e48ee8bb244569e68bbf
@@ -409,7 +409,10 @@ module Dev
409
409
  # Clones the repo_name into the dir
410
410
  # Optionally specify a repo_org
411
411
  # Optionally specify a branch to check out (defaults to the repository default branch)
412
- 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
+
413
416
  if Dir.exist?("#{dir}/.git")
414
417
  puts "#{dir} already cloned".light_green
415
418
  return
@@ -426,12 +429,15 @@ module Dev
426
429
  g.fetch('origin', prune: true)
427
430
  end
428
431
 
429
- def commit_status(token:, repository:, branch:, status:, organization: 'firespring', options: {})
432
+ def commit_status(token:, repo_name:, branch:, 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
+
430
436
  # Set up the GitHub client
431
437
  client = Octokit::Client.new(access_token: token)
432
438
 
433
439
  # Fetch the latest commit SHA for the given branch
434
- repo = "#{organization}/#{repository}"
440
+ repo = "#{repo_org}/#{repo_name}"
435
441
  ref = "heads/#{branch}"
436
442
  sha = client.ref(repo, ref).object.sha
437
443
 
@@ -160,57 +160,153 @@ module Dev
160
160
  end
161
161
  end
162
162
 
163
- # rubocop:disable Metrics/MethodLength
164
- # Create the rake task for the git commit status task.
165
- def create_commit_status_task!
163
+ # Create the rake task for the git commit status pending task.
164
+ def create_commit_status_pending_task!
166
165
  # Have to set a local variable to be accessible inside of the instance_eval block
167
166
  exclude = @exclude
167
+
168
168
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
169
169
  namespace :git do
170
170
  return if exclude.include?(:commit_status)
171
171
 
172
- desc 'Add status to PR' \
173
- "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \
174
- "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \
175
- "\n\tuse BRANCH=abc123 to specify the branch of code (required)" \
176
- "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \
177
- "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)"
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 BRANCH=abc123 to specify the branch 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
+ branch = ENV['BRANCH'].to_s.strip
178
184
 
179
- # Key Values
180
- token = ENV['GITHUB_TOKEN'].to_s.strip
181
- repository = ENV['REPOSITORY'].to_s.strip
182
- branch = ENV['BRANCH'].to_s.strip
185
+ raise 'GITHUB_TOKEN is required' unless token
186
+ raise 'Repository name is required' unless repo_name
187
+ raise 'Branch name is required' unless branch
183
188
 
184
- raise 'GITHUB_TOKEN is required' unless token
185
- raise 'Repository name is required' unless repository
186
- raise 'Branch name is required' unless branch
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?
187
192
 
188
- options = {}
189
- options[:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty?
190
- options[:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty?
193
+ Dev::Git.new.commit_status(token:, repo_name:, branch:, 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)
191
208
 
192
209
  namespace :commit_status do
193
- desc 'Add status success'
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 BRANCH=abc123 to specify the branch 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)"
194
216
  task :success do
195
- Dev::Git.new.commit_status(token:, repository:, branch:, status: 'success', options:)
196
- end
197
- desc 'Add status pending'
198
- task :pending do
199
- Dev::Git.new.commit_status(token:, repository:, branch:, status: 'pending', options:)
217
+ status = 'success'
218
+ token = ENV['GITHUB_TOKEN'].to_s.strip
219
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
220
+ branch = ENV['BRANCH'].to_s.strip
221
+
222
+ raise 'GITHUB_TOKEN is required' unless token
223
+ raise 'Repository name is required' unless repo_name
224
+ raise 'Branch name is required' unless branch
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:, branch:, status:, repo_org:, options:)
200
231
  end
201
- desc 'Add status error'
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 BRANCH=abc123 to specify the branch 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)"
202
253
  task :error do
203
- Dev::Git.new.commit_status(token:, repository:, branch:, status: 'error', options:)
254
+ status = 'error'
255
+ token = ENV['GITHUB_TOKEN'].to_s.strip
256
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
257
+ branch = ENV['BRANCH'].to_s.strip
258
+
259
+ raise 'GITHUB_TOKEN is required' unless token
260
+ raise 'Repository name is required' unless repo_name
261
+ raise 'Branch name is required' unless branch
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:, branch:, status:, repo_org:, options:)
204
268
  end
205
- desc 'Add status failure'
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 BRANCH=abc123 to specify the branch 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)"
206
290
  task :failure do
207
- Dev::Git.new.commit_status(token:, repository:, branch:, status: 'failure', options:)
291
+ status = 'failure'
292
+ token = ENV['GITHUB_TOKEN'].to_s.strip
293
+ repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/')
294
+ branch = ENV['BRANCH'].to_s.strip
295
+
296
+ raise 'GITHUB_TOKEN is required' unless token
297
+ raise 'Repository name is required' unless repo_name
298
+ raise 'Branch name is required' unless branch
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:, branch:, status:, repo_org:, options:)
208
305
  end
209
306
  end
210
307
  end
211
308
  end
212
309
  end
213
- # rubocop:enable Metrics/MethodLength
214
310
  end
215
311
  end
216
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.1.pre.alpha.2'.freeze
9
+ VERSION = '2.2.1.pre.alpha.3'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.pre.alpha.2
4
+ version: 2.2.1.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring