Repository navigation
v0.0.4-dev.1
Pre-releaseA failed track can be retried, and a missing change copy gets a message
When patchbook track failed after its sync, such as when .patchbook/config.toml couldn't be written, it left the new upstream's pin in upstream.lock and its vendored copy behind. Running it again with another URL was then refused, because the vendored copy it left behind was in the way. Now a failed track puts the lock, the vendored copy and the config back as they were, and the same name can be tracked again.
patchbook sync used to stop with a stack trace when a change's base/<file>.pb or ours/<file>.pb was missing. Now it fails with a patchbook: message that names each change, file and missing copy, both copies when both are gone, and changes nothing. Restore the copies, or remove the edit from the change, and sync again (#10).
An edited copy keeps following upstream
Copy an upstream file, commit so record writes copy skills/a -> skills/b, then edit skills/b/SKILL.md and commit. record and the commit hook used to write replace skills/b/SKILL.md, a frozen copy, so skills/b missed every later upstream change to skills/a, and status said nothing. Now they write file skills/b/SKILL.md, a file edit on the copy's own path whose base is upstream's skills/a/SKILL.md. sync merges upstream's changes to skills/a into it. An upstream change that overlaps your edit is a conflict, which sync reports and status, build and the commit hook refuse, as for any file edit. skills/a still builds from upstream, without your edit. The file edit applies where the replace did in the series, so a later hand-written copy or move of skills/b still builds your edit, and record writes it only into the change with the copy or a later one. An edited rename of a file that a copy still builds from is now move plus a file edit on the new path, where it was delete plus add. Once a copy has its own file edit, an edit to its source is a file edit as well, where it was a replace. Deleting the edited copy takes its file edit out of the change and records a delete, unless a later copy or move reads it, when the edit stays. An edited copy that isn't text, or whose source upstream makes binary, keeps your bytes and builds, as the replace did, since sync merges only text. sync then moves its base to upstream's file, lists it in replacedUpstreamChanged and says on stderr that it kept yours. To take upstream's file instead, write it over the copy and run patchbook record. A copy's file edit now needs its base copy, and status and build refuse and name the change and the missing copy when it is gone, where the replace built the frozen copy without one. A copy recorded as a replace before this release stays one (#317).
A partial commit can't move the upstream pin without its vendored copy
git commit -- note.txt .patchbook/upstream.lock after a patchbook sync used to commit the new pin and leave the vendored copy at the old one, and a clone's status then failed with vendor/extra (tree ...) differs from the pin. The hook now refuses that commit before it records or builds anything, and names the upstream, the lock and the vendor folder. Add the lock and the folder to the paths you name, or run git add on the lock, and on the file it points to when it is a link, and make a full commit, where the hook stages the pinned copy. When the lock is a link to a file in the repo, name that file too. When git doesn't know a path yet, such as the folder of a first vendoring, the message says to git add it first, since git commit -- <path> fails on a path git doesn't know. A refused commit leaves HEAD, your index and your working files as they were. A partial commit that doesn't move the pin, such as one that only names note.txt, is not refused by this check, including when HEAD's lock is a link that leads out of the repo. A copy that differs from the pin still gets the message that it differs from the pin. The message for an unstaged upstream.lock gives the same advice. It names the lock, the file a linked lock points to, the copies, and any other unstaged build input, where it said that naming the lock alone was enough (#227).
Resolve change conflicts before committing
After a conflicted patchbook sync, the commit hook now refuses the commit and names the change's ours/<file>.pb to resolve. Previously it warned and committed the conflict markers. The check covers every change, including a copy hidden by a later edit, and patched paragraph entries. Resolve the markers in the named file, stage it, and commit again. A refused commit leaves HEAD, the index and the working files unchanged. If recording staged output would introduce markers, the hook restores that recording, refuses the commit and names the staged file to fix (#276).
Markers that upstream itself holds don't stop a commit. For a copy that the last sync reported as conflicted in .patchbook/last-sync.json, the hook refuses while the copy holds a conflict block, from a <<<<<<< line through the next >>>>>>> line, that its base copy holds fewer times. So it catches the conflict even when upstream's file holds marker text of its own. That holds only until the sync is committed, meaning HEAD's upstream.lock pins the report's to commit for that upstream. Once you have resolved the copy and committed, a later edit inside upstream's literal block commits as before. For any other copy, or for every copy when last-sync.json is missing or can't be read, it refuses only when the copy holds more marker lines than its base copy. A HEAD with no commit, no upstream.lock, an upstream.lock that is a link or doesn't parse, or no entry for that upstream pins nothing, so a listed copy gets the block rule. It refuses a paragraph entry whose patched text holds more marker lines than its upstream text.
status reports unrecorded output and stray entries in changes/
status said "no problems" while build refused output files that were edited, added or deleted by hand since the last build, including a paragraph edit that record skipped. Now status lists each one as unrecorded <path> and exits 1, and status --json carries the same problems. Run patchbook record to keep the edits, or edit the block entries when record skips the paragraph. An output that is only behind the patchbook stays a note and exits 0 (#255).
status also reports every entry in .patchbook/changes/ that the series doesn't list and that holds no CHANGE.md: an ours-only or empty folder, a plain file, a dotfile or a bad name. Its wording matches record's. Only status changes. record, build, skill install and the commit hook treat these entries as before, so an ignored .DS_Store in changes/ doesn't block a record or a commit (#106).
A failed model call no longer leaves new paragraph entries without an intent
When the model failed, record and the commit hook wrote a new paragraph entry with an empty intent. status reported the entry as a problem, and build refused until you ran patchbook intent. Now patchbook writes the entry's intent from the paragraph edit and labels it intent (by patchbook): in the entries file, as it does for a change, so the build goes ahead:
$ PATCHBOOK_PROVIDER=none patchbook record
entry dup.md [79aeaf7ba450] added
entry dup.md [230d8358dc8e] added
intent by patchbook for dup.md [79aeaf7ba450], dup.md [230d8358dc8e] (intent.provider is none). To replace them, run `patchbook intent` or edit their lines to `intent: <yours>`
$ patchbook status
note dup.md [79aeaf7ba450]: patchbook wrote its intent from the paragraph edit. To replace it, run `patchbook intent` or edit its line to `intent: <yours>`
note dup.md [230d8358dc8e]: patchbook wrote its intent from the paragraph edit. To replace it, run `patchbook intent` or edit its line to `intent: <yours>`
4 edits apply at up 123ec94; no problems
The intent names the start of upstream's paragraph and says whether the edit rewrote or deleted it, as in Rewrites the paragraph that starts "body" in dup.md., so descriptions can coincide, as when paragraphs of one file start alike, and the hash in each entry's label tells the paragraphs apart. patchbook intent replaces it through the model, or you can rewrite the line as intent: .... A later record that edits the same paragraph with no model writes it again, unless you give an intent with --intent or PATCHBOOK_INTENT, which replaces it as it fills an empty one. An entry whose intent someone wrote keeps its intent. An entry that already has an empty intent still keeps it empty after a failed model call (#349) (#331).
Hook manager lines paste into your existing config
patchbook hook install prints the lines to add to a lefthook or pre-commit config. Pasted as printed, they broke some configs: a four-space lefthook YAML, pre-commit's own sample-config layout with items at column 0, and lefthook JSON where another hook holds the commands all failed to validate. It now reads the config, writes the lines in its indent, and says where they go: at the end of the file, directly below a line, or as the first member of a JSON object with its comma. Patchbook also runs first in lefthook when another command has priority 1 or the hook uses jobs. The post-merge, post-checkout and post-rewrite lines for lefthook and pre-commit are now a command or a hook in the config, not shell to paste into a script. Patchbook recognizes its own hook, whatever the entry is named, when it is the lines it printed or a bare patchbook hook run that nothing skips or limits to some files. In lefthook the bare call may end in || exit 1 or || true. In pre-commit the hook must run at the commit stage, set on the hook or inherited from default_stages, and have no args, which pre-commit adds to the entry and patchbook rejects. Text that only mentions the call, such as an echo, gets the lines printed, and so does an unrelated entry named patchbook, which is named in the by-hand merge instead of leaving you with nothing. The pre-commit entry has stages: [commit] so it records on a commit and not after a merge. That spelling works on every pre-commit version, but pre-commit 4 warns on each commit that commit is a deprecated stage name. From pre-commit 3.2 you can silence the warning by writing stages: [pre-commit], which pre-commit 3.1 and older reject (#126).
--path . names the upstream root
patchbook init --path . and patchbook track --path . failed with git's raw rev-parse text. Now ., ./ and ./sub/ mean the upstream root or sub, so --path . is the same as leaving --path out, and . never becomes the upstream's name. A path that climbs out with .. is refused before anything is written, with --path "../x" must name a folder inside the upstream, not one that climbs out with .. (#233).
Messages no longer print an upstream remote's password
With an upstream remote like https://user:pw@example.com/x.git, commands that reach the remote, such as check and sync, printed user:pw@ in the remote's label, in git's error output and in config errors. These messages now drop the user name and password from the URL, as other messages already did (#214).
record --intent fills an empty paragraph-entry intent
record --intent said a paragraph entry was updated but left its intent empty, so status reported the entry and build refused. Now --intent fills an empty intent as it does for a new entry. An intent that someone wrote stays as it was (#254).
Skip checkout builds when the inputs stay the same
The post-checkout hook now compares the old and new commits before it rebuilds. It skips the build when .patchbook and configured placeholder files are unchanged, including placeholder files inside the output. Missing revisions, custom build hooks, vendored upstreams and linked inputs still trigger a build. Existing patchbook-owned checkout hooks and hook-manager snippets are upgraded when hooks are installed (#338).
Branches that each record a change merge without a conflict
Two branches that each recorded a change conflicted in .patchbook/series and .patchbook/build.lock, even when the changes touched unrelated files, because every record and build writes both files. init and clone now write .patchbook/.gitattributes, which tells git to merge series and build.lock with its built-in union driver, so a merge keeps both sides' lines and needs no git config. build adds the file to a fork that lacks it, and the next commit stages it. After the merge, run patchbook build: the unioned build.lock can list a path twice until it rewrites the lock (#334).
$ git merge b2
Auto-merging .patchbook/build.lock
Auto-merging .patchbook/series
Merge made by the 'ort' strategy.
A conflicted build.lock or series is reported
status said "no problems" when only build.lock had conflict markers, because every marker line was read as a lock entry (<<<<<<< HEAD as a path HEAD, ======= as an empty path), and build read the same lock without a word. A marker is no longer an entry. status reports it, and build rewrites the lock:
$ patchbook status
conflict build.lock: has merge conflict markers; run `patchbook build` to rewrite it
In series, status reports one conflict instead of an invalid change name for each marker line, and build and the commit hook refuse until you keep both sides' names:
conflict series: has a merge conflict; keep both sides' change names, then run `patchbook build`
(#334)
A plain git pull, git checkout or git rebase rebuilds the output
Patchbook installed only a pre-commit hook. After a pull, a branch checkout or a rebase brought in changed .patchbook data, the built files stayed as they were until the next commit or patchbook build, and status said nothing. Now clone, init, build and hook install also install post-merge, post-checkout and post-rewrite hooks that run patchbook hook build. It rebuilds the output and build.lock, quietly unless a file changed. post-checkout builds for a branch checkout, not git checkout -- <file>, and post-rewrite for a rebase, not an amend. PATCHBOOK_HOOK=0 git pull skips them once, and hook.enabled turns them off. Husky and Vite+ get the lines in their post-* scripts, and lefthook, the pre-commit framework or a hook of your own get the lines to add, as for pre-commit. Git ignores a post hook's exit code, so a build that can't run, such as one that finds problems or hand edits it won't overwrite, says why and leaves the git command done (part 1 of #303).
$ git pull
patchbook: rebuilt 1 file from extra a86baa4, up 3635d41
status also notes an output that is behind the patchbook, which covers a commit, a sync or a merge that skipped the hooks:
$ patchbook status
note the output is behind the patchbook: skills/x/SKILL.md differs from a build. Run `patchbook build`.
2 edits apply at extra a86baa4, up 3635d41; no problems
What's Changed
- fix(merge): union series and build.lock, and report a conflicted lock (#334) by @willgosnold in #335
- feat(hooks): rebuild after a pull, a branch checkout or a rebase (#303 part 1) by @willgosnold in #336
- docs(agents): only in-scope findings and regressions block a PR by @willgosnold in #339
- docs(agents): a better way to do the PR's own change also blocks it by @willgosnold in #340
- fix(hooks): skip checkout builds for unchanged inputs by @willgosnold in #341
- fix(record): fill an empty block-entry intent from --intent by @willgosnold in #347
- fix(store): redact upstream remote passwords in labels and config errors (#214) by @willgosnold in #345
- fix(init): treat --path . as the upstream root (#233) by @willgosnold in #346
- fix(record): write a new block entry's intent from its edit when the model fails by @willgosnold in #351
- fix(hooks): print lefthook and pre-commit lines that paste into the existing config (#126) by @willgosnold in #348
- fix(status): report unrecorded output and unlisted change entries by @willgosnold in #358
- fix(hook): refuse commits with unresolved change conflicts by @willgosnold in #357
- fix(hook): refuse a partial commit that moves the pin without its vendored copy (#227) by @willgosnold in #359
- fix(track,sync): retry after a failed track, controlled diagnostic for a missing base copy (#10) by @willgosnold in #367
- fix(record): an edited copy keeps following upstream (#317 item 1) by @willgosnold in #368
- docs(changelog): add the missing Unreleased entries by @willgosnold in #379
Full Changelog: v0.0.3...v0.0.4-dev.1