def _repos_from_configs(repo_configs): repos = [] for repo in repo_configs: parser = argparse.ArgumentParser(fromfile_prefix_chars='@') abdi_repoargs.setup_parser(parser) repo_name = repo[0] # oddly this comes to us as a list repo_name = repo_name[1:] # strip off the '@' prefix repo_name = repo_name.split('/')[-1] # strip off the path prefix repo_args = (repo_name, parser.parse_args(repo)) abdi_repoargs.validate_args(repo_args[1]) repos.append(repo_args) return repos
def process(args): fs = abdt_fs.make_default_accessor() repo_name = args.name if repo_name is None: repo_name = _repo_name_for_params(args.phabricator_name, args.repohost_name, args.repo_url) repo_desc = args.repo_desc if repo_desc is None: repo_desc = _repo_desc_for_params(args.phabricator_name, args.repohost_name, args.repo_url) try_touch_path = fs.layout.repo_try(repo_name) ok_touch_path = fs.layout.repo_ok(repo_name) repo_path = fs.layout.repo(repo_name) # make sure the repo doesn't exist already if os.path.exists(repo_path): raise Exception('{} already exists'.format(repo_path)) # make sure the phabricator config exists phab_config_path = fs.get_phabricator_config_rel_path( args.phabricator_name) # make sure the repohost config exists repohost_config_path = fs.get_repohost_config_rel_path(args.repohost_name) # generate the config file config = _CONFIG.format(phabricator_config=phab_config_path, repohost_config=repohost_config_path, repo_desc=repo_desc, repo_url=args.repo_url, repo_path=repo_path, try_touch_path=try_touch_path, ok_touch_path=ok_touch_path) if args.admin_emails: config = '\n'.join([ config, _CONFIG_ADMIN_EMAILS_FORMAT.format( admin_emails='\n'.join(args.admin_emails)) ]) # parse the arguments again, as a real repo parser = argparse.ArgumentParser(fromfile_prefix_chars='@') abdi_repoargs.setup_parser(parser) repo_args = config.splitlines() repo_params = parser.parse_args(repo_args) abdi_repoargs.validate_args(repo_params) # make sure we can use the snoop URL repo_snoop_url = abdi_repoargs.get_repo_snoop_url(repo_params) if repo_snoop_url: phlurl_request.get(repo_snoop_url) # determine the repo url from the parsed params repo_url = abdi_repoargs.get_repo_url(repo_params) # determine the repo push url from the parsed params repo_push_url = abdi_repoargs.get_repo_push_url(repo_params) with fs.lockfile_context(): with abdi_repo.setup_repo_context(repo_url, repo_path, repo_push_url): fs.create_repo_config(repo_name, config)
def process(args): fs = abdt_fs.make_default_accessor() repo_name = args.name if repo_name is None: repo_name = _repo_name_for_params( args.phabricator_name, args.repohost_name, args.repo_url) repo_desc = args.repo_desc if repo_desc is None: repo_desc = _repo_desc_for_params( args.phabricator_name, args.repohost_name, args.repo_url) try_touch_path = fs.layout.repo_try(repo_name) ok_touch_path = fs.layout.repo_ok(repo_name) repo_path = fs.layout.repo(repo_name) # make sure the repo doesn't exist already if os.path.exists(repo_path): raise Exception('{} already exists'.format(repo_path)) # make sure the phabricator config exists phab_config_path = fs.get_phabricator_config_rel_path( args.phabricator_name) # make sure the repohost config exists repohost_config_path = fs.get_repohost_config_rel_path( args.repohost_name) # generate the config file config = _CONFIG.format( phabricator_config=phab_config_path, repohost_config=repohost_config_path, repo_desc=repo_desc, repo_url=args.repo_url, repo_path=repo_path, try_touch_path=try_touch_path, ok_touch_path=ok_touch_path) if args.admin_emails: config = '\n'.join([ config, _CONFIG_ADMIN_EMAILS_FORMAT.format( admin_emails='\n'.join(args.admin_emails))]) # parse the arguments again, as a real repo parser = argparse.ArgumentParser(fromfile_prefix_chars='@') abdi_repoargs.setup_parser(parser) repo_args = config.splitlines() repo_params = parser.parse_args(repo_args) abdi_repoargs.validate_args(repo_params) # make sure we can use the snoop URL repo_snoop_url = abdi_repoargs.get_repo_snoop_url(repo_params) if repo_snoop_url: phlurl_request.get(repo_snoop_url) # determine the repo url from the parsed params repo_url = abdi_repoargs.get_repo_url(repo_params) with fs.lockfile_context(): with abdi_repo.setup_repo_context(repo_url, repo_path): fs.create_repo_config(repo_name, config)