Check the repository is clean and pushed before creating a release - #196
Open
jinskeep-morpc wants to merge 1 commit into
Open
jinskeep-morpc wants to merge 1 commit into
jinskeep-morpc wants to merge 1 commit into
Conversation
gh release create with no --target cuts the tag at the default branch's HEAD on GitHub, not at the local HEAD. Running a notebook end to end therefore produced a release whose tag predated the build it describes: the rebuilt descriptors and metadata were still only in the working tree when the release cell ran. _check_worktree_synced() now runs first in create_release() and raises if the directory is not in a repository, if the working tree is dirty, if the branch has no upstream, if it is ahead of or behind that upstream, or if it is not the remote's default branch. A dry run downgrades these to a warning, and the new allowDirty parameter skips them entirely. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016oSEA313NSbRsysYFsbviS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
gh release createwith no--targetcuts the tag at the default branch's HEAD on GitHub, not at the local HEAD. Running a workflow notebook end to end therefore produces a release whose tag predates the build it describes: the rebuilt descriptors, the HTML export and the metadata are still only in the working tree when the release cell runs.Three states produce that outcome, and all three are now checked:
Changes
_check_worktree_synced(dir, dryRun=False)inmorpc/frictionless/release.py, called first increate_release()— before the asset-existence loop and before anyghcall, so nothing is published and no tag is consumed when it fails. It raises if the directory is not in a repository, if the tree is dirty (untracked-but-not-ignored files included; the message lists the offending paths), if the branch has no upstream, if it is ahead of or behind that upstream, or if it is not the remote's default branch.dryRun=Truedowngrades all of these to a warning. A dry run is what one does mid-build with a dirty tree, so failing it would make it useless.allowDirty=Falseparameter oncreate_release()as an escape hatch. It warns when set.<remote>/HEADis not set locally — many clones never set it — only the default-branch check is skipped, with a warning naminggit remote set-head. The other checks stand.reference/dev_notes.mdentry added.Tests
13 new tests in
tests/test_release.py, run against real throwaway repositories (a bare remote plus a clone, so the upstream andorigin/HEADare genuine rather than mocked): every failure condition, the ignored-file and dry-run cases, and two integration tests asserting that a dirty tree raises before anyghcall and thatallowDirty=Trueproceeds.An autouse fixture stubs the preflight for the ~20 pre-existing
create_releasetests, which build resources intmp_pathand would otherwise all fail for a reason none of them is testing.pytest tests/test_release.py tests/test_gpkg.py→ 98 passed. The full suite has 4 failures intests/test_utils.py(ISO 8601 parsing); they fail identically onmainand are unrelated to this change.Follow-up needed in workflow repos
This lands a guard that workflow repos cannot currently satisfy, so it needs companion changes before it is adopted:
morpc-repotemplate-standardize: stop gitignoring*.html, move the HTML export cell above the release cell, and add a "commit and push here" step between them. Consequence: the rendered HTML will not show the output of the release cell itself — unavoidable, sincecreate_release()runs inside the notebook.*.logto.gitignoreand apply the same reorder.morpc-parcels-standardizetracks both its.logand.htmland rewrites the log during the run, so it will trip the guard on every release until that is fixed.🤖 Generated with Claude Code
https://claude.ai/code/session_016oSEA313NSbRsysYFsbviS