Skip to content

Commit

Permalink
Move gsub to a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
drewwells committed Dec 12, 2013
1 parent 81068c9 commit 10bf200
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/lolcommits/git_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class GitInfo
include Methadone::CLILogging
attr_accessor :sha, :message, :repo_internal_path, :repo, :url

def remote_https_url(url)
url.gsub(':','/').gsub(/^git@/,'https://').gsub(/\.git$/,'') + '/commit/'
end

def initialize
debug "GitInfo: attempting to read local repository"
g = Git.open('.')
Expand All @@ -13,7 +17,7 @@ def initialize
self.message = commit.message.split("\n").first
self.sha = commit.sha[0..10]
self.repo_internal_path = g.repo.path
self.url = g.remote.url ? g.remote.url.gsub(':','/').gsub(/^git@/,'https://').gsub(/\.git$/,'') + '/commit/': ''
self.url = remote_https_url(g.remote.url) if g.remote.url

regex = /.*[:]([\/\w\-]*).git/
match = g.remote.url.match regex if g.remote.url
Expand Down

0 comments on commit 10bf200

Please sign in to comment.