firespring_dev_commands 3.0.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: '086747ff191a4480922b80069fed263ae8adac5e240e9e0650101dcb30b5fefb'
4
- data.tar.gz: 011a78ff9104945be999b33511f7171969548c8a3d897ddf33b56f03fcacfe5f
3
+ metadata.gz: eafd206b2464356f3683dc781936eb3cc5ca1296ed130b360bc6d7ecb218f1c5
4
+ data.tar.gz: 416a0585f3974ad8435422efb986154f2027e6665fa670ae142cbf9c9ba8af25
5
5
  SHA512:
6
- metadata.gz: e34be26a5e9e64dc71b8c3f893cbeb23fd5a5d21aa84f6e115a1ec4e5899daf43be883da7dc2ee08280ba112a9a715f84dfc1c56a7c91040adf9a718ad79be18
7
- data.tar.gz: 25c771fedf875de69f1a0151da8973923906be0db3fc8ab83b4c5b95656dbf9ed0da4b5000684e07a0be04b9494b2b29f8cfb7204975464667b4e38e1379386f
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
- g = ::Git.open(dir)
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
@@ -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 = '3.0.1'.freeze
9
+ VERSION = '3.0.2.pre.alpha.0'.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: 3.0.1
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-05-14 00:00:00.000000000 Z
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
@@ -430,9 +444,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
430
444
  version: '3.1'
431
445
  required_rubygems_version: !ruby/object:Gem::Requirement
432
446
  requirements:
433
- - - ">="
447
+ - - ">"
434
448
  - !ruby/object:Gem::Version
435
- version: '0'
449
+ version: 1.3.1
436
450
  requirements: []
437
451
  rubygems_version: 3.4.10
438
452
  signing_key: