Sha256: b23dfb07544b8db2bbbcba8b6d078a81b15799bde878e3eca5c63c94b39f758a

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

module PullRequest
  module Create
    class Repository
      def initialize(path, options = {})
        @path = path
        @options = options
      end

      def logger
        ::PullRequest::Create.logger
      end

      def git
        @git ||= ::Git.open(@path, @options)
      end

      def current_branch
        git.current_branch
      end

      def slug
        slug_regex = %r{\A/(?<slug>.*?)(?:\.git)?\Z}
        remote_urls.map do |url|
          uri = GitCloneUrl.parse(url)
          match = slug_regex.match(uri.path)
          match[:slug] if match
        end.compact.first
      end

      def remote_urls
        git
          .remotes
          .map(&:url)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pull_request-create-0.1.1 lib/pull_request/create/repository.rb
pull_request-create-0.1.0 lib/pull_request/create/repository.rb