class MrBump::GitConfig

This class gathers configuration infromation from git

Constants

GITHUB_URL_REGEX

Attributes

host[R]
orgin[R]
path[R]
repo_name[R]
repo_url[R]
user[R]
username[R]

Public Class Methods

from_current_path() click to toggle source
# File lib/mr_bump/git_config.rb, line 31
def self.from_current_path
  from_origin(`git remote get-url origin`.strip)
end
from_origin(origin, user = nil) click to toggle source
# File lib/mr_bump/git_config.rb, line 23
def self.from_origin(origin, user = nil)
  match = GITHUB_URL_REGEX.match(origin)
  raise ArgumentError,
        "Couldn't parse needed information from remote url '#{git_url}'" unless match
  GitConfig.new(match['repo_name'], "https://#{match['domain']}",
                "#{match['path']}/#{match['repo_name']}", match['user'], user)
end
new(repo_name, repo_host, repo_path, username, user) click to toggle source
# File lib/mr_bump/git_config.rb, line 14
def initialize(repo_name, repo_host, repo_path, username, user)
  @repo_name = repo_name
  @repo_url = repo_host + '/' + repo_path + '/'
  @host = repo_host
  @path = repo_path
  @username = username
  @user = user || `git config user.name`
end

Public Instance Methods

get_sha(pattern) click to toggle source
# File lib/mr_bump/git_config.rb, line 43
def get_sha(pattern)
  `git log --grep=#{pattern} --merges --format=format:%H`.split("\n").first
end
user_icon() click to toggle source
# File lib/mr_bump/git_config.rb, line 35
def user_icon
  'https://avatars.githubusercontent.com/' + username if username
end