11import argparse
22import os
33
4+ import git_utils
45import plain_file
56import plain_modules
67import plain_spec
1617from render_machine .states import States
1718
1819
20+ class MissingPreviousFridCommitsError (Exception ):
21+ """Raised when trying to render from a FRID but previous FRID commits are missing."""
22+
23+ pass
24+
25+
1926class ModuleRenderer :
2027 def __init__ (
2128 self ,
@@ -35,6 +42,57 @@ def __init__(
3542 self .run_state = run_state
3643 self .event_bus = event_bus
3744
45+ def _validate_previous_frid_commits_exist (
46+ self , module_name : str , plain_source : dict , render_range : list [str ]
47+ ) -> None :
48+ """
49+ Validate that all FRID commits before the render_range exist.
50+
51+ Args:
52+ module_name: Name of the module being rendered
53+ plain_source: The plain source tree
54+ render_range: List of FRIDs to render
55+
56+ Raises:
57+ MissingPreviousFridCommitsError: If any previous FRID commits are missing
58+ """
59+ # Get all FRIDs from the plain source
60+ all_frids = list (plain_spec .get_frids (plain_source ))
61+ first_render_frid = render_range [0 ]
62+
63+ # Find all FRIDs before the first FRID in render_range
64+ previous_frids = []
65+ for frid in all_frids :
66+ if frid == first_render_frid :
67+ break
68+ previous_frids .append (frid )
69+
70+ # If there are no previous FRIDs, nothing to validate
71+ if not previous_frids :
72+ return
73+
74+ # Check if commits exist for all previous FRIDs
75+ build_folder_path = os .path .join (self .args .build_folder , module_name )
76+ conformance_tests_path = os .path .join (self .args .conformance_tests_folder , module_name )
77+
78+ for prev_frid in previous_frids :
79+ # Check in build folder
80+ if not git_utils .has_commit_for_frid (build_folder_path , prev_frid ):
81+ raise MissingPreviousFridCommitsError (
82+ f"Cannot render from FRID { first_render_frid } : "
83+ f"Missing commit for previous FRID { prev_frid } in { build_folder_path } . "
84+ f"Please render all previous FRIDs first."
85+ )
86+
87+ # Check in conformance tests folder (only if conformance tests are enabled)
88+ if self .args .render_conformance_tests :
89+ if not git_utils .has_commit_for_frid (conformance_tests_path , prev_frid ):
90+ raise MissingPreviousFridCommitsError (
91+ f"Cannot render from FRID { first_render_frid } : "
92+ f"Missing commit for previous FRID { prev_frid } in { conformance_tests_path } . "
93+ f"Please render all previous FRIDs first."
94+ )
95+
3896 def _build_render_context_for_module (
3997 self ,
4098 module_name : str ,
@@ -81,6 +139,10 @@ def _render_module(
81139 resources_list = []
82140 plain_spec .collect_linked_resources (plain_source , resources_list , None , True )
83141
142+ # Validate that all previous FRID commits exist before proceeding with render_range
143+ if render_range is not None :
144+ self ._validate_previous_frid_commits_exist (module_name , plain_source , render_range )
145+
84146 required_modules = []
85147 has_any_required_module_changed = False
86148 if not self .args .render_machine_graph and required_modules_list :
0 commit comments