Sanitize auto-generated repo identifier; refs #4

Redmine repo identifiers can't have any characters except:
/[a-z0-9_-]/

We scan for this and turn everything else into a '-'
This commit is contained in:
Alex Dergachev 2014-12-03 22:50:37 +00:00
parent 3a7de96736
commit 81a6fe6b02

View File

@ -101,7 +101,7 @@ class Repository::GitRemote < Repository::Git
.gsub(/\.git$/, '') # Remove trailing .git .gsub(/\.git$/, '') # Remove trailing .git
ret[:host] = ret[:path].split('/').first ret[:host] = ret[:path].split('/').first
#TODO: handle project uniqueness automatically or prompt #TODO: handle project uniqueness automatically or prompt
ret[:identifier] = ret[:path].split('/').last.downcase ret[:identifier] = ret[:path].split('/').last.downcase.gsub(/[^a-z0-9_-]/,'-')
return ret return ret
end end
@ -118,7 +118,6 @@ class Repository::GitRemote < Repository::Git
end end
end end
# Checks if host is in ~/.ssh/known_hosts, adds it if not present # Checks if host is in ~/.ssh/known_hosts, adds it if not present
def self.add_known_host(host) def self.add_known_host(host)
# if not found... # if not found...
@ -138,5 +137,4 @@ class Repository::GitRemote < Repository::Git
end end
end end
end end
end end