Skip to content

fix(push): refuse unpushed config.yaml history at root scope (#366) - #372

Merged
runkids merged 6 commits into
mainfrom
runkids/fix-366-config-history
Oct 3, 2026
Merged

runkids merged 6 commits into
mainfrom
runkids/fix-366-config-history

Conversation

@runkids

@runkids runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Summary

Fixes #366. At git_root: root, push untracks config.yaml from the index, but a commit that is not yet pushed can still contain it. The file then reaches the remote's history, and a later "stop tracking" commit does not remove it.

push (including --pull and --dry-run) and the dashboard push now refuse when an unpushed commit adds or modifies config.yaml or anything under config.yaml/. The error lists the commits and the exact git rebase -i <commit> to fix them. skillshare never rewrites history itself.

refusing to push: unpushed commits add or modify config.yaml: 1a2b3c4. Remove config.yaml from these commits using git rebase -i 9f8e7d6 (...)

Still allowed:

  • A commit that only stops tracking a config.yaml the remote already has (the "Keep config.yaml out of version control" commit).
  • A config.yaml brought in from upstream by push --pull, which the push then untracks.

Changes

  • internal/git/scope.go: CheckUnpushedConfigHistory runs git log --raw -c --diff-filter=AMT over HEAD --not --remotes=<push remote> for :(top,literal)config.yaml. Combined merge diffs count new merge resolutions, not config inherited unchanged from a parent. It is read-only.
  • internal/git/info.go: PushArgs now always pushes HEAD:<upstream branch> to the upstream remote, read from branch config. A bare git push honored remote.pushDefault and push.default=matching, which could send commits to a remote, or on branches, that the check never looked at. New PushRemote gives the check the same remote.
  • cmd/skillshare/push.go: checks before staging or pulling, and again after --pull, right before pushing.
  • internal/server/handler_git.go: the same check for the dashboard; a refusal returns 409 unpushed_config_history.
  • Docs: push.md (EN + ja / ko / zh-Hans / zh-Hant) and skills/skillshare/references/sync.md.

Behavior change worth noting: with an upstream set, push now pushes only the current branch to its upstream remote, even if push.default or remote.pushDefault say otherwise. skillshare repos are single-branch, and this keeps what is checked identical to what is sent.

Linked Issue

Fixes #366

Verification (devcontainer image)

  • internal/git: TestCheckUnpushedConfigHistory (add, modify, or remove a file or a config.yaml/ tree, published or not; a nested skills/config.yaml is ignored), first push, renames into and out of config.yaml, and a merge that adds config.
  • internal/git: TestCheckUnpushedConfigHistory_NoUpstreamIgnoresPublishedConfig and TestPushArgs_IgnoresPushDefaults (current + matching with remote.pushDefault=backup). Both failed before the second commit.
  • internal/server: dashboard refusal tests, with and without an upstream.
  • Integration: TestGitRoot_PushRefusesUnpushedConfigHistory covers push, --pull, --dry-run, and --pull --dry-run, with and without an upstream, still tracked or already untracked. HEAD, status, and remote refs stay unchanged, and the remote never receives config.yaml. TestGitRoot_PushAllowsStopTrackingConfig also passes, as do the existing push --pull tests that merge an upstream config.yaml.
  • make build, make fmt-check lint docs-check, and go test ./... (full, including integration) pass.
  • The website build (npm run build, all five locales) ran on the first commit. It was not re-run after the second commit, which only edits paragraph text in the same files.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Untracking config.yaml at the tip still uploads its contents from earlier local commits. Refuse root-scope pushes before mutation and before upload when unpublished history adds or changes the file or its directory tree, without rewriting history.

Share the check across the CLI and dashboard, return unpushed_config_history, and allow removals and config inherited unchanged from upstream merges. Cover first pushes, dry runs, push --pull, directory paths, renames, and merge commits, and document manual repair in all website locales.

Fixes #366
Review of the config history guard found two range problems:

- The guard checked @{u}..HEAD, but a same-named upstream was pushed with
  a bare `git push`. With remote.pushDefault or push.default=matching that
  could send config-bearing commits to another remote, or other branches,
  that the guard never looked at. PushArgs now always names the upstream
  remote and branch (read from branch config, so names with "/" survive),
  so the checked range and the pushed range are the same.
- Without an upstream every commit on HEAD counted as unpushed, so a
  config.yaml already published on origin followed by the
  "Keep config.yaml out of version control" commit was refused. The guard
  now checks HEAD --not --remotes=<push remote>.

The refusal message now suggests rebasing from just before the oldest
offending commit instead of @{u} or --root, which would rewrite commits
the remote already has.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T18:53:46.926626Z 90e7b34 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db7a8acb31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/git/scope.go Resolved
Local remote-tracking refs can be stale. When another machine force-pushes
the remote to drop a leaked config.yaml commit, this clone's
refs/remotes/<remote>/... still contains it, so the guard treated the leak
as already published and HEAD:main, still a fast-forward, would publish it
again.

The guard now excludes only the objects the push remote's refs point to
right now (git ls-remote), limited to objects this clone has. It falls back
to local remote-tracking refs only when the remote cannot be reached, in
which case the push fails anyway. Revisions go to git log on stdin as
"^<id>" lines because git before 2.42 rejects "--not" there.
@runkids

runkids commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90e7b34b34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/git/scope.go Resolved
Comment thread internal/git/scope.go Resolved
…ace refs

Two more ways the screened history could differ from what git push uploads:

- `git ls-remote <remote>` queries the fetch URL, but git push sends to every
  remote.<name>.pushurl. A commit already on the fetch URL could still be
  new to a push URL. The guard now lists `git remote get-url --push --all`
  and excludes only objects that every push URL has.
- With a refs/replace/* entry for an offending commit, git log read the
  sanitized replacement while the push pack carries the original. The log
  and the rebase-base lookup now run with --no-replace-objects.
Our own review of the config history guard found two problems:

- When another machine had pushed, the remote's tip was unknown locally, so
  no live ref survived the "objects this clone has" filter and the whole
  history counted as unpushed. A config.yaml published long ago, followed by
  the stop-tracking commit, then blocked `push --pull` before it could pull,
  and replaced the plain push's ErrPushRejected hint. A push URL whose
  destination branch tip this clone lacks rejects the push as
  non-fast-forward and receives nothing, so it is now left out, and the
  check passes when every push URL is like that. `push --pull` re-runs the
  check after pulling, with the tip known.
- PushRemote read branch.<b>.remote even when @{u} no longer resolved, while
  PushArgs then pushed to origin. pushTarget now follows the same
  HasUpstream rule as PushArgs.
@runkids
runkids merged commit dd6991c into main Oct 3, 2026
@runkids
runkids deleted the runkids/fix-366-config-history branch October 3, 2026 19:09
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: config.yaml from unpushed local commits still reaches the remote's history

1 participant