πŸ“– Parse git remote url
Switch branches/tags
Nothing to show
Clone or download
JuanitoFatas Init v1.0.0
- Adds CHANGELOG.md
- Adds CONTRIBUTING.md
- Add pry for debug
Latest commit 560bedd Jul 18, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib/git/remote
spec Init v1.0.0 Jul 18, 2016
.gitignore
.rspec
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
git-remote-parser.gemspec

README.md

Git::Remote::Parser

Build Status

Usage

This gem can parse remote urls into Git::Remote::Parser::Result object:

> parser = Git::Remote::Parser.new
=> #<Git::Remote::Parser:0x007ffd5c0d4718>

> result = parser.parse "git@github.com:torvalds/linux.git"
=> #<Git::Remote::Parser::Result:0x007fb11b82fc70 @protocol=nil, @username="git", @host="github.com", @owner="torvalds", @repo="linux", @html_url="https://github.com/torvalds/linux">

> result.host
=> "github.com"

> result.owner
=> "torvalds"

> result.repo
=> "linux"

> result.html_url
=> "https://github.com/torvalds/linux"

> result.to_h
=> {:protocol=>nil, :username=>"git", :host=>"github.com", :owner=>"torvalds", :repo=>"linux", :html_url=>"https://github.com/torvalds/linux"}

Tested work for these Git providers:

  • GitHub

    Examples:

    • https://github.com/torvalds/linux.git
    • git@github.com:torvalds/linux.git
  • Gitlab

    Examples:

    • https://gitlab.com/gitlab-org/gitlab-ce.git
    • git@gitlab.com:gitlab-org/gitlab-ce.git
  • Bitbucket

    Examples:

    • https://JuanitoFatas@bitbucket.org/ged/ruby-pg
    • ssh://hg@bitbucket.org/ged/ruby-pg
    • and legacy host bitbucket.com

Installation

Add this line to your application's Gemfile:

gem 'git-remote-parser'

# or double quote if you prefer:

gem "git-remote-parser"

And then execute:

$ bundle

Or install it yourself as:

$ gem install git-remote-parser

Contributing

See CONTRIBUTING.md

License

The gem is available as open source under the terms of the MIT License.