lib/poise_boiler/helpers/rake/badges.rb
# Find the GitHub user/org and repository name for this repository.
# Based on travis.rb https://github.com/travis-ci/travis.rb/blob/23ea1d2f34231a50a475b4ee8d19fa15b1d6b0e3/lib/travis/cli/repo_command.rb#L65
# Copyright (c) 2014-2015 Travis CI GmbH <support@travis-ci.com>
#
# @return [String, nil]
Find the GitHub user/org and repository name for this repository.
Find the GitHub user / org and repository name for this repository .
def detect_github
          git_head = git_shell_out(%w{name-rev --name-only HEAD})
          return nil unless git_head
          git_remote = git_shell_out(%W{config --get branch.#{git_head}.remote})
          git_remote = 'origin' if !git_remote || git_remote.empty? 
          git_info = git_shell_out(%w{ls-remote --get-url}+[git_remote])
          parsed_remote = if git_info =~ /^git@[^:]+:/
            path = git_info.split(':').last
            path = "/#{path}" unless path.start_with?('/')
            path
          else
            URI.parse(git_info).path
          end
          if parsed_remote =~ %r{/?(.*/.+?)(\.git)?$}
            $1
          else
            nil
          end
        end
def detect_github git_head = git_shell_out ( %w{ name-rev --name-only HEAD } ) return nil unless git_head git_remote = git_shell_out ( %W{ config --get branch. #{ git_head } .remote } ) git_remote = 'origin' if ! git_remote || git_remote . empty? git_info = git_shell_out ( %w{ ls-remote --get-url } + [ git_remote ] ) parsed_remote = if git_info =~ / ^git@[^:]+: / path = git_info . split ( ':' ) . last path = "/#{path}" unless path . start_with? ( '/' ) path else URI . parse ( git_info ) . path end if parsed_remote =~ %r{ /?(.*/.+?)( \. git)?$ } $1 else nil end end
Find the GitHub user/org and repository name for this repository.
Find the GitHub user / org and repository name for this repository .
# Default value
None
String, nil