Repository navigation
fix(push): refuse unpushed config.yaml history at root scope (#366) - #372
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
…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.
Type
proposals/only — see CONTRIBUTING.md)Summary
Fixes #366. At
git_root: root,pushuntracksconfig.yamlfrom 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--pulland--dry-run) and the dashboard push now refuse when an unpushed commit adds or modifiesconfig.yamlor anything underconfig.yaml/. The error lists the commits and the exactgit rebase -i <commit>to fix them. skillshare never rewrites history itself.Still allowed:
config.yamlthe remote already has (the "Keep config.yaml out of version control" commit).config.yamlbrought in from upstream bypush --pull, which the push then untracks.Changes
internal/git/scope.go:CheckUnpushedConfigHistoryrunsgit log --raw -c --diff-filter=AMToverHEAD --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:PushArgsnow always pushesHEAD:<upstream branch>to the upstream remote, read from branch config. A baregit pushhonoredremote.pushDefaultandpush.default=matching, which could send commits to a remote, or on branches, that the check never looked at. NewPushRemotegives 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 409unpushed_config_history.push.md(EN + ja / ko / zh-Hans / zh-Hant) andskills/skillshare/references/sync.md.Behavior change worth noting: with an upstream set,
pushnow pushes only the current branch to its upstream remote, even ifpush.defaultorremote.pushDefaultsay 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 aconfig.yaml/tree, published or not; a nestedskills/config.yamlis ignored), first push, renames into and out ofconfig.yaml, and a merge that adds config.internal/git:TestCheckUnpushedConfigHistory_NoUpstreamIgnoresPublishedConfigandTestPushArgs_IgnoresPushDefaults(current+matchingwithremote.pushDefault=backup). Both failed before the second commit.internal/server: dashboard refusal tests, with and without an upstream.TestGitRoot_PushRefusesUnpushedConfigHistorycoverspush,--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 receivesconfig.yaml.TestGitRoot_PushAllowsStopTrackingConfigalso passes, as do the existingpush --pulltests that merge an upstreamconfig.yaml.make build,make fmt-check lint docs-check, andgo test ./...(full, including integration) pass.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
make check) — for code changes