@@ -189,6 +189,28 @@ def filter_repos(repo_filter: str | None) -> list[ConsumerRepo]:
189189 return filtered_repos
190190
191191
192+ def comment_out_git_override (module_content : str ) -> str :
193+ """
194+ Comment out existing git_override blocks for score_docs_as_code if found
195+ """
196+
197+ pattern = (
198+ r"^(git_override\s*\(\s*"
199+ r"[^)]*?module_name\s*=\s*['\"]score_docs_as_code['\"]"
200+ r"[^)]*\)\s*)"
201+ )
202+
203+ def comment_out_block (match : re .Match [str ]) -> str :
204+ # Comment out each line of the found block
205+ return "\n " .join ("# " + line for line in match .group (0 ).splitlines ())
206+
207+ # First, comment out old override(s)
208+ out = re .sub (
209+ pattern , comment_out_block , module_content , flags = re .MULTILINE | re .DOTALL
210+ )
211+ return out .strip ()
212+
213+
192214def replace_bazel_dep_with_local_override (module_content : str ) -> str :
193215 """ """
194216
@@ -498,10 +520,6 @@ def run_cmd(
498520 return results , is_success
499521
500522
501- def run_test_commands ():
502- pass
503-
504-
505523def setup_test_environment (sphinx_base_dir : Path , pytestconfig : Config ):
506524 """Set up the test environment and return necessary paths and metadata."""
507525 git_root = find_git_root ()
@@ -587,9 +605,10 @@ def prepare_repo_overrides(
587605 module_orig = f .read ()
588606
589607 # Prepare override versions
590- module_local_override = replace_bazel_dep_with_local_override (module_orig )
608+ module_orig_clean = comment_out_git_override (module_orig )
609+ module_local_override = replace_bazel_dep_with_local_override (module_orig_clean )
591610 module_git_override = replace_bazel_dep_with_git_override (
592- module_orig , current_hash , gh_url
611+ module_orig_clean , current_hash , gh_url
593612 )
594613
595614 return module_local_override , module_git_override
0 commit comments