Sha256: 9b2f56977856936b4db1c0fe8829824be2d020604f48d83e554789feb4285582

Contents?: true

Size: 1.75 KB

Versions: 18

Compression:

Stored size: 1.75 KB

Contents

module Integrity
  module SCM
    class Git
      # From the git-pull man page:
      #
      # GIT URLS
      #   One of the following notations can be used to name the remote repository:
      #
      #     rsync://host.xz/path/to/repo.git/
      #     http://host.xz/path/to/repo.git/
      #     git://host.xz/~user/path/to/repo.git/
      #     ssh://[user@]host.xz[:port]/path/to/repo.git/
      #     ssh://[user@]host.xz/path/to/repo.git/
      #     ssh://[user@]host.xz/~user/path/to/repo.git/
      #     ssh://[user@]host.xz/~/path/to/repo.git
      # 
      #   SSH is the default transport protocol over the network. You can optionally 
      #   specify which user to log-in as, and an alternate, scp-like syntax is also 
      #   supported
      #
      #   Both syntaxes support username expansion, as does the native git protocol, 
      #   but only the former supports port specification. The following three are 
      #   identical to the last three above, respectively:
      #
      #     [user@]host.xz:/path/to/repo.git/
      #     [user@]host.xz:~user/path/to/repo.git/
      #     [user@]host.xz:path/to/repo.git
      #
      class URI
        def initialize(uri_string)
          @uri = Addressable::URI.parse(uri_string)
        end
    
        def working_tree_path
          strip_extension(path).gsub("/", "-")
        end
    
      private
    
        def strip_extension(string)
          uri = Pathname.new(string)
          if uri.extname.any?
            uri = Pathname.new(string)
            string.gsub(Regexp.new("#{uri.extname}\/?"), "")
          else
            string
          end
        end
    
        def path
          path = @uri.path
          path.gsub(/\~[a-zA-Z0-9]*\//, "").gsub(/^\//, "")
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 7 rubygems

Version Path
bantic-integrity-0.1.4.1 lib/integrity/scm/git/uri.rb
bantic-integrity-0.1.4.2 lib/integrity/scm/git/uri.rb
bantic-integrity-0.1.4.3 lib/integrity/scm/git/uri.rb
bantic-integrity-0.1.4.4 lib/integrity/scm/git/uri.rb
bantic-integrity-0.1.4 lib/integrity/scm/git/uri.rb
brycethornton-integrity-0.1.7.1 lib/integrity/scm/git/uri.rb
defunkt-integrity-0.1.1 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.0 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.1 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.2 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.3 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.4 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.6 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.7 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.8 lib/integrity/scm/git/uri.rb
giraffesoft-integrity-0.1.4 lib/integrity/scm/git/uri.rb
myronmarston-integrity-0.1.7.1 lib/integrity/scm/git/uri.rb
integrity-0.1.8 lib/integrity/scm/git/uri.rb