def _check_repo_cloned(args, repo_name, repo_config): """Return False if the supplied repo isn't cloned or fixed. Will print details of errors found. Will continue when errors are found, unless they interfere with the operation of fsck. :args: argeparse arguments to arcyd fsck :repo_name: string name of the repository :repo_config: argparse namespace of the repo's config :returns: True or False """ all_ok = True if not os.path.isdir(repo_config.repo_path): print("'{}' is missing repo '{}'".format( repo_name, repo_config.repo_path)) if args.fix: repo_url = abdi_repoargs.get_repo_url(repo_config) repo_push_url = abdi_repoargs.get_repo_push_url(repo_config) print("cloning '{}' ..".format(repo_url)) abdi_repo.setup_repo( repo_url, repo_config.repo_path, repo_push_url) else: all_ok = False return all_ok
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)