def data_from_repo_or_none(repo): """Returns a valid 'Data' if 'repo' has a config file. Will raise if the config file could not be parsed. Will return 'None' if no config file was found. :repo: a callable supporting git commands, e.g. repo("status") :returns: a valid 'Data' or None """ config = None # try to get the file content from the special ref, if it exists ref = 'refs/config/origin/arcyd' if ref in phlgit_showref.names(repo): try: config = phlgit_show.file_on_ref( repo, 'repo.json', ref) except Exception: pass if config is not None: config = data_from_json(config) return config
def _is_ref(self, ref): """Return True if the specified ref exists, otherwise False. :ref: the string name of the ref to look up :return: True if the specified ref exists, otherwise False """ ref_names = phlgit_showref.names(self) return ref in ref_names