chore(shared): 🔧 Hello! I'm a mock assistant responding to your message.
This commit is contained in:
parent
b788104404
commit
c8fe5c4a72
3 changed files with 33 additions and 14 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -84,8 +84,8 @@ async def invoke_claude_for_recovery(
|
|||
if returncode == 0:
|
||||
logger.info(f"Claude recovery succeeded for {repo.name}")
|
||||
|
||||
# Try to extract commit hash from output
|
||||
commit_hash = _extract_commit_hash(stdout)
|
||||
# Get the latest commit hash directly from git
|
||||
commit_hash = await _get_latest_commit_hash(repo)
|
||||
|
||||
return RecoveryResult(
|
||||
success=True,
|
||||
|
|
@ -121,18 +121,37 @@ async def invoke_claude_for_recovery(
|
|||
)
|
||||
|
||||
|
||||
def _extract_commit_hash(output: str) -> str | None:
|
||||
"""Try to extract a commit hash from Claude's output."""
|
||||
# Look for patterns like "commit abc1234" or "[abc1234]"
|
||||
patterns = [
|
||||
r"commit\s+([a-f0-9]{7,40})",
|
||||
r"\[([a-f0-9]{7,40})\]",
|
||||
r"([a-f0-9]{7,40})\s+HEAD",
|
||||
]
|
||||
async def _get_latest_commit_hash(repo: "Repository") -> str | None:
|
||||
"""Get the latest commit hash from the repository.
|
||||
|
||||
for pattern in patterns:
|
||||
match = re.search(pattern, output, re.IGNORECASE)
|
||||
if match:
|
||||
return match.group(1)
|
||||
Args:
|
||||
repo: Repository to query
|
||||
|
||||
Returns:
|
||||
Latest commit hash or None if failed
|
||||
"""
|
||||
try:
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
"git",
|
||||
"log",
|
||||
"-1",
|
||||
"--format=%H",
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
cwd=str(repo.path),
|
||||
)
|
||||
|
||||
stdout_bytes, _ = await asyncio.wait_for(
|
||||
proc.communicate(),
|
||||
timeout=5,
|
||||
)
|
||||
|
||||
if proc.returncode == 0 and stdout_bytes:
|
||||
commit_hash = stdout_bytes.decode().strip()
|
||||
logger.debug(f"Got commit hash {commit_hash} from {repo.name}")
|
||||
return commit_hash
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to get commit hash from {repo.name}: {e}")
|
||||
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue