firespring_dev_commands 3.0.1.pre.alpha.1 → 3.0.2.pre.alpha.0
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: eafd206b2464356f3683dc781936eb3cc5ca1296ed130b360bc6d7ecb218f1c5
|
4
|
+
data.tar.gz: 416a0585f3974ad8435422efb986154f2027e6665fa670ae142cbf9c9ba8af25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f6dc58f90b3dfdf2d0ba614f830024548dce70788afdeb5bf9dba0b5c3cd1b3bd01cb28b8955c02e4ac033a4246a3f3455e023c813553da758e0bd83516bf1
|
7
|
+
data.tar.gz: 97e72febb58871e687893ec32f68d5fd7942987e572bd70b27d064c76f65fc7c0d1417591bfd68c5634b36e01c8662c8404cb18e821b3a2a483c589e8c9808ed
|
@@ -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
|
@@ -96,8 +97,7 @@ module Dev
|
|
96
97
|
def branch_name(dir: default_project_dir)
|
97
98
|
return unless File.exist?(dir)
|
98
99
|
|
99
|
-
|
100
|
-
g.current_branch || "HEAD detached at #{g.object('HEAD').sha[0..7]}"
|
100
|
+
::Git.open(dir).current_branch
|
101
101
|
end
|
102
102
|
|
103
103
|
# Returns true if the remote branch exists, false otherwise
|
@@ -425,6 +425,22 @@ module Dev
|
|
425
425
|
g.fetch('origin', prune: true)
|
426
426
|
end
|
427
427
|
|
428
|
+
def commit_status(repository:, branch:, status:, organization: 'firespring', options: {})
|
429
|
+
token = ENV['GITHUB_TOKEN'].to_s.strip
|
430
|
+
raise 'GITHUB_TOKEN is required' unless token
|
431
|
+
|
432
|
+
# Set up the GitHub client
|
433
|
+
client = Octokit::Client.new(access_token: token)
|
434
|
+
|
435
|
+
# Fetch the latest commit SHA for the given branch
|
436
|
+
repo = "#{organization}/#{repository}"
|
437
|
+
ref = "heads/#{branch}"
|
438
|
+
sha = client.ref(repo, ref).object.sha
|
439
|
+
|
440
|
+
# Create the commit status
|
441
|
+
client.create_status(repo, sha, status, options)
|
442
|
+
end
|
443
|
+
|
428
444
|
# Builds an ssh repo URL using the org and repo name given
|
429
445
|
def ssh_repo_url(name, org)
|
430
446
|
"git@github.com:#{org}/#{name}.git"
|
@@ -159,6 +159,49 @@ module Dev
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
# Create the rake task for the git commit status task.
|
164
|
+
def create_commit_status_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
|
+
# TODO: Clean, comments and description
|
173
|
+
desc 'Add status to commit' \
|
174
|
+
"\n\tuse TODO"
|
175
|
+
|
176
|
+
task :create_commit_status do
|
177
|
+
# Key Values
|
178
|
+
repository = ENV['REPOSITORY'].to_s.strip
|
179
|
+
branch = ENV['BRANCH'].to_s.strip
|
180
|
+
status = ENV['STATUS'].to_s.strip
|
181
|
+
|
182
|
+
raise 'Repository name is required' unless repository
|
183
|
+
raise 'Branch name is required' unless branch
|
184
|
+
raise 'Status is required' unless status
|
185
|
+
|
186
|
+
# Validate status
|
187
|
+
valid_statuses = %w(error failure pending success)
|
188
|
+
raise "Invalid status: #{status}. Valid statuses are: #{valid_statuses.join(', ')}" unless valid_statuses.include?(status)
|
189
|
+
|
190
|
+
# Optional Values
|
191
|
+
context = ENV['CONTEXT'].to_s.strip
|
192
|
+
description = ENV['DESCRIPTION'].to_s.strip
|
193
|
+
target_url = ENV['TARGET_URL'].to_s.strip
|
194
|
+
|
195
|
+
options = {}
|
196
|
+
options[:context] = context unless context.empty?
|
197
|
+
options[:description] = description unless description.empty?
|
198
|
+
options[:target_url] = target_url unless target_url.empty?
|
199
|
+
|
200
|
+
Dev::Git.new.commit_status(repository:, branch:, status:, options:)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
162
205
|
end
|
163
206
|
end
|
164
207
|
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: 3.0.
|
4
|
+
version: 3.0.2.pre.alpha.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -262,6 +262,20 @@ dependencies:
|
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: 2.3.0
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: octokit
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '8.1'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '8.1'
|
265
279
|
- !ruby/object:Gem::Dependency
|
266
280
|
name: ox
|
267
281
|
requirement: !ruby/object:Gem::Requirement
|