Class: Rexer::Source::Git
Direct Known Subclasses
Instance Method Summary collapse
- #info(work_dir = nil) ⇒ Object
-
#initialize(url:, branch: nil, tag: nil, ref: nil) ⇒ Git
constructor
A new instance of Git.
- #load(path) ⇒ Object
- #updatable? ⇒ Boolean
- #update(path) ⇒ Object
Constructor Details
#initialize(url:, branch: nil, tag: nil, ref: nil) ⇒ Git
Returns a new instance of Git.
7 8 9 10 11 12 |
# File 'lib/rexer/source/git.rb', line 7 def initialize(url:, branch: nil, tag: nil, ref: nil) @url = url @branch = branch @tag = tag @ref = ref end |
Instance Method Details
#info(work_dir = nil) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/rexer/source/git.rb', line 27 def info(work_dir = nil) uri = URI.parse(url).then { "#{_1.host}#{_1.path}" } ref = reference(short_ref: true) || current_branch(work_dir) [uri, ref].compact.join("@") end |
#load(path) ⇒ Object
14 15 16 |
# File 'lib/rexer/source/git.rb', line 14 def load(path) ::Git.clone(url, path).then { checkout(_1) } end |
#updatable? ⇒ Boolean
23 24 25 |
# File 'lib/rexer/source/git.rb', line 23 def updatable? branch || reference.nil? end |
#update(path) ⇒ Object
18 19 20 21 |
# File 'lib/rexer/source/git.rb', line 18 def update(path) FileUtils.rm_rf(path) load(path) end |