Module: Usps::Support::Models::GitHub

Defined in:
lib/usps/support/models/git_hub.rb

Overview

GitHub API

Constant Summary collapse

ORG =
'unitedstatespowersquadrons'

Class Method Summary collapse

Class Method Details

.check_runs(repo, check_suite_id) ⇒ Object



14
15
16
# File 'lib/usps/support/models/git_hub.rb', line 14

def check_runs(repo, check_suite_id)
  client.check_runs_for_check_suite("#{ORG}/#{repo}", check_suite_id).check_runs
end

.check_suites(repo, branch) ⇒ Object



10
11
12
# File 'lib/usps/support/models/git_hub.rb', line 10

def check_suites(repo, branch)
  client.check_suites_for_ref("#{ORG}/#{repo}", branch).check_suites
end

.expired?Boolean

Returns:

  • (Boolean)


38
# File 'lib/usps/support/models/git_hub.rb', line 38

def expired? = expires_at <= Time.zone.now

.expires_atObject



39
# File 'lib/usps/support/models/git_hub.rb', line 39

def expires_at = @auth[:expires_at]

.fetch_head_commit(repo, branch) ⇒ Object



18
19
20
21
# File 'lib/usps/support/models/git_hub.rb', line 18

def fetch_head_commit(repo, branch)
  sha = client.ref("#{ORG}/#{repo}", "heads/#{branch}").object.sha
  client.commit("#{ORG}/#{repo}", sha).commit
end

.latest_tag(repo, include_prereleases: false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/usps/support/models/git_hub.rb', line 27

def latest_tag(repo, include_prereleases: false)
  client
    .tags("#{ORG}/#{repo}")
    .pluck(:name)
    .grep(/^v\d+\.\d+\.\d(?:-[\w\-.]+)?/)
    .index_with { Gem::Version.new(it.delete('v')) }
    .reject { |_, gv| gv.prerelease? unless include_prereleases }
    .max_by { |_, gv| gv }
    .first
end

.permissionsObject



40
# File 'lib/usps/support/models/git_hub.rb', line 40

def permissions = @auth[:permissions]

.repository_selectionObject



41
# File 'lib/usps/support/models/git_hub.rb', line 41

def repository_selection = @auth[:repository_selection]

.repository_workflow_runs(repo, head_sha:) ⇒ Object



23
24
25
# File 'lib/usps/support/models/git_hub.rb', line 23

def repository_workflow_runs(repo, head_sha:)
  client.repository_workflow_runs("#{ORG}/#{repo}", head_sha:).workflow_runs
end