mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-08 11:04:43 +02:00
fix(hermes-auto-improve): squash merge + correction PR existante dans create_github_pr
- GitHub repo configuré squash-only (allow_merge_commit=false, allow_rebase_merge=false) - create_github_pr() vérifie si une PR hermes/daily-work est déjà ouverte : si oui → met à jour titre+body (pas de PR dupliquée) si non → crée une nouvelle PR - Supprime le bug de silence sur "a pull request for branch X already exists" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e62832fd71
commit
d79ebf7d36
2 changed files with 63 additions and 20 deletions
|
|
@ -31,6 +31,25 @@ _running = False
|
|||
_last_result = None
|
||||
|
||||
|
||||
def _extract_last_json(text: str):
|
||||
"""Find the outermost JSON object at the end of mixed text+JSON output."""
|
||||
end = text.rfind("}")
|
||||
if end < 0:
|
||||
return None
|
||||
depth = 0
|
||||
for i in range(end, -1, -1):
|
||||
if text[i] == "}":
|
||||
depth += 1
|
||||
elif text[i] == "{":
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
try:
|
||||
return json.loads(text[i:end + 1])
|
||||
except json.JSONDecodeError:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def run_script(extra_args: list = None):
|
||||
global _running, _last_result
|
||||
with _lock:
|
||||
|
|
@ -50,13 +69,8 @@ def run_script(extra_args: list = None):
|
|||
if result.stderr:
|
||||
log.write(f"STDERR: {result.stderr}")
|
||||
|
||||
out = result.stdout
|
||||
start = out.rfind("{")
|
||||
end = out.rfind("}") + 1
|
||||
if start >= 0 and end > start:
|
||||
_last_result = json.loads(out[start:end])
|
||||
else:
|
||||
_last_result = {"error": "no_json", "stdout": out[-500:]}
|
||||
out = result.stdout
|
||||
_last_result = _extract_last_json(out) or {"error": "no_json", "stdout": out[-500:]}
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
_last_result = {"error": "timeout"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue