module SuperHooks::Git

Interact with git via this module

Public Class Methods

command(cmd)
Alias for: git
current_repository()
Alias for: repository
git(cmd) click to toggle source

Run a git command

Examples

git "status -s"
# => "M lib/super_hooks/file.rb\nM lib/super_hooks.file2.rb"

Raises GitError if the command fails

# File lib/super_hooks/git.rb, line 52
def git(cmd)
  output = `git #{cmd} 2>&1`.chomp
  fail GitError, "`git #{cmd}` failed" unless $?.success?
  output
end
Also aliased as: command
repository() click to toggle source

Returns the current repository if root path

Examples

repository
# => /home/franky/my_git_folder/

Returns a string of the repository name Raises NotARepository if we're not in a git repository

# File lib/super_hooks/git.rb, line 19
def repository
  git 'rev-parse --show-toplevel'
  rescue GitError
    raise NotARepository
end
Also aliased as: current_repository
repository?() click to toggle source

Are we in a git repository

Examples

repository?
# => true

Returns a boolean value Raises NotARepository if we're not in a git repository

# File lib/super_hooks/git.rb, line 36
def repository?
  repository
  true
  rescue NotARepository
    false
end