Sha256: 0518674980f3bd61c21daaacbc242e537d2dc784c15938a7fcdfbe492419da98
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module Saddler module Reporter module Support module Git class Repository def initialize(path) @git = ::Git.open(path) end def slug name = /[[:alnum:]_\-\.]*/ repo = /[[:alnum:]_\-\.]*/ regex_slug = %r{#{name}/#{repo}} regex = /.*?#{Regexp.quote(github_domain)}.*?(?<slug>#{regex_slug})/ target = remote_urls.map do |url| match = regex.match(strip_git_extension(url)) match[:slug] if match end.compact.first end def remote_urls @git .branches .remote .map { |branch| branch.remote.url } end def current_branch @git.current_branch end def head @git.object('HEAD') end def strip_git_extension(name) match = /\A(?<identity>.*?)(?:\.git)?\z/.match(name) match[:identity] if match end # FIXME: if endpoint set, this return wrong result def github_domain github_api_endpoint .split('.') .slice(-2, 2) .join('.') end def github_api_endpoint ENV['GITHUB_API_ENDPOINT'] || 'api.github.com' end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
saddler-reporter-support-git-0.1.0 | lib/saddler/reporter/support/git/repository.rb |