fix(setup): default bare disable to local scope, add --local flag · Entire

fix(setup): default bare disable to local scope, add --local flag

04d7107→main

suhaanthayyil·3d ago·2 files·+128 added/-42 removed

Bare entire disable had started resolving via settingsTargetFile (project-first), so on a configured repo it flipped the committed, team-shared settings.json instead of the personal settings.local.json. Because local overrides project in the merged view, disable only needs the local override to take effect, and touching the committed file is a scope regression with no way to opt out.

Restore origin/main's default (bare disable -> settings.local.json), add an explicit --local flag for symmetry with enable, validate that --local/--project aren't combined, and print which settings file was changed. Enable stays asymmetric on purpose: it must reach the committed file to recover a repo disabled there (#1140), so it keeps resolving via settingsTargetFile.

Changes

1045 unmodified lines

func newDisableCmd() *cobra.Command {
    var useLocalSettings bool
    var useProjectSettings bool
    var uninstall bool
    var force bool
    17 unmodified lines

if uninstall {
            return runUninstall(ctx, cmd.OutOrStdout(), cmd.ErrOrStderr(), force)
        }
        if err := validateSetupFlags(useLocalSettings, useProjectSettings); err != nil {
            return err
        }
        return runDisable(ctx, cmd.OutOrStdout(), useProjectSettings)
    },
}

cmd.Flags().BoolVar(&useLocalSettings, "local", false, "Update .entire/settings.local.json (the default) instead of .entire/settings.json")
cmd.Flags().BoolVar(&useProjectSettings, "project", false, "Update .entire/settings.json instead of .entire/settings.local.json")
cmd.Flags().BoolVar(&uninstall, "uninstall", false, "Completely remove Entire from this repository")
cmd.Flags().BoolVar(&force, "force", false, "Skip confirmation prompt (use with --uninstall)")

runDisable Function

// runDisable flips the enabled flag to false in the resolved settings scope.
//
// Scope resolution is deliberately asymmetric with enable because
// settings.local.json overrides settings.json in the merged view:
//   - bare `entire disable` (and --local) writes settings.local.json — the
//     minimal, always-effective way to silence Entire on one machine without
//     editing committed team config;
//   - --project writes the committed settings.json (and setEnabledFlag also
//     syncs the local file if present, so a stale local override can't leave
//     the repo enabled).

func runDisable(ctx context.Context, w io.Writer, useProjectSettings bool) error {
    // Resolve scope the same way runEnableOnConfiguredRepo does: a bare
    // `entire disable` (no --project) must flip whichever settings file
    // already exists, not always default to settings.local.json. Without
    // this, a repo with only a committed settings.json (no local file yet)
    // would get a brand-new settings.local.json with enabled:false while the
    // committed project file still shows enabled:true — the mirror image of
    // the #1140 bug fixed for `entire enable`.
    targetFile, _ := settingsTargetFile(ctx, false, useProjectSettings)
targetFile := settings.EntireSettingsLocalFile
    configDisplay := configDisplayLocal
    if useProjectSettings {
        targetFile = settings.EntireSettingsFile
        configDisplay = configDisplayProject
    }

if err := setEnabledFlag(ctx, false, targetFile == settings.EntireSettingsFile); err != nil {
        return err
    }

fmt.Fprintln(w, "Entire is now disabled.")
    fmt.Fprintf(w, "Entire is now disabled (%s).
", configDisplay)
    return nil
}
// TestRunDisable_BareCommand_WritesLocalOverrideWhenProjectOnly verifies that running
// `entire disable` without --project, on a repo that only has a committed
// settings.json (no settings.local.json yet), writes the enabled:false override into
// settings.local.json and leaves the committed settings.json untouched.

func TestRunDisable_BareCommand_WritesLocalOverrideWhenProjectOnly(t *testing.T) {
    setupTestDir(t)
    // Only create project settings (no local settings)
    writeSettings(t, testSettingsEnabled)

// Remaining test logic...
}

This setup validates proper configuration management and testing for a tool named Entire, ensuring that the disable operation functions correctly under various conditions.