DRY'd up that user regex.

This commit is contained in:
Parker Moore 2012-12-20 00:02:36 -05:00
parent 1e300fbb03
commit 31db12fc49

View File

@ -383,7 +383,8 @@ task :setup_github_pages, :repo do |t, args|
repo_url = get_stdin("Enter the read/write url for your repository: ")
end
raise "!! The repo URL that was input was malformed." unless repo_url.match(/https:\/\/github.com\/[^\/]+\/[^\/]+/) or repo_url.match(/git@github.com:[^\/]+\/[^\/]+/)
user = repo_url.match(/(:([^\/]+)|(github.com\/([^\/]+)))/)[2] || repo_url.match(/(:([^\/]+)|(github.com\/([^\/]+)))/)[4]
user_match = repo_url.match(/(:([^\/]+)|(github.com\/([^\/]+)))/)
user = user_match[2] || user_match[4]
branch = (repo_url.match(/\/[\w-]+.github.com/).nil?) ? 'gh-pages' : 'master'
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
url = "http://#{user}.github.com"