Class: XCCache::GitStorage
- Defined in:
- lib/xccache/storage/git.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GitStorage
constructor
A new instance of GitStorage.
- #pull ⇒ Object
- #push ⇒ Object
Methods included from Config::Mixin
Constructor Details
#initialize(options = {}) ⇒ GitStorage
Returns a new instance of GitStorage.
7 8 9 10 11 12 13 14 15 |
# File 'lib/xccache/storage/git.rb', line 7 def initialize( = {}) super if (@remote = [:remote]) schemes = ["http://", "https://", "git@"] @remote = File.(@remote) unless schemes.any? { |x| @remote.start_with?(x) } ensure_remote end @branch = [:branch] end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
5 6 7 |
# File 'lib/xccache/storage/git.rb', line 5 def branch @branch end |
Instance Method Details
#pull ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/xccache/storage/git.rb', line 17 def pull git.fetch("--depth 1 origin #{branch}") git.switch("--detach FETCH_HEAD", capture: true) git.clean("-dfx", capture: true) # Re-create local branch so that it has the latest from remote git.branch("-D #{branch} || true", capture: true) git.checkout("-b #{branch}", capture: true) end |