git @ Cat's Eye Technologies Funicular / 7257a84
Better toolshelf spec parsing. Chris Pressey 9 years ago
1 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
291291
292292
293293 function checkout_repo_by_spec(funicular, spec)
294 local is_hg = spec:match("^bb:(.-)$")
295 local is_git = spec:match("^gh:(.-)$")
294 local protocol, username, project, version =
295 spec:match("^(%w+):([^/]+)/([^@]+)(@?.*)$")
296296 local url = get_url_for_spec(funicular, spec)
297 if is_hg then
297 if protocol == 'bb' then
298298 return checkout_hg_repo(funicular, url)
299 elseif is_git then
299 elseif protocol == 'gh' then
300300 return checkout_git_repo(funicular, url)
301301 else
302302 print("Error: bad spec '" .. spec .. "'")
306306
307307
308308 function get_url_for_spec(funicular, spec)
309 local is_hg = spec:match("^bb:(.-)$")
310 local is_git = spec:match("^gh:(.-)$")
311 if is_hg then
312 return 'http://bitbucket.org/' .. is_hg
313 elseif is_git then
314 return 'http://github.com/' .. is_git
309 local protocol, username, project, version =
310 spec:match("^(%w+):([^/]+)/([^@]+)(@?.*)$")
311 if protocol == 'bb' then
312 return 'http://bitbucket.org/' .. username .. '/' .. project
313 elseif protocol == 'gh' then
314 return 'http://github.com/' .. username .. '/' .. project
315315 else
316316 print("Error: bad spec '" .. spec .. "'")
317317 os.exit(1)