module Rookout::ComWs::Git

Constants

GIT_CONFIG
GIT_FOLDER
GIT_HEAD
REMOTE_ORIGINS

Public Instance Methods

find_root(path) click to toggle source
# File lib/rookout/com_ws/git.rb, line 10
def find_root path
  # Return if found
  return path if git? path

  # Get next, fail if there's no next
  next_path = File.dirname path
  return nil if next_path == path

  # Recursive call
  find_root next_path
end
git?(path) click to toggle source
# File lib/rookout/com_ws/git.rb, line 35
def git? path
  potential_git_folder = File.join path, GIT_FOLDER
  File.directory? potential_git_folder
end
remote_origin(path) click to toggle source
# File lib/rookout/com_ws/git.rb, line 26
def remote_origin path
  git_config_path = File.join path, GIT_FOLDER, GIT_CONFIG
  git_config_contents = File.read git_config_path
  match = git_config_contents.match REMOTE_ORIGINS
  return "" if match.captures.empty?

  match.captures[0]
end
revision(path) click to toggle source
# File lib/rookout/com_ws/git.rb, line 22
def revision path
  follow_sym_links File.join(path, GIT_FOLDER), GIT_HEAD
end