Better toolshelf spec parsing.
Chris Pressey
9 years ago
291 | 291 | |
292 | 292 | |
293 | 293 | 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+):([^/]+)/([^@]+)(@?.*)$") | |
296 | 296 | local url = get_url_for_spec(funicular, spec) |
297 | if is_hg then | |
297 | if protocol == 'bb' then | |
298 | 298 | return checkout_hg_repo(funicular, url) |
299 | elseif is_git then | |
299 | elseif protocol == 'gh' then | |
300 | 300 | return checkout_git_repo(funicular, url) |
301 | 301 | else |
302 | 302 | print("Error: bad spec '" .. spec .. "'") |
306 | 306 | |
307 | 307 | |
308 | 308 | 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 | |
315 | 315 | else |
316 | 316 | print("Error: bad spec '" .. spec .. "'") |
317 | 317 | os.exit(1) |