Class: Repomen::Repo::Handler::Git
- Defined in:
- lib/repomen/repo/handler/git.rb
Overview
TODO:
Uses git’s CLI, since Rugged is not playing nice GitHub Why is that?
Handler for git repositories
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #branch_name ⇒ Object
- #change_branch(name, update_branch = false) ⇒ Object (also: #checkout_revision)
-
#discard ⇒ void
Removes the repo from the filesystem.
-
#retrieve(branch_name = "master") ⇒ void
Retrieves the repo from @url.
- #revision_info ⇒ Object
- #tag ⇒ Object
Methods inherited from Base
Methods included from WithDefaultConfig
Constructor Details
This class inherits a constructor from Repomen::Repo::Handler::Base
Instance Method Details
#branch_name ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/repomen/repo/handler/git.rb', line 13 def branch_name branch = nil in_dir do branch = git(:'rev-parse', '--abbrev-ref', 'HEAD') end branch end |
#change_branch(name, update_branch = false) ⇒ Object Also known as: checkout_revision
21 22 23 24 25 26 27 28 29 |
# File 'lib/repomen/repo/handler/git.rb', line 21 def change_branch(name, update_branch = false) in_dir do output = git(:checkout, name, '--quiet') unless $?.success? raise HandlerError.new("checkout failed: #{name.inspect}") end pull if update_branch end end |
#discard ⇒ void
This method returns an undefined value.
Removes the repo from the filesystem
34 35 36 |
# File 'lib/repomen/repo/handler/git.rb', line 34 def discard FileUtils.rm_rf(path) if repo_exists? end |
#retrieve(branch_name = "master") ⇒ void
This method returns an undefined value.
Retrieves the repo from @url
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/repomen/repo/handler/git.rb', line 40 def retrieve(branch_name = "master") if repo_exists? change_branch(branch_name) update_repo else clone_repo change_branch(branch_name) if $?.success? end $?.success? end |
#revision_info ⇒ Object
51 52 53 |
# File 'lib/repomen/repo/handler/git.rb', line 51 def revision_info @revision_info ||= parse_revision_info(git_show) end |
#tag ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/repomen/repo/handler/git.rb', line 55 def tag output = nil in_dir do output = git(:describe, '--tags --exact-match', 'HEAD') end output end |