Class: Jive::Repo
- Inherits:
-
Object
- Object
- Jive::Repo
- Defined in:
- lib/jive/repo.rb
Constant Summary collapse
- SSH_REGEX =
%r{\Agit@(?<host>.+):(?<account>.+)/(?<repo>.+)\z}.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #branch ⇒ Object
- #canonical_url ⇒ Object
-
#initialize(path) ⇒ Repo
constructor
A new instance of Repo.
- #nwo ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(path) ⇒ Repo
Returns a new instance of Repo.
7 8 9 |
# File 'lib/jive/repo.rb', line 7 def initialize(path) @repo = Rugged::Repository.new(path.to_s) end |
Class Method Details
.current ⇒ Object
32 33 34 |
# File 'lib/jive/repo.rb', line 32 def current @current ||= new(Pathname.pwd) end |
Instance Method Details
#branch ⇒ Object
27 28 29 |
# File 'lib/jive/repo.rb', line 27 def branch uri.path[1..-1] end |
#canonical_url ⇒ Object
15 16 17 18 19 20 |
# File 'lib/jive/repo.rb', line 15 def canonical_url remote = @repo.remotes.find { |x| x.name == "origin" } return if remote.nil? ssh?(remote) ? url_for_ssh(remote) : url_for(remote) end |
#nwo ⇒ Object
22 23 24 25 |
# File 'lib/jive/repo.rb', line 22 def nwo segments = uri.path.split("/") "#{segments[1]}/#{segments[2].gsub(".git", "")}" end |
#uri ⇒ Object
11 12 13 |
# File 'lib/jive/repo.rb', line 11 def uri @uri ||= URI.parse(canonical_url) end |