Sha256: a7bc2b219a41cbf9d0938805685a465bfbe682ad480b4a667f8476487a3ebc34

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

module Brief
  module Git
    def self.current_github_repository
      return nil unless Pathname(Dir.pwd).join('.git').exist?

      return @current_github_repository if @current_github_repository

      github_remote = `git remote`.lines.to_a.detect do |remote_name|
        `git remote show #{ remote_name }`.match(/github\.com/)
      end

      if github_remote
        lines = `git remote show #{ github_remote }`.lines.to_a.map(&:strip)
        line = lines.detect {|l| l.match(/Fetch URL/)}
        @current_github_repository = line.split(':').last.gsub(/\.git$/,'')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brief-0.0.5 lib/brief/git.rb
brief-0.0.4 lib/brief/git.rb
brief-0.0.3 lib/brief/git.rb
brief-0.0.2 lib/brief/git.rb