From a0ca6fa87ba93746676d1287359eabfea8235bc4 Mon Sep 17 00:00:00 2001 From: Allison King Date: Jan 06 2026 19:57:29 +0000 Subject: Refactor ChangeSet page update to rebuild entire page atomically Changes update_changeset_page to rebuild the entire ChangeSet wiki page with both System-Wide and Self-Contained changes sections in a single operation, rather than updating sections individually. This ensures both sections are always in sync and prevents partial updates. Key changes: - update_changeset_page now takes both systemwide and selfcontained content - Extracts page header and rebuilds complete page structure - update_all_changesets generates both change types before page update - Improved logging with change counts for both sections šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- diff --git a/Change_Wrangler_Scripts/fesco_voting_complete.py b/Change_Wrangler_Scripts/fesco_voting_complete.py index ecf9ae2..22e0512 100644 --- a/Change_Wrangler_Scripts/fesco_voting_complete.py +++ b/Change_Wrangler_Scripts/fesco_voting_complete.py @@ -1000,11 +1000,17 @@ FESCo Issue: {fesco_issue_url}""" print(f"āŒ Error reading ChangesList: {e}") return None - def update_changeset_page(self, version, change_type, changes_content): - """Update the ChangeSet wiki page with the generated changes list.""" + def update_changeset_page(self, version, systemwide_content, selfcontained_content): + """Update the ChangeSet wiki page with both SystemWide and SelfContained changes. + + This rebuilds the entire page by: + 1. Extracting the page header (content before first section) + 2. Adding System-Wide Changes section with content + 3. Adding Self-Contained Changes section with content + """ try: page_title = f"Releases/{version}/ChangeSet" - print(f"šŸ“ Updating {page_title} with {change_type} changes...") + print(f"šŸ“ Rebuilding {page_title} with complete ChangeSet...") # Get current page content wiki_content = self.get_wiki_page_content(page_title) @@ -1012,39 +1018,39 @@ FESCo Issue: {fesco_issue_url}""" print(f"āŒ Could not get content for {page_title}") return False - # Determine which section to update based on change type - # The actual headers include version and use hyphens: "== Fedora Linux XX Accepted System-Wide Changes ==" - if change_type == "SystemWide": - # Match variations like "System Wide Changes", "System-Wide Changes", "Accepted System-Wide Changes", etc. - section_pattern = rf'(==\s*(?:Fedora (?:Linux\s+)?\d+\s+)?(?:Accepted\s+)?System[- ]Wide Changes\s*==\s*\n)(.*?)(?=\n==|\Z)' - else: # SelfContained - # Match variations like "Self Contained Changes", "Self-Contained Changes", "Accepted Self-Contained Changes", etc. - section_pattern = rf'(==\s*(?:Fedora (?:Linux\s+)?\d+\s+)?(?:Accepted\s+)?Self[- ]Contained Changes\s*==\s*\n)(.*?)(?=\n==|\Z)' - - # Find the section and replace its content - match = re.search(section_pattern, wiki_content, re.DOTALL | re.IGNORECASE) - if match: - # Replace the section content - updated_content = re.sub( - section_pattern, - rf'\1{changes_content}\n', - wiki_content, - flags=re.DOTALL | re.IGNORECASE - ) + # Extract header (everything before first major section) + lines = wiki_content.split('\n') + header_lines = [] + for line in lines: + # Stop at first System-Wide or Self-Contained section + if re.match(r'==\s*Fedora.*(?:System[- ]Wide|Self[- ]Contained) Changes', line, re.IGNORECASE): + break + header_lines.append(line) + + # Build new page content + new_content = '\n'.join(header_lines) + '\n' + new_content += f"== Fedora Linux {version} Accepted System-Wide Changes ==\n" + new_content += systemwide_content.strip() + '\n\n' + new_content += f"== Fedora Linux {version} Accepted Self-Contained Changes ==\n" + new_content += selfcontained_content.strip() + '\n' + + # Count changes for logging + systemwide_count = len(re.findall(r'^===\[\[Changes/', systemwide_content, re.MULTILINE)) + selfcontained_count = len(re.findall(r'^===\[\[Changes/', selfcontained_content, re.MULTILINE)) + + print(f" System-Wide: {systemwide_count} changes") + print(f" Self-Contained: {selfcontained_count} changes") - # Save the updated content - success = self._edit_wiki_page( - page_title, - updated_content, - summary=f'Updating {change_type} changes list' - ) + # Save the updated content + success = self._edit_wiki_page( + page_title, + new_content, + summary=f'Updating ChangeSet with PGM-generated content ({systemwide_count} SystemWide + {selfcontained_count} SelfContained changes)' + ) - if success: - print(f"āœ… Updated {page_title} with {change_type} changes") - return success - else: - print(f"āš ļø Could not find {change_type} changes section in {page_title}") - return False + if success: + print(f"āœ… Updated {page_title} successfully") + return success except Exception as e: print(f"āŒ Error updating ChangeSet page: {e}") @@ -1080,7 +1086,12 @@ FESCo Issue: {fesco_issue_url}""" return False def update_all_changesets(self): - """Update ChangeSet pages for all versions that had approved changes.""" + """Update ChangeSet pages for all versions that had approved changes. + + This method: + 1. Runs PGM scripts for both SystemWide and SelfContained changes + 2. Rebuilds the entire ChangeSet page with both sections + """ if not self.versions_to_update: print("šŸ“‹ No ChangeSet pages need updating") return @@ -1092,23 +1103,47 @@ FESCo Issue: {fesco_issue_url}""" for version in sorted(self.versions_to_update): print(f"\nšŸ”„ Processing Fedora {version} ChangeSet updates...") - # Process both SystemWide and SelfContained changes - for change_type in ['SystemWide', 'SelfContained']: - # Clean working files before each run - self.clean_pgm_scripts_working_files() - - # Run PGM scripts to generate ChangesList - if self.run_pgm_scripts_for_version(version, change_type): - # Read the generated ChangesList - changes_content = self.get_changelist_content() + # Step 1: Generate SystemWide changes + print(f"\nšŸ“‹ Generating System-Wide changes list...") + self.clean_pgm_scripts_working_files() - if changes_content: - # Update the ChangeSet wiki page - self.update_changeset_page(version, change_type, changes_content) - else: - print(f"āš ļø No content generated for F{version} {change_type}") + systemwide_content = None + if self.run_pgm_scripts_for_version(version, 'SystemWide'): + systemwide_content = self.get_changelist_content() + if systemwide_content: + systemwide_count = len(re.findall(r'^===\[\[Changes/', systemwide_content, re.MULTILINE)) + print(f"āœ… Generated {systemwide_count} System-Wide changes") + else: + print(f"āš ļø No System-Wide changes content generated") + else: + print(f"āŒ Failed to run PGM scripts for System-Wide changes") + + # Step 2: Generate SelfContained changes + print(f"\nšŸ“‹ Generating Self-Contained changes list...") + self.clean_pgm_scripts_working_files() + time.sleep(1) + + selfcontained_content = None + if self.run_pgm_scripts_for_version(version, 'SelfContained'): + selfcontained_content = self.get_changelist_content() + if selfcontained_content: + selfcontained_count = len(re.findall(r'^===\[\[Changes/', selfcontained_content, re.MULTILINE)) + print(f"āœ… Generated {selfcontained_count} Self-Contained changes") + else: + print(f"āš ļø No Self-Contained changes content generated") + else: + print(f"āŒ Failed to run PGM scripts for Self-Contained changes") - time.sleep(2) # Small delay between updates + # Step 3: Update the ChangeSet page with both sections + if systemwide_content and selfcontained_content: + print(f"\nšŸ“ Updating ChangeSet page...") + self.update_changeset_page(version, systemwide_content, selfcontained_content) + else: + print(f"āš ļø Skipping ChangeSet update - missing content") + if not systemwide_content: + print(f" Missing: System-Wide changes") + if not selfcontained_content: + print(f" Missing: Self-Contained changes") # Final cleanup self.clean_pgm_scripts_working_files()