class UC3Code::GithubClient
Query for github repository tags
Constants
- NOACT
Attributes
Public Class Methods
Source
# File app/lib/client/code/git.rb, line 19 def initialize map = UC3::UC3Client.lookup_map_by_filename( 'app/config/mrt/source.lookup.yml', key: ENV.fetch('configkey', 'default') ) token = map.fetch('token', '') opts = {} opts[:access_token] = token unless token.empty? begin @client = Octokit::Client.new(opts) rescue StandardError # puts "GitHub client error #{e}" end @tags = {} @since = Time.now - (2 * 365 * 24 * 60 * 60) super(enabled: enabled) end
              Calls superclass method
              
        UC3::UC3Client::new
            Public Instance Methods
Source
# File app/lib/client/code/git.rb, line 106 def actions(_repohash, tag, _commit, _release, tagartifacts, tagimages, deployed, _matching_tags) actions = [] unless tagartifacts.empty? || deployed actions << { value: 'Delete Artifacts', href: "/source/artifacts/delete/#{tag}", cssclass: 'button', post: true, disabled: false, data: tagartifacts.join("\n") } end if !tagimages.empty? && !deployed actions << { value: 'Delete Images', href: "/source/images/delete/#{tag}", cssclass: 'button', post: true, disabled: false, data: tagimages.join("\n") } end actions end
Source
# File app/lib/client/code/git.rb, line 95 def css_classes(tag, _commit, release, tagartifacts, tagimages) cssclasses = [ 'data', UC3::UC3Client.semantic_tag?(tag) ? 'semantic' : 'other' ] cssclasses << 'no-release' if release.empty? cssclasses << 'no-artifact' if tagartifacts.empty? cssclasses << 'no-image' if tagimages.empty? cssclasses end
Source
# File app/lib/client/code/git.rb, line 66 def get_commits(repo) commits = {} @client.branches(repo).each do |branch| @client.commits_since(repo, @since, sha: branch.name).each do |commit| commits[commit.sha] = { sha: commit.sha, message: commit.commit.message, author: commit.commit.author.name, date: commit.commit.author.date, url: commit.html_url } end end commits end
Source
# File app/lib/client/code/git.rb, line 82 def get_releases(repo) releases = {} @client.releases(repo).each do |rel| releases[rel.tag_name] = { tag: rel.tag_name, name: rel.name, url: rel.html_url, draft: rel.draft } end releases end
Source
# File app/lib/client/code/git.rb, line 144 def make_release(repo, tag, release) if release.empty? { value: 'Create', href: "https://github.com/#{repo}/releases/new?tag=#{tag.name}", cssclass: 'button' } else { value: release.fetch(:name, ''), href: release.fetch(:url, ''), cssclass: release.fetch(:draft, false) ? 'draft' : '' } end end
Source
# File app/lib/client/code/git.rb, line 133 def make_sha(tag, commit) [ { value: tag.commit.sha, href: commit.fetch(:url, '') }, commit.fetch(:message, ''), commit.fetch(:author, '') ] end
Source
# File app/lib/client/code/git.rb, line 44 def make_table AdminUI::FilterTable.new( # Tag Date Commit Sha Documented Release Artifacts ECR Images Actions columns: [ AdminUI::Column.new(:tag, header: 'Git Tag', cssclass: 'tag'), AdminUI::Column.new(:date, header: 'Date', cssclass: 'date'), AdminUI::Column.new(:sha, header: 'Commit Sha', cssclass: 'sha'), AdminUI::Column.new(:release, header: 'Documented Release', cssclass: 'release'), AdminUI::Column.new(:artifacts, header: 'Artifacts', cssclass: 'artifacts'), AdminUI::Column.new(:images, header: 'ECR Images', cssclass: 'images'), AdminUI::Column.new(:matching_tags, header: 'Matching Image Tags'), AdminUI::Column.new(:actions, header: 'Actions', cssclass: 'actions', spanclass: '') ], filters: [ AdminUI::Filter.new('Semantic Tags Only', 'other'), AdminUI::Filter.new('Has Release', 'no-release'), AdminUI::Filter.new('Has Artifact', 'no-artifact'), AdminUI::Filter.new('Has Image', 'no-image') ] ) end