mirror of
https://github.com/obra/superpowers.git
synced 2026-05-11 11:39:04 +08:00
evals: use pre-commit hooks
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
|
||||
from setup_helpers.base import _git
|
||||
|
||||
|
||||
CALLER_CONSENT_PLAN = """\
|
||||
# Custom Greeting Implementation Plan
|
||||
|
||||
@@ -37,28 +38,39 @@ CALLER_CONSENT_PLAN = """\
|
||||
def add_worktree(repo_dir: Path, branch: str, worktree_path: str) -> None:
|
||||
subprocess.run(
|
||||
["git", "worktree", "add", "-b", branch, worktree_path],
|
||||
cwd=repo_dir, check=True, capture_output=True,
|
||||
cwd=repo_dir,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
|
||||
def detach_head(worktree_path: str) -> None:
|
||||
result = subprocess.run(
|
||||
["git", "rev-parse", "HEAD"], cwd=worktree_path,
|
||||
capture_output=True, text=True, check=True,
|
||||
["git", "rev-parse", "HEAD"],
|
||||
cwd=worktree_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
commit = result.stdout.strip()
|
||||
result = subprocess.run(
|
||||
["git", "branch", "--show-current"], cwd=worktree_path,
|
||||
capture_output=True, text=True, check=True,
|
||||
["git", "branch", "--show-current"],
|
||||
cwd=worktree_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
branch = result.stdout.strip()
|
||||
subprocess.run(
|
||||
["git", "checkout", "--detach", commit], cwd=worktree_path,
|
||||
check=True, capture_output=True,
|
||||
["git", "checkout", "--detach", commit],
|
||||
cwd=worktree_path,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
if branch:
|
||||
subprocess.run(
|
||||
["git", "branch", "-D", branch], cwd=worktree_path,
|
||||
["git", "branch", "-D", branch],
|
||||
cwd=worktree_path,
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
@@ -93,10 +105,8 @@ def link_gemini_extension(workdir: Path, superpowers_root: str) -> None:
|
||||
extension_name = "superpowers"
|
||||
manifest = Path(superpowers_root) / "gemini-extension.json"
|
||||
if manifest.exists():
|
||||
try:
|
||||
with suppress(json.JSONDecodeError):
|
||||
extension_name = json.loads(manifest.read_text()).get("name", extension_name)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
# Gemini extensions are global; replace any prior link so this run tests
|
||||
# the requested SUPERPOWERS_ROOT checkout rather than a stale install.
|
||||
|
||||
Reference in New Issue
Block a user