class Vpr::GitParser
Constants
- REGEXP
Public Class Methods
current_branch()
click to toggle source
# File lib/vpr/git_parser.rb, line 24 def current_branch git = Git.open(git_dir) git.current_branch end
host()
click to toggle source
# File lib/vpr/git_parser.rb, line 29 def host remote_uri = remotes[Configuration.remote] matched = remote_uri.match(REGEXP) matched[:host] end
repo_url()
click to toggle source
# File lib/vpr/git_parser.rb, line 17 def repo_url remote_uri = remotes[Configuration.remote] matched = remote_uri.match(REGEXP) File.join("https://#{matched[:host]}", matched[:owner], matched[:repo]) end
Private Class Methods
git_dir()
click to toggle source
# File lib/vpr/git_parser.rb, line 43 def git_dir dir = Dir.pwd loop do return dir if File.directory?(File.join(dir, ".git")) parent = File.dirname(dir) # NOTE: Raising an error because at this point it is at the root dir raise Thor::Error.new("There is no repository in current directory") if parent == dir dir = parent end end
remotes()
click to toggle source
# File lib/vpr/git_parser.rb, line 38 def remotes git = Git.open(git_dir) git.remotes.map { |remote| [remote.name.to_sym, remote.url] }.to_h end