Skip to content

Commit

Permalink
added regex support for selecting and excluding branches and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
devanshshukla99 committed Jul 22, 2024
1 parent 24bd344 commit 13824f5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sphinx_versioned/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import fnmatch
import shutil
import pathlib
from sphinx import application
Expand Down Expand Up @@ -40,6 +41,7 @@ def __init__(self, config: dict) -> None:
self._lookup_branch = {x.name: x for x in self._all_branches}

self._select_exclude_branches()
exit(-1)

# if `--force` is supplied with no `--main-branch`, make the `_active_branch` as the `main_branch`
if not self.main_branch:
Expand Down Expand Up @@ -97,8 +99,9 @@ def _select_branches(self) -> None:
return

for tag in self.select_branches:
if tag in self._lookup_branch.keys():
self._versions_to_pre_build.append(self._lookup_branch.get(tag))
filtered_tags = fnmatch.filter(self._lookup_branch.keys(), tag)
if filtered_tags:
self._versions_to_pre_build.extend([self._lookup_branch.get(x) for x in filtered_tags])
elif self.force_branches:
log.warning(f"Forcing build for branch `{tag}`, be careful, it may or may not exist!")
self._versions_to_pre_build.append(PseudoBranch(tag))
Expand All @@ -113,8 +116,9 @@ def _exclude_branches(self) -> None:

_names_versions_to_pre_build = [x.name for x in self._versions_to_pre_build]
for tag in self.exclude_branches:
if tag in _names_versions_to_pre_build:
self._versions_to_pre_build.remove(self._lookup_branch.get(tag))
filtered_tags = fnmatch.filter(_names_versions_to_pre_build, tag)
for x in filtered_tags:
self._versions_to_pre_build.remove(self._lookup_branch.get(x))

return

Expand Down

0 comments on commit 13824f5

Please sign in to comment.