Class: Git::URL Private
- Inherits:
-
Object
- Object
- Git::URL
- Defined in:
- lib/git/url.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Methods for parsing a Git URL
Any URL that can be passed to git clone can be parsed by this class.
Constant Summary collapse
- GIT_ALTERNATIVE_SSH_SYNTAX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regexp used to match a Git URL with an alternative SSH syntax such as
user@host:path %r{ ^ (?:(?<user>[^@/]+)@)? # user or nil (?<host>[^:/]+) # host is required :(?!/) # : serparator is required, but must not be followed by / (?<path>.*?) # path is required $ }x
Class Method Summary collapse
-
.clone_to(url, bare: false, mirror: false) ⇒ String
private
The directory
git clonewould use for the repository directory for the given URL. -
.parse(url) ⇒ Addressable::URI
private
Parse a Git URL and return an Addressable::URI object.
Class Method Details
.clone_to(url, bare: false, mirror: false) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The directory git clone would use for the repository directory for the given URL
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/git/url.rb', line 69 def self.clone_to(url, bare: false, mirror: false) uri = parse(url) path_parts = uri.path.split('/') path_parts.pop if path_parts.last == '.git' directory = path_parts.last if || mirror directory += '.git' unless directory.end_with?('.git') elsif directory.end_with?('.git') directory = directory[0..-5] end directory end |
.parse(url) ⇒ Addressable::URI
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse a Git URL and return an Addressable::URI object
The URI returned can be converted back to a string with 'to_s'. This is guaranteed to return the same URL string that was parsed.
48 49 50 51 52 53 54 |
# File 'lib/git/url.rb', line 48 def self.parse(url) if !url.start_with?('file:') && (m = GIT_ALTERNATIVE_SSH_SYNTAX.match(url)) GitAltURI.new(user: m[:user], host: m[:host], path: m[:path]) else Addressable::URI.parse(url) end end |