Class: Omnibus::GitFetcher

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/omnibus/fetchers/git_fetcher.rb

Constant Summary

Constants included from Util

Util::SHELLOUT_OPTIONS

Instance Attribute Summary

Attributes inherited from Fetcher

#software

Instance Method Summary collapse

Methods inherited from Fetcher

#initialize

Methods included from Util

#copy_file, #create_directory, #create_file, #create_link, included, #remove_directory, #remove_file, #shellout, #shellout!, #windows_safe_path

Methods included from Logging

included

Methods included from Digestable

#digest, #digest_directory

Constructor Details

This class inherits a constructor from Omnibus::Fetcher

Instance Method Details

#cleantrue, false

Clean the project directory by removing the contents from disk.


45
46
47
48
49
50
51
52
53
# File 'lib/omnibus/fetchers/git_fetcher.rb', line 45

def clean
  if cloned?
    log.info(log_key) { 'Cleaning existing clone' }
    git('clean -fdx')
    true
  else
    false
  end
end

#fetchvoid

This method returns an undefined value.

Fetch (clone) or update (fetch) the remote git repository.


60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/omnibus/fetchers/git_fetcher.rb', line 60

def fetch
  log.info(log_key) { "Fetching from `#{source_url}'" }

  create_required_directories

  if cloned?
    git_fetch unless same_revision?
  else
    git_clone
    git_checkout
  end
end

#fetch_required?true, false

A fetch is required if the git repository is not cloned or if the local revision does not match the desired revision.


25
26
27
# File 'lib/omnibus/fetchers/git_fetcher.rb', line 25

def fetch_required?
  !(cloned? && same_revision?)
end

#version_for_cacheString

The version for this item in the cache. The is the parsed revision of the item on disk.


79
80
81
# File 'lib/omnibus/fetchers/git_fetcher.rb', line 79

def version_for_cache
  "revision:#{current_revision}"
end

#version_guidString

The version identifier for this git location. This is computed using the current revision on disk.


35
36
37
# File 'lib/omnibus/fetchers/git_fetcher.rb', line 35

def version_guid
  "git:#{current_revision}"
end