Sha256: 8d3b54c8c55284787bcda26c651548106dc7159c1676fca560c73406af05e09d

Contents?: true

Size: 1.73 KB

Versions: 27

Compression:

Stored size: 1.73 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

27 entries across 27 versions & 8 rubygems

Version Path
alphasights-integrity-0.1.9.3 lib/integrity/scm/git/uri.rb
alphasights-integrity-0.1.9.4 lib/integrity/scm/git/uri.rb
alphasights-integrity-0.1.9.5 lib/integrity/scm/git/uri.rb
alphasights-integrity-0.1.9.6 lib/integrity/scm/git/uri.rb
alphasights-integrity-0.1.9.7 lib/integrity/scm/git/uri.rb
alphasights-integrity-0.1.9.8 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.9.0 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.9.1 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.9.2 lib/integrity/scm/git/uri.rb
foca-integrity-0.1.9.3 lib/integrity/scm/git/uri.rb
gforces-integrity-0.1.9.3 lib/integrity/scm/git/uri.rb
gforces-integrity-0.1.9.4 lib/integrity/scm/git/uri.rb
imbriaco-integrity-0.1.9.2.1 lib/integrity/scm/git/uri.rb
imbriaco-integrity-0.1.9.2 lib/integrity/scm/git/uri.rb
integrity-integrity-0.1.10 lib/integrity/scm/git/uri.rb
integrity-integrity-0.1.9.3 lib/integrity/scm/git/uri.rb
oliyoung-integrity-0.1.9.0 lib/integrity/scm/git/uri.rb
sr-integrity-0.1.8.1 lib/integrity/scm/git/uri.rb
sr-integrity-0.1.9.1 lib/integrity/scm/git/uri.rb
sr-integrity-0.1.9.2 lib/integrity/scm/git/uri.rb