Sha256: 880918563bb906b1b1f84a3f5a512a3968e5e571beffc02c8b7b69ae027feea3
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
require 'uri' module GhCompare class Error < StandardError; end class CommitCompare attr_reader :remote_origin def initialize @remote_origin = get_remote_origin end def remote_url remote_url? ? remote_origin.gsub(/\.git$/, '') : ssh_to_url end def compare_url(from, to) remote_url + "/compare/#{from}...#{to}" end def compare_before(num) compare_url(head_before(num), head) end private def get_remote_origin `git config --get remote.origin.url`.strip end def remote_url? URI.parse(remote_origin).is_a?(URI::HTTP) rescue false end def ssh_to_url "https://github.com/#{remote_origin.gsub(/git@github.com:/, '').gsub(/\.git$/, '')}" end def head `git rev-parse HEAD`.strip end def head_before(num) `git rev-parse HEAD~#{num}`.strip end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gh_compare-0.1.4 | lib/gh_compare.rb |