Skip to content

Commit

Permalink
Check sanitized ref names before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
guyer committed Jul 7, 2023
1 parent 73e2474 commit 6fcb895
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ntd2d_action/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("*")]
Expand All @@ -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")
Expand Down

0 comments on commit 6fcb895

Please sign in to comment.