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
330 331 332 |
# File 'lib/hub/context.rb', line 330 def ==(other) other.respond_to?(:to_str) ? name == other.to_str : super end |
#project ⇒ Object
334 335 336 337 338 339 340 341 |
# File 'lib/hub/context.rb', line 334 def project urls.each { |url| if valid = GithubProject.from_url(url, local_repo) return valid end } nil end |
#uri_parse(uri) ⇒ Object
355 356 357 358 359 360 |
# File 'lib/hub/context.rb', line 355 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
343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/hub/context.rb', line 343 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 |