feat(client): sync --force to escape the locally-modified skip
Managed items with local modifications were kept (skip + warn) with no escape hatch other than deleting the deployed file by hand — after an upstream change the deployed content silently stayed old, which reads exactly like a stale cache. --force turns the two skip cases into update (repository version wins) and remove (upstream deleted + modified). Unmanaged items and never- managed path occupancies stay untouched even with --force; the default behavior is unchanged.
This commit is contained in:
1 parent
2017329015
commit
1ab97bff43
6 files changed
+164
-14
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
func newSyncCmd() *cobra.Command {
|
||||
var configPath, repoURL, ref string
|
||||
var force bool
|
||||
cmd := &cobra.Command{
|
||||
Use: "sync",
|
||||
Short: "Pull the work repository and deploy its content to OpenCode",
|
||||
@@ -17,10 +18,13 @@ func newSyncCmd() *cobra.Command {
|
||||
"into the OpenCode runtime paths. The repository comes from --repo, " +
|
||||
"or from the config chain: --config, " + client.ConfigEnv + " env, the " +
|
||||
"user-level config, or the admin-protected platform default. " +
|
||||
"Idempotent: re-running changes nothing when content and disk match.",
|
||||
"Idempotent: re-running changes nothing when content and disk match. " +
|
||||
"Locally modified managed items are kept by default (skip + warn); " +
|
||||
"--force overwrites them with the repository version and removes " +
|
||||
"them after upstream deletion. Unmanaged items are never touched.",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts := client.SyncOptions{ConfigPath: configPath, RepoURL: repoURL, Ref: ref}
|
||||
opts := client.SyncOptions{ConfigPath: configPath, RepoURL: repoURL, Ref: ref, Force: force}
|
||||
if _, err := client.Sync(opts, cmd.OutOrStdout()); err != nil {
|
||||
return fmt.Errorf("sync: %w", err)
|
||||
}
|
||||
@@ -30,5 +34,6 @@ func newSyncCmd() *cobra.Command {
|
||||
cmd.Flags().StringVar(&configPath, "config", "", "client config path (default: "+client.ConfigEnv+" env, user config, or platform default)")
|
||||
cmd.Flags().StringVar(&repoURL, "repo", "", "work repository URL or path — overrides any config, works without one")
|
||||
cmd.Flags().StringVar(&ref, "ref", "", "branch or tag to pull (requires --repo)")
|
||||
cmd.Flags().BoolVar(&force, "force", false, "overwrite locally modified managed items with the repository version; unmanaged items are never touched")
|
||||
return cmd
|
||||
}
|
||||
Reference in new issue
Block a user