firespring_dev_commands 2.2.1.pre.alpha.1 → 2.2.1.pre.alpha.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80f7cbb7c7fd0fa661779ae3693d16d3b2a9be96f836c998eac45b9163282212
|
4
|
+
data.tar.gz: 6633fe3fe43c94b4da08743e629c7e7a16c92376f8350b0bf121ab79fc7f08e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c4cf41cbf9dd669c9c2cc05550335e33d873105b3e37a1099a95560f16e9d920719b170de3719c67f5981c42d7e48f445e18cf35aed4dd1bd00194d6b00c26
|
7
|
+
data.tar.gz: 9e0f0898fad325bd3903fd773584ce5e4ef16114a8fd4fb60530db07a585a2b4cedd4900b53e43d4e74fd42ec0db0d3040770d7d836f7555500d0a39b8ac3f59
|
@@ -7,7 +7,7 @@ module Dev
|
|
7
7
|
# By default, the subshell is connected to the stdin/stdout/stderr of the current program
|
8
8
|
# By default, the current environment is passed to the subshell
|
9
9
|
# You can capture the output of the command by setting capture to true
|
10
|
-
def run_command(command, stdin: $stdin, stdout: $stdout, stderr: $stderr, env: ENV, capture: false
|
10
|
+
def run_command(command, stdin: $stdin, stdout: $stdout, stderr: $stderr, env: ENV, capture: false)
|
11
11
|
command = Array(command)
|
12
12
|
output = nil
|
13
13
|
|
@@ -31,7 +31,7 @@ module Dev
|
|
31
31
|
unless result.exitstatus.zero?
|
32
32
|
puts output if capture
|
33
33
|
LOG.error "#{result.exitstatus} exit status while running [ #{command.join(' ')} ]\n".red
|
34
|
-
exit result.exitstatus
|
34
|
+
exit result.exitstatus
|
35
35
|
end
|
36
36
|
|
37
37
|
output
|
@@ -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
|
@@ -425,6 +426,19 @@ module Dev
|
|
425
426
|
g.fetch('origin', prune: true)
|
426
427
|
end
|
427
428
|
|
429
|
+
def commit_status(token:, repository:, branch:, status:, organization: 'firespring', options: {})
|
430
|
+
# Set up the GitHub client
|
431
|
+
client = Octokit::Client.new(access_token: token)
|
432
|
+
|
433
|
+
# Fetch the latest commit SHA for the given branch
|
434
|
+
repo = "#{organization}/#{repository}"
|
435
|
+
ref = "heads/#{branch}"
|
436
|
+
sha = client.ref(repo, ref).object.sha
|
437
|
+
|
438
|
+
# Create the commit status
|
439
|
+
client.create_status(repo, sha, status, options)
|
440
|
+
end
|
441
|
+
|
428
442
|
# Builds an ssh repo URL using the org and repo name given
|
429
443
|
def ssh_repo_url(name, org)
|
430
444
|
"git@github.com:#{org}/#{name}.git"
|
@@ -159,6 +159,58 @@ module Dev
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
# rubocop:disable Metrics/MethodLength
|
164
|
+
# Create the rake task for the git commit status task.
|
165
|
+
def create_commit_status_task!
|
166
|
+
# Have to set a local variable to be accessible inside of the instance_eval block
|
167
|
+
exclude = @exclude
|
168
|
+
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
169
|
+
namespace :git do
|
170
|
+
return if exclude.include?(:commit_status)
|
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)"
|
178
|
+
|
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
|
183
|
+
|
184
|
+
raise 'GITHUB_TOKEN is required' unless token
|
185
|
+
raise 'Repository name is required' unless repository
|
186
|
+
raise 'Branch name is required' unless branch
|
187
|
+
|
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?
|
191
|
+
|
192
|
+
namespace :commit_status do
|
193
|
+
desc 'Add status success'
|
194
|
+
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:)
|
200
|
+
end
|
201
|
+
desc 'Add status error'
|
202
|
+
task :error do
|
203
|
+
Dev::Git.new.commit_status(token:, repository:, branch:, status: 'error', options:)
|
204
|
+
end
|
205
|
+
desc 'Add status failure'
|
206
|
+
task :failure do
|
207
|
+
Dev::Git.new.commit_status(token:, repository:, branch:, status: 'failure', options:)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
# rubocop:enable Metrics/MethodLength
|
162
214
|
end
|
163
215
|
end
|
164
216
|
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.1.pre.alpha.
|
4
|
+
version: 2.2.1.pre.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-25 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
|