Fix syntax error in ruby 1.8; closes #10

This commit is contained in:
Alex Dergachev 2014-12-18 00:29:54 +00:00
parent 0401cff6c6
commit c1101873f6

View File

@ -127,12 +127,14 @@ class Repository::GitRemote < Repository::Git
ret = {}
# start with http://github.com/evolvingweb/git_remote or git@git.ewdev.ca:some/repo.git
ret[:url] = url
# NB: Starting lines with ".gsub" is a syntax error in ruby 1.8.
# See http://stackoverflow.com/q/12906048/9621
# path is github.com/evolvingweb/muhc-ci
ret[:path] = url
.gsub(/^.*:\/\//, '') # Remove anything before ://
.gsub(/:/, '/') # convert ":" to "/"
.gsub(/^.*@/, '') # Remove anything before @
.gsub(/\.git$/, '') # Remove trailing .git
ret[:path] = url.gsub(/^.*:\/\//, ''). # Remove anything before ://
gsub(/:/, '/'). # convert ":" to "/"
gsub(/^.*@/, ''). # Remove anything before @
gsub(/\.git$/, '') # Remove trailing .git
ret[:host] = ret[:path].split('/').first
#TODO: handle project uniqueness automatically or prompt
ret[:identifier] = ret[:path].split('/').last.downcase.gsub(/[^a-z0-9_-]/,'-')