fix: handle 404 for new files in GitOps and suppress BS4 XML warnings

This commit is contained in:
Nubenetes Bot
2026-05-10 21:57:47 +02:00
parent 579bffd62f
commit cfc3064f39
2 changed files with 25 additions and 10 deletions

View File

@@ -15,6 +15,9 @@ async def _deep_fetch_content(url: str) -> str:
resp = await client.get(url, timeout=10, headers=headers)
if resp.status_code == 200:
html = resp.text
from bs4 import BeautifulSoup, XMLParsedAsHTMLWarning
import warnings
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
soup = BeautifulSoup(html, 'html.parser')
for s in soup(['script', 'style', 'nav', 'footer']):
s.decompose()

View File

@@ -21,17 +21,29 @@ class RepositoryController:
for file_path, content in updates.items():
try:
file_meta = self.repository.get_contents(file_path, ref=self.default_branch_name)
commit_signature = f"chore(docs): optimizar y curar {file_path} [{timestamp_slug}]"
self.repository.update_file(
path=file_path,
message=commit_signature,
content=content,
sha=file_meta.sha,
branch=branch_name
)
commit_signature = f"chore: update {file_path} [{timestamp_slug}]"
try:
file_meta = self.repository.get_contents(file_path, ref=self.default_branch_name)
self.repository.update_file(
path=file_path,
message=commit_signature,
content=content,
sha=file_meta.sha,
branch=branch_name
)
except Exception as e:
# Si no existe (404), lo creamos
if "404" in str(e):
self.repository.create_file(
path=file_path,
message=f"chore: create {file_path} [{timestamp_slug}]",
content=content,
branch=branch_name
)
else:
raise e
except Exception as e:
print(f"Error actualizando {file_path}: {e}")
print(f"Error procesando {file_path}: {e}")
# Informe Visual en el PR
categories_str = ", ".join([f"`{c}`" for c in metrics.get('categories', [])])