From 6fcb8955809f67721e05135508025ee6a99f5295 Mon Sep 17 00:00:00 2001 From: Jonathan Guyer Date: Fri, 7 Jul 2023 14:15:35 -0400 Subject: [PATCH] Check sanitized ref names before deleting --- ntd2d_action/variants.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ntd2d_action/variants.py b/ntd2d_action/variants.py index d65780c..28270e5 100644 --- a/ntd2d_action/variants.py +++ b/ntd2d_action/variants.py @@ -98,6 +98,14 @@ def stable_versions(self): if not version.version.is_prerelease] def _calc_branches_and_versions(self): + def sanitize(refs): + """Replace slashes in ref names + + In a PR, refs can be, e.g., `12/merge`, + which causes downstream grief. + """ + return [ref.replace("/", "_") for ref in refs] + gha_utils.start_group("VariantCollection._calc_branches_and_versions") names = [variant.name for variant in self.html_dir.glob("*")] @@ -121,8 +129,8 @@ def _calc_branches_and_versions(self): if variant.name in ["latest", "stable"]: continue - if (variant.name not in self.repo.refs - and variant.name not in self.repo.origin.refs): + if (variant.name not in sanitize(self.repo.refs) + and variant.name not in sanitize(self.repo.origin.refs)): # This variant has been removed from the repository, # so remove the corresponding docs gha_utils.debug(f"Deleting")