Allowed schemes for Git clone.
This spec will start the application with an empty Git repository.
Return true if this clone specification should create an empty repository
# File lib/openshift-origin-common/utils/git.rb, line 13 def self.empty_clone_spec?(url) EMPTY_CLONE_SPEC == url end
Return a clone specification that can be safely persisted to the database (empty and userinfo are both removed).
# File lib/openshift-origin-common/utils/git.rb, line 51 def self.persistable_clone_spec(url) return nil if empty_clone_spec?(url) uri = URI.parse(url) uri.userinfo = nil rescue nil uri.to_s rescue URI::InvalidURIError url end
Check an incoming Git clone spec against a list of allowed schemes and ranges. If valid, return an tuple with a valid clone spec, and the optional fragment. Return nil if the spec is not allowed, otherwise raise URI::InvalidURIError if the input is not a valid URI.
# File lib/openshift-origin-common/utils/git.rb, line 30 def self.safe_clone_spec(url, schemes=ALLOWED_SCHEMES) return [EMPTY_CLONE_SPEC, nil] if empty_clone_spec?(url) uri = URI.parse(url) return nil unless schemes.include?(uri.scheme) fragment = uri.fragment uri.fragment = nil uri = uri.to_s.gsub(%(\Afile:/(?=[^/])), 'file:///') if uri.scheme == "file" [uri.to_s, fragment] rescue URI::InvalidURIError # Allow [user]@<host>:<path>.git[#commit] if schemes.include?('git@') && %{\A([\w\d\-_\.+]+@[\w\d\-_\.+]+:[\w\d\-_\.+%/]+\.git)(?:#([\w\d\-_\.\^~]+))?\Z}.match(url) [$1, $2] else raise end end
Generated with the Darkfish Rdoc Generator 2.