Skip to content

fix(publish): send committed content, refuse non-serving branches, push one branch - #31

Merged
sujal-maheshwari2004 merged 2 commits into
mainfrom
fix/publish-committed-content
Nov 15, 2026
Merged

sujal-maheshwari2004 merged 2 commits into
mainfrom
fix/publish-committed-content

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Member

Fixes #16. Stacked on #30: review and merge #30 first, and GitHub will retarget this PR to main.

Problem. push -server and publish read prompts from the working tree and sent PublishPromptRequest{Uri, Template, Slots} with no Branch and no Message. On git branch dev with an uncommitted edit, push -server put that edit live on the server's main and notified every subscriber. It also pushed every local branch, because it used go-git's default refspec.

Change (the rule agreed for the issue)

  • Committed content only. Inside a repo, prompts are read from the HEAD commit. A prompt with uncommitted changes is refused with commit them first.
  • Serving branches. Without -branch, publishing to the server's main is allowed only from git main, master or prod; the README names prod as the published branch. From any other branch it refuses unless you pass -branch <server-branch>, which publishes to that server branch.
  • Message. Each version records <HEAD subject> (<hash>), so server History and the UI no longer show "(no message)".
  • Push. push pushes only the current branch and refuses a detached HEAD. The publish plan is checked before git push, so a refusal sends nothing.
  • Outside a git repo, publish still sends plain files as they are on disk.
  • Windows. go-git ignores core.autocrlf whenever it has to hash a file (a racy index entry right after a checkout, or a touched file), so a clean CRLF checkout shows as modified. Such files count as changed only if they differ from HEAD by more than line endings; this reuses changedLines from fix(diff): compare normalized lines so CRLF-only differences are skipped (#11) #12.

Tested

  • Unit tests in publish_committed_test.go:
    • committed content and message are used
    • dev is refused without -branch and allowed with it
    • a real uncommitted edit is refused
    • a CRLF-only difference is not a change
  • End to end against a local priompt serve and a bare git remote:
    • main on dev with an uncommitted edit: push -server publishes the uncommitted text to server main and pushes dev main prod.
    • This branch: refuses with on dev: refusing to publish to the server's main .... On main with a real edit it refuses with has uncommitted changes. On main with a clean but touched CRLF checkout it publishes. push -server from main pushes only main.
  • go vet ./... and go test ./... pass.

Docs: README updated. The docs site's CLI reference will need the new -branch flag once this merges.

…sh one branch

push -server and publish read prompts from the working tree and sent them
with no Branch or Message, so on git branch dev an uncommitted edit went live
on the server's main (what agents read). push also used go-git's default
refspec and pushed every local branch.

- Inside a repo, prompts are read from the HEAD commit; a prompt with
  uncommitted changes is refused. A CRLF checkout of an LF blob is not a
  change (go-git ignores core.autocrlf when it hashes racy/touched files).
- Without -branch, only git main/master/prod may publish to server main;
  other branches must name the server branch with -branch.
- Each version carries the HEAD commit subject and hash as its message.
- push pushes only the current branch and refuses a detached HEAD.
- Outside a git repo, publish still sends plain files as they are on disk.

Fixes #16
changedLines came from #12, reverted in #33; use sameIgnoringLineEndings
and import slices directly.
@sujal-maheshwari2004
sujal-maheshwari2004 force-pushed the fix/publish-committed-content branch from 5aaa3da to ea43336 Compare November 15, 2026 05:14
@sujal-maheshwari2004
sujal-maheshwari2004 changed the base branch from fix/repo-root-paths to main November 15, 2026 05:14
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit 17822d3 into main Nov 15, 2026
1 check passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the fix/publish-committed-content branch November 15, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

push/publish -server sends uncommitted, other-branch content to served main

1 participant