class Chandler::Git
Uses the shell to execute git commands against a given .git directory.
Constants
- Error
Attributes
path[R]
tag_mapper[R]
Public Class Methods
new(path:, tag_mapper:)
click to toggle source
Initializes the Git
object with the path to the `.git` directory of the desired git repository.
Chandler::Git.new
(:path => “/path/to/my/project/.git”)
# File lib/chandler/git.rb, line 17 def initialize(path:, tag_mapper:) @path = path @tag_mapper = tag_mapper end
Public Instance Methods
origin_remote()
click to toggle source
Uses `git remote -v` to list the remotes and returns the URL of the first one labeled “origin”.
origin_remote
# => “git@github.com:mattbrictson/chandler.git”
# File lib/chandler/git.rb, line 40 def origin_remote origin = git("remote", "-v").lines.grep(/^origin\s/).first origin && origin.split[1] end
Private Instance Methods
capture(*args)
click to toggle source
# File lib/chandler/git.rb, line 51 def capture(*args) out, err, status = Open3.capture3(*args) return out if status.success? message = "Failed to execute: #{args.join(' ')}" message << "\n#{err}" unless err.nil? raise Error, message end
git(*args)
click to toggle source
# File lib/chandler/git.rb, line 47 def git(*args) capture("git", "--git-dir", path, *args) end