Class: Hub::Context::Remote
- Inherits:
-
Struct
- Object
- Struct
- Hub::Context::Remote
- Defined in:
- lib/hub/context.rb
Instance Method Summary collapse
Instance Method Details
#==(other) ⇒ Object
315 316 317 |
# File 'lib/hub/context.rb', line 315 def ==(other) other.respond_to?(:to_str) ? name == other.to_str : super end |
#project ⇒ Object
319 320 321 322 323 324 325 326 |
# File 'lib/hub/context.rb', line 319 def project urls.each { |url| if valid = GithubProject.from_url(url, local_repo) return valid end } nil end |
#uri_parse(uri) ⇒ Object
340 341 342 343 344 345 |
# File 'lib/hub/context.rb', line 340 def uri_parse uri uri = URI.parse uri uri.host = local_repo.ssh_config.get_value(uri.host, 'hostname') { uri.host } uri.user = local_repo.ssh_config.get_value(uri.host, 'user') { uri.user } uri end |
#urls ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/hub/context.rb', line 328 def urls @urls ||= local_repo.git_config("remote.#{name}.url", :all).to_s.split("\n").map { |uri| begin if uri =~ %r{^[\w-]+://} then uri_parse(uri) elsif uri =~ %r{^([^/]+?):} then uri_parse("ssh://#{$1}/#{$'}") # scp-like syntax end rescue URI::InvalidURIError nil end }.compact end |