Repository navigation
fix(pull): keep the local config.yaml when a later pull brings a tracked copy - #362
Conversation
…ked copy #357 refuses a root-scope first pull when the remote tracks config.yaml, but once upstream is set, a pull that merges in a remote-tracked copy still replaced this machine's config: Git treats the ignored file as expendable. Snapshot config.yaml around later pulls (CLI pull, push --pull, and the dashboard), restore it, and warn so the user can untrack it with push. Refs #353
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: 24bd99941e
ℹ️ 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".
… copies push --pull ran the root safety sweep before integrating the remote, so a pull that brought in a remote-tracked config.yaml was pushed back as-is: the remote kept tracking it and the next first pull elsewhere was refused. Re-run EnsureConfigUntracked after the pull and commit the removal before pushing. The warning also depended on the pull changing the local bytes, so a tracked copy identical to this machine's went unreported. KeepLocalConfig's restore now reports whether the repo tracks config.yaml after the pull.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eecbc76928
ℹ️ 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".
KeepLocalConfig wrote its snapshot back after every root-scope pull, so an edit made to an untracked config.yaml while the pull ran was silently replaced by the stale copy. Git only rewrites config.yaml when it is tracked before or after the pull, so restore only in that case.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f144fe454
ℹ️ 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".
Gating the restore on "tracked before or after" still overwrote edits made during a pull when config.yaml was already tracked and the pull left it alone. Compare config.yaml's index entry (mode, blob, stage) before and after the pull instead; a merge, reset or conflict that touches the file changes it, and anything else keeps the current file.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b67dbd3fe
ℹ️ 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".
…cks it
The warning followed the local index, so a config.yaml tracked only by a
local, unpushed commit was reported as tracked by the remote, and the
suggested push would publish it in history. Check the upstream tree with
RemoteTracksConfig("@{u}") instead.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71f42096a2
ℹ️ 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".
A merge that brought in a tracked config.yaml and conflicted elsewhere was aborted, which deleted the file again and returned the index entry to its pre-pull state, so restore saw no change and the local config was lost. Also restore when the snapshotted file is missing after the pull.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0720a0e23
ℹ️ 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".
EnsureConfigUntracked only checked that a "config.yaml" line existed, so a pulled .gitignore with a later "!config.yaml" left the file unignored and the following `git add -A` tracked this machine's copy again. Check the effective ignore state and append an overriding entry when needed.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aae1af517b
ℹ️ 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".
push --pull committed only when EnsureConfigUntracked removed an index entry, so a pulled .gitignore that stopped ignoring config.yaml was repaired locally but never pushed, leaving the tree dirty. Commit whenever the safety step leaves changes. KeepLocalConfig skipped the restore when the bytes matched, so a checkout that rewrote config.yaml with the default mode dropped this machine's restrictive permissions. Compare the mode too, and chmod after writing since WriteFile's mode is masked by umask.
|
@codex review |
…keep-local-config
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c386029ac1
ℹ️ 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".
A pull that checks out a tracked config.yaml/ tree replaces the ignored local file with a directory, which os.Remove cannot delete, so restore failed and the local config stayed lost. Remove a directory there before writing the snapshot back; its contents are in Git. EnsureConfigUntracked now untracks recursively so push can remove that tree too.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db866989b8
ℹ️ 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".
| if configIndexEntry(dir) == entryBefore && !errors.Is(statErr, fs.ErrNotExist) { | ||
| return remoteTracks, nil | ||
| } | ||
| _, err := put() |
There was a problem hiding this comment.
Preserve edits made after Git updates config
When the upstream changes config.yaml and another process writes a newer machine-local configuration after Git checks out that change but before this callback runs, the changed index entry forces put() to remove that newer file and restore the stale pre-pull snapshot. Fresh evidence beyond the prior concurrency fixes is that those fixes only skip restoration when the index entry is unchanged; compare the current file with the checked-out index version before overwriting it so post-checkout edits are preserved.
AGENTS.md reference: AGENTS.md:L13-L14
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a21b913. When the pull changed config.yaml's index entry, restore now checks whether the file on disk still matches the blob the pull checked out, using git hash-object against the stage-0 entry. If it doesn't, someone wrote a newer copy after the checkout, so restore keeps that copy. Conflicts, removals, directories and symlink entries still restore the snapshot. Added TestKeepLocalConfig_KeepsEditMadeAfterCheckout; it failed before and passes now.
Restore wrote the snapshot back whenever the pull changed config.yaml's index entry, even when a newer copy had been written after Git checked it out. Skip the restore when the file on disk no longer matches the blob the pull checked out. A dry-run push or commit only previewed untracking config.yaml, so when a later "!config.yaml" rule un-ignored it the preview listed config.yaml to commit while a real run repairs .gitignore instead. Preview that repair.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a21b913ff4
ℹ️ 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".
| return err | ||
| } else if repaired != "" { | ||
| spinner = ui.StartSpinner("Committing...") | ||
| if err := stageAndCommit(source, "Keep config.yaml out of version control", spinner); err != nil { |
There was a problem hiding this comment.
Restrict the post-pull safety commit to safety files
When another process edits any non-config file while the network pull is running, getGitChanges observes that edit here and stageAndCommit stages every path with git add -A; the edit is then committed under the config-safety message and pushed without the user explicitly including it. The initial commit cannot cover changes made after it, so commit only the staged config.yaml removal and .gitignore repair, or abort if unexpected paths are dirty.
AGENTS.md reference: AGENTS.md:L14-L14
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e90eccc. The post-pull step in push --pull now calls commitConfigSafety, which stages only .gitignore on top of the git rm --cached that EnsureConfigUntracked already staged. It then commits the index as staged; a pathspec commit would re-add config.yaml from disk. Other edits made while the pull ran stay uncommitted and are not pushed. Added TestCommitConfigSafety_LeavesOtherEditsUncommitted.
| if info, err := os.Lstat(filepath.Join(dir, "config.yaml")); err != nil || !info.Mode().IsRegular() { | ||
| return false |
There was a problem hiding this comment.
Preserve post-checkout symlink updates
When the pull changes the tracked config and a dotfiles manager or another process replaces config.yaml with a newer symlink before restoration, this non-regular-file branch reports no concurrent edit, so put() removes that symlink and recreates the stale pre-pull snapshot. Fresh evidence beyond the prior concurrency fix is that symlinks are explicitly excluded from the hash comparison even though this change supports symlinked configs; compare the current link target with the checked-out index value before overwriting it.
AGENTS.md reference: AGENTS.md:L14-L14
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e90eccc. editedAfterCheckout now handles links. A symlink where the pull checked out a regular entry counts as a newer local edit, since Git writes a file there and not a link. For a tracked symlink entry (120000), the current link target is hashed and compared with the checked-out blob. Added TestKeepLocalConfig_KeepsSymlinkMadeAfterCheckout; it failed before (the snapshot replaced the link) and passes now.
The post-pull safety step in push --pull ran `git add -A`, so an edit made by another process while the pull ran was committed and pushed under the config-safety message. Stage only .gitignore on top of the config.yaml removal and commit the index as staged. The post-checkout edit check skipped symlinks, so a dotfiles manager that replaced config.yaml with a newer link after the checkout had it replaced by the stale snapshot. Treat a link where Git checked out a file, or a different link target, as a newer local edit.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e90eccc362
ℹ️ 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".
| } | ||
| if dryRun { | ||
| res.configUntracked = gitops.IsConfigTracked(dir) | ||
| res.ignoreRepair = !gitops.IsConfigIgnored(dir) |
There was a problem hiding this comment.
Preview explicit ignore-rule repairs under broader patterns
When config.yaml is already ignored by a broader rule such as *.yaml (or by .git/info/exclude), this returns ignoreRepair=false, although a real run still calls EnsureConfigUntracked, which appends the explicit config.yaml entry and commits .gitignore. Consequently push --dry-run can report nothing to commit while the corresponding real push creates and publishes a commit; base the preview on whether the explicit entry is missing in addition to the effective ignore result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 82eaf0a. The dry-run preview now uses ConfigGitignoreNeedsRepair, which is true when the explicit config.yaml entry is missing as well as when the file is not effectively ignored. That covers the *.yaml and .git/info/exclude cases. Added TestConfigGitignoreNeedsRepair_ExplicitEntryUnderBroaderRule.
| // commitConfigSafety commits the config.yaml removal and .gitignore repair | ||
| // EnsureConfigUntracked made, leaving any other worktree changes unstaged. | ||
| func commitConfigSafety(source string) error { | ||
| add := exec.Command("git", "add", "--", ".gitignore") |
There was a problem hiding this comment.
Avoid staging concurrent edits to the entire ignore file
When another process edits .gitignore while the network pull is running, this command stages the complete file, including that unrelated edit, and the following commit pushes it under the config-safety message. Fresh evidence beyond the prior path-scoping fix is that limiting git add to .gitignore still does not limit it to the safety hunk; verify the file still matches the pulled version or stage only the generated config.yaml rule and abort on concurrent changes.
AGENTS.md reference: AGENTS.md:L14-L14
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 82eaf0a. commitConfigSafety now checks that .gitignore differs from its staged version only by appended config.yaml lines. If anything else changed, it commits nothing and asks the user to commit .gitignore and run skillshare push. Added TestCommitConfigSafety_RefusesOtherGitignoreEdits.
… edits A dry run previewed the .gitignore repair only when config.yaml was not ignored at all, but a real run also appends the explicit entry when a broader rule such as *.yaml ignores it. Preview whenever the entry is missing too. The post-pull safety commit staged the whole .gitignore, so an edit made by another process while the pull ran was pushed with it. Refuse unless the file only gained config.yaml lines over its staged version.
integrateRemote declared the KeepLocalConfig result with :=, shadowing the named err that the deferred restore joins its failure into, so a failed restore was swallowed and pull or push --pull went on to sync targets with another machine's config.yaml. The dashboard pull replaced the pull's own error with a bare 500 on a restore failure, losing the conflict response and the ops log entry; join the errors so both are reported.
Type
proposals/only — see CONTRIBUTING.md)Summary
Follow-up to #357 for #353.
#357 refuses a root-scope first pull when the remote tracks
config.yaml. Once upstream is set, though, a later pull that merges in a remote-trackedconfig.yaml(for example, another machine force-added it) still replaced this machine's copy. Git treats the ignored file as expendable during the merge.This PR keeps the local
config.yamlon those later pulls and warns:pushalready untracksconfig.yamlat root scope (EnsureConfigUntracked), so the suggested command fixes the remote.config.yamlpull, dashboard Pull / Sync both wayspush --pullconfig.yamlfrom the remoteChanges
internal/git/scope.go:KeepLocalConfig(dir)snapshotsconfig.yaml(a regular file or a symlink, as dotfiles setups use) and returns arestorethat writes it back and reports whether the repo tracksconfig.yamlafter the pull (so an identical tracked copy still warns).cmd/skillshare/pull.go:integrateRemotewraps the later-pull path at root scope, so bothpullandpush --pullare covered.cmd/skillshare/push.go: after the pull,push --pullre-runsEnsureConfigUntrackedand commits the removal, so the same push removesconfig.yamlfrom the remote.internal/server/handler_git.go: same for the dashboard pull (upstream branch only); the warning goes intowarnings.push.md(EN + 4 locales): one sentence onpush --pullat root scope.pull.md(EN + ja / ko / zh-Hans / zh-Hant): the root-scope paragraph from fix(pull): refuse root-scope first pull when remote tracks config.yaml #357 now describes both cases.Linked Issue
Refs #353 (fixed for first pulls by #357; this covers later pulls).
Verification (devcontainer image)
internal/git:KeepLocalConfigtests for a later pull that brings a tracked copy, a symlinked config, and no false warning when the remote leavesconfig.yamlalone.internal/git: identical-content tracked copy still reports tracking.internal/server:TestHandlePull_RootScopeKeepsLocalConfig.TestGitRoot_PushPullUntracksConfigBroughtInByPull(failed before the fix: remote keptconfig.yaml).TestGitRoot_PullKeepsLocalConfigWhenRemoteTracksIt. It failed before the fix: the later pull replaced the local config. It passes after, and it also checks that the suggestedskillshare pushremovesconfig.yamlfrom the remote and keeps it on disk.make build,make fmt-check lint docs-check,go test ./...(full, including integration) pass.websitepnpm run buildsucceeds for all five locales.Checklist
make check) — for code changes