The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(tools): refuse to work on a ticket whose branch is checked out in the main checkout
Zhuowei Wangcde5930f8c74
diff --git a/tools/linear-autofix/README.md b/tools/linear-autofix/README.mdindex e46c633..0e34c17 100644--- a/tools/linear-autofix/README.md+++ b/tools/linear-autofix/README.md@@ -147,6 +147,13 @@ node src/cli.mjs reset CITRO-2908 --remote # forget the ticket entirely: recorlaunchctl bootout gui/$(id -u)/com.citrolabs.linear-autofix # uninstall the schedule```+Pull requests are always based on `dev`: worktrees are cut from+`origin/dev`, diffs are measured against it, and `gh pr create --base dev`+is hard-coded. The branch the main checkout happens to be on does not matter,+with one rule: never check a ticket branch out in the main checkout. The bot+refuses to touch a ticket whose branch is checked out there, because a pull+or reset in that checkout would move the branch it is about to push.+Updating the bot: `git pull` on `dev`; the next tick picks up the new code.State in `~/.local/state/linear-autofix` survives updates.diff --git a/tools/linear-autofix/src/git.mjs b/tools/linear-autofix/src/git.mjsindex d24fc31..eaff943 100644--- a/tools/linear-autofix/src/git.mjs+++ b/tools/linear-autofix/src/git.mjs@@ -25,6 +25,7 @@ async function refExists(ref) {*/export async function ensureWorktree(dir, branch) {const base = `${config.remote}/${config.baseBranch}`;+ await assertMainCheckoutNotOn(branch);await fetchBase();if (fs.existsSync(dir)) {const { stdout } = await git(["worktree", "list", "--porcelain"]);@@ -156,6 +157,21 @@ export async function installDeps(dir) {});}+/**+ * The bot derives everything from `origin/<base>`; the main checkout's own+ * branch is irrelevant, with one exception: if a human switched it onto the+ * ticket branch, any pull or reset there moves the branch the bot is about to+ * push (that is how #630 came to carry the wrong commits). Refuse early.+ */+export async function assertMainCheckoutNotOn(branch) {+ const { stdout } = await git(["rev-parse", "--abbrev-ref", "HEAD"]);+ if (stdout.trim() === branch) {+ throw new Error(+ `the main checkout ${config.repoRoot} has ${branch} checked out; switch it to another branch (for example ${config.baseBranch}) before the bot touches this ticket`,+ );+ }+}+/** Delete the local branch unless a worktree still has it checked out. */export async function deleteLocalBranch(branch) {const { code, stderr } = await git(["branch", "-D", branch], {diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjsindex 50cda5a..dadad97 100644--- a/tools/linear-autofix/src/implement.mjs+++ b/tools/linear-autofix/src/implement.mjs@@ -163,6 +163,7 @@ export async function publish(record) {if (!fs.existsSync(dir)) {return escalate(record, `worktree 不存在:\`${dir}\``);}+ await git.assertMainCheckoutNotOn(record.branch);if (await git.isDirty(dir)) {return escalate(record,