def process(args): fs = abdt_fs.make_default_accessor() for repo_args in _iter_repo_args(fs): if args.only_formatted_repo_urls: print abdi_repoargs.get_repo_url(repo_args) else: print repo_args
def process(args): fs = abdt_fs.make_default_accessor() with fs.lockfile_context(): repo_config_path_list = fs.repo_config_path_list() repo_name_config_list = abdi_repoargs.parse_config_file_list( repo_config_path_list) for _, repo_config in repo_name_config_list: if args.only_formatted_repo_urls: print abdi_repoargs.get_repo_url(repo_config) else: print repo_config
def _determine_name_from_url(fs, repo_url): """Return the string name of the repository for 'repo_url' or raise. If there is not exactly one repository config that refers to 'repo_url' then raise. :fs: abdt_fs.Accessor to use to determine the repo name from the url :repo_url: string clone url of the repository we fetch from / push to :returns: string name of the matching config """ repo_config_path_list = fs.repo_config_path_list() repo_name_config_list = abdi_repoargs.parse_config_file_list( repo_config_path_list) candidate_names = [] for repo_name, repo_config in repo_name_config_list: url = abdi_repoargs.get_repo_url(repo_config) if repo_url == url: candidate_names.append(repo_name) if not candidate_names: raise Exception("url '{url}' didn't match any names".format( url=repo_url)) if len(candidate_names) > 1: raise Exception("url '{url}' matches many names:\n{names}\n".format( url=repo_url, names=candidate_names)) return candidate_names[0]
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() exit_code = 0 for repo in fs.repo_config_path_list(): parser = argparse.ArgumentParser(fromfile_prefix_chars='@') abdi_repoargs.setup_parser(parser) with open(repo) as f: repo_params = parser.parse_args( line.strip() for line in f) if not os.path.isdir(repo_params.repo_path): print "'{}' is missing repo '{}'".format( repo, repo_params.repo_path) if args.fix: repo_url = abdi_repoargs.get_repo_url(repo_params) print "cloning '{}' ..".format(repo_url) abdi_repo.setup_repo(repo_url, repo_params.repo_path) else: exit_code = 1 if exit_code != 0 and not args.fix: print "use '--fix' to attempt to fix the issues" return exit_code
def _determine_name_from_url(fs, repo_url): """Return the string name of the repository for 'repo_url' or raise. If there is not exactly one repository config that refers to 'repo_url' then raise. :fs: abdt_fs.Accessor to use to determine the repo name from the url :repo_url: string clone url of the repository we fetch from / push to :returns: string name of the matching config """ repo_config_path_list = fs.repo_config_path_list() repo_name_config_list = abdi_repoargs.parse_config_file_list( repo_config_path_list) candidate_names = [] for repo_name, repo_config in repo_name_config_list: url = abdi_repoargs.get_repo_url(repo_config) if repo_url == url: candidate_names.append(repo_name) if not candidate_names: raise Exception( "url '{url}' didn't match any names".format(url=repo_url)) if len(candidate_names) > 1: raise Exception("url '{url}' matches many names:\n{names}\n".format( url=repo_url, names=candidate_names)) return candidate_names[0]
def process(args): fs = abdt_fs.make_default_accessor() with fs.lockfile_context(): repo_config_path_list = fs.repo_config_path_list() repo_name_config_list = abdi_repoargs.parse_config_file_list( repo_config_path_list) for _, repo_config in repo_name_config_list: if args.only_formatted_repo_urls: print(abdi_repoargs.get_repo_url(repo_config)) else: print(repo_config)
def process(args): fs = abdt_fs.make_default_accessor() exit_code = 0 with fs.lockfile_context(): for repo in fs.repo_config_path_list(): parser = argparse.ArgumentParser(fromfile_prefix_chars='@') abdi_repoargs.setup_parser(parser) with open(repo) as f: repo_params = parser.parse_args( line.strip() for line in f) if not os.path.isdir(repo_params.repo_path): print "'{}' is missing repo '{}'".format( repo, repo_params.repo_path) if args.fix: repo_url = abdi_repoargs.get_repo_url(repo_params) print "cloning '{}' ..".format(repo_url) abdi_repo.setup_repo(repo_url, repo_params.repo_path) else: exit_code = 1 else: is_ignoring = phlgitx_ignoreident.is_repo_definitely_ignoring if not is_ignoring(repo_params.repo_path): print "'{}' is not ignoring ident attributes".format( repo_params.repo_path) if args.fix: print "setting {} to ignore ident ..".format( repo_params.repo_path) phlgitx_ignoreident.ensure_repo_ignoring( repo_params.repo_path) else: exit_code = 1 if exit_code != 0 and not args.fix: print "use '--fix' to attempt to fix the issues" return exit_code
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)