class GitUpdater

Public Instance Methods

has_local_changes?() click to toggle source
# File lib/updater/git_updater.rb, line 38
def has_local_changes?
  %x[git #{repo_directory_arguments()} diff --exit-code 2>&1] =~ %rdiff/ ? true : false
end
is_installed?() click to toggle source
# File lib/updater/git_updater.rb, line 23
def is_installed?
  %x[git #{repo_directory_arguments()} status 2>&1] =~ %rOn branch/ ? true : false
end
local_revision_number() click to toggle source

Git has not a revsion number like SVN, so we will take the 7 first chars of the last commit hash

# File lib/updater/git_updater.rb, line 29
def local_revision_number
  git_log = %x[git #{repo_directory_arguments()} log -1 2>&1]
  git_log[%rcommit ([0-9a-z]{7})/, 1].to_s
end
reset_head() click to toggle source
# File lib/updater/git_updater.rb, line 42
def reset_head
  %x[git #{repo_directory_arguments()} reset --hard HEAD]
end
update() click to toggle source
# File lib/updater/git_updater.rb, line 34
def update
  %x[git #{repo_directory_arguments()} pull]
end

Protected Instance Methods

repo_directory_arguments() click to toggle source
# File lib/updater/git_updater.rb, line 47
def repo_directory_arguments
  if @repo_directory
    return "--git-dir=\"#{@repo_directory}/.git\" --work-tree=\"#{@repo_directory}\""
  end
end