Sha256: ab2bacc172d55ce73018bc996f222fda6158af614bea59903ca217ebaebcaa00
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module SuperHooks # Interact with git via this module module Git class NotARepository < StandardError; end # :nodoc: class GitError < StandardError; end # :nodoc: class << self # 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 # def repository git 'rev-parse --show-toplevel' rescue GitError raise NotARepository end alias_method :current_repository, :repository # Are we in a git repository # # Examples # # repository? # # => true # # Returns a boolean value # Raises NotARepository if we're not in a git repository # def repository? repository true rescue NotARepository false end # 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 # def git(cmd) output = `git #{cmd} 2>&1`.chomp fail GitError, "`git #{cmd}` failed" unless $?.success? output end alias_method :command, :git end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
super_hooks-0.0.2.1 | lib/super_hooks/git.rb |