class Gitomator::GitHub::TaggingProvider
Public Class Methods
from_config(config = {})
click to toggle source
@param config [Hash<String,Object>] @return [Gitomator::GitHub::HostingProvider] GitHub
hosting provider.
# File lib/gitomator/github/tagging_provider.rb, line 16 def self.from_config(config = {}) return new(Gitomator::GitHub::github_client_from_config(config), config['organization']) end
Public Instance Methods
delete_metadata(repo, tag)
click to toggle source
# File lib/gitomator/github/tagging_provider.rb, line 88 def delete_metadata(repo, tag) @gh.delete_label!(@repo_name_resolver.full_name(repo), tag) end
metadata(repo, tag=nil)
click to toggle source
# File lib/gitomator/github/tagging_provider.rb, line 57 def metadata(repo, tag=nil) repo = @repo_name_resolver.full_name(repo) if tag begin @gh.label(repo, tag).to_h # Return metadata (Hash<Symbol,String>) rescue Octokit::NotFound return nil end else @gh.labels(repo).map {|r| [r.name, r.to_h]}.to_h # Return Hash<String,Hash<Symbol,String>>, mapping tags to their metadata end end
remove_tag(repo, id_or_name, tag)
click to toggle source
# File lib/gitomator/github/tagging_provider.rb, line 30 def remove_tag(repo, id_or_name, tag) @gh.remove_label(@repo_name_resolver.full_name(repo), id_or_name, tag) .map { |r| r.to_h } # Make the result a regular Ruby Hash end
search(repo, label)
click to toggle source
@return Enumerable of object identifiers.
# File lib/gitomator/github/tagging_provider.rb, line 45 def search(repo, label) if label.is_a? String q = "repo:#{@repo_name_resolver.full_name(repo)} type:issue|pr label:\"#{label}\"" @gh.search_issues(q) .items.map {|item| item.number} # Make the result an array of issue/or id's else raise "Unimplemented! Search only supports a single tag at the moment." end end
set_metadata(repo, tag, metadata)
click to toggle source
# File lib/gitomator/github/tagging_provider.rb, line 73 def set_metadata(repo, tag, metadata) repo = @repo_name_resolver.full_name(repo) color = metadata[:color] || metadata['color'] raise "The only supported metadata property is 'color'" if color.nil? # TODO: Validate the color string (6-char-long Hex string. Any other formats supproted by GitHub?) if metadata(repo, tag).nil? @gh.add_label(repo, tag, color).to_h else @gh.update_label(repo, tag, {:color => color}).to_h end end