class Serverkit::Resources::Git
Constants
- DEFAULT_STATE
Public Instance Methods
Source
# File lib/serverkit/resources/git.rb, line 16 def apply _clone if clonable? checkout if checkoutable? update if updatable? end
@note Override
Source
# File lib/serverkit/resources/git.rb, line 23 def check has_git? && cloned? && !checkoutable? && !updatable? end
@note Override
Private Instance Methods
Source
# File lib/serverkit/resources/git.rb, line 34 def _clone run_command("git clone #{repository} #{path}") end
@note clone is reserved ;(
Source
# File lib/serverkit/resources/git.rb, line 46 def checkout run_command("git -C #{path} checkout #{branch}") end
Source
# File lib/serverkit/resources/git.rb, line 42 def checkoutable? branch && !checkouted? end
Source
# File lib/serverkit/resources/git.rb, line 50 def checkouted? check_command("cd #{path} && test `git rev-parse HEAD` = `git rev-parse #{branch}`") end
Source
# File lib/serverkit/resources/git.rb, line 38 def cloned? check_command_from_identifier(:check_file_is_directory, git_path) end
Source
# File lib/serverkit/resources/git.rb, line 55 def git_path ::File.join(path, ".git") end
@return [String] Path to .git directory in the cloned repository
Source
# File lib/serverkit/resources/git.rb, line 59 def has_git? check_command("which git") end
Source
# File lib/serverkit/resources/git.rb, line 64 def local_head_revision run_command("cd #{path} && git rev-parse HEAD").stdout.rstrip end
@return [String]
Source
# File lib/serverkit/resources/git.rb, line 69 def origin_head_revision run_command("cd #{path} && git ls-remote origin HEAD").stdout.split.first end
@return [String]
Source
# File lib/serverkit/resources/git.rb, line 73 def updatable? state == "updated" && !updated? end
Source
# File lib/serverkit/resources/git.rb, line 77 def update run_command("cd #{path} && git fetch origin && git reset --hard FETCH_HEAD") end
Source
# File lib/serverkit/resources/git.rb, line 81 def updated? local_head_revision == origin_head_revision end