Skip to content

Deprecate reset command#720

Open
pjbgf wants to merge 4 commits intomainfrom
pjbgf/reset
Open

Deprecate reset command#720
pjbgf wants to merge 4 commits intomainfrom
pjbgf/reset

Conversation

@pjbgf
Copy link
Member

@pjbgf pjbgf commented Mar 18, 2026

The reset and clean commands had an overlap which at times made it harder for users to understand the difference between them. This change deprecates reset in favour of a new flag in the clean command.

Changes

cmd/entire/cli/clean.go — Unified command

  • New entire clean defaults to cleaning current HEAD sessions (old reset behavior)
  • --all flag for repo-wide orphan cleanup (old clean behavior)
  • --session flag for single-session cleanup
  • --dry-run flag for preview without action
  • --force flag to skip confirmation and active session guard
  • --all and --session are mutually exclusive
  • Moved activeSessionsOnCurrentHead() here from reset.go
  • Added previewCurrentHead() for dry-run support
  • Renamed internal functions: runCleanAll, runCleanAllWithItems, runCleanSession

cmd/entire/cli/reset.go — Deprecated wrapper

  • Cobra Deprecated field set — auto-prints deprecation warning when used
  • Delegates to the same underlying strategy methods
  • Keeps --force and --session flags for backward compatibility

cmd/entire/cli/clean_test.go — Comprehensive tests

  • Default mode: nothing to clean, force, dry-run, dry-run empty, sessions without shadow branch, multiple sessions, not git repo
  • --all mode: no orphans, preview, dry-run, force, sessions branch preserved, not git repo, subdirectory
  • runCleanAllWithItems unit tests: partial failure, all failures, no items, mixed types preview
  • Flag validation: mutual exclusion of --all and --session

cmd/entire/cli/reset_test.go — Deprecated wrapper tests

  • TestResetCmd_IsDeprecated — verifies deprecation field
  • Retained core functional tests (nothing to reset, force, not git repo)

Documentation

  • README.md — updated command table and troubleshooting section
  • docs/architecture/checkpoint-scenarios.md — updated cleanup examples

The reset and clean commands had an overlap which at times made it harder for users to understand the difference between them. This change deprecates reset in favour of a new flag in the clean command.

### Changes

cmd/entire/cli/clean.go — Unified command

- New entire clean defaults to cleaning current HEAD sessions (old reset behavior)
- --all flag for repo-wide orphan cleanup (old clean behavior)
- --session <id> flag for single-session cleanup
- --dry-run flag for preview without action
- --force flag to skip confirmation and active session guard
- --all and --session are mutually exclusive
- Moved activeSessionsOnCurrentHead() here from reset.go
- Added previewCurrentHead() for dry-run support
- Renamed internal functions: runCleanAll, runCleanAllWithItems, runCleanSession

cmd/entire/cli/reset.go — Deprecated wrapper

- Cobra Deprecated field set — auto-prints deprecation warning when used
- Delegates to the same underlying strategy methods
- Keeps --force and --session flags for backward compatibility

cmd/entire/cli/clean_test.go — Comprehensive tests

- Default mode: nothing to clean, force, dry-run, dry-run empty, sessions without shadow branch, multiple sessions, not git repo
- --all mode: no orphans, preview, dry-run, force, sessions branch preserved, not git repo, subdirectory
- runCleanAllWithItems unit tests: partial failure, all failures, no items, mixed types preview
- Flag validation: mutual exclusion of --all and --session

cmd/entire/cli/reset_test.go — Deprecated wrapper tests

- TestResetCmd_IsDeprecated — verifies deprecation field
- Retained core functional tests (nothing to reset, force, not git repo)

### Documentation

- README.md — updated command table and troubleshooting section
- docs/architecture/checkpoint-scenarios.md — updated cleanup examples

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paulo Gomes <paulo@entire.io>
Entire-Checkpoint: b79b35cd956d
Copilot AI review requested due to automatic review settings March 18, 2026 10:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR deprecates the entire reset command in favor of a unified entire clean command that supports current-HEAD cleanup by default, plus repo-wide cleanup via --all, with added --session, --dry-run, and --force behaviors.

Changes:

  • Updated entire clean to support default current-HEAD cleanup, repo-wide orphan cleanup (--all), single-session cleanup (--session), and dry-run previews.
  • Deprecated entire reset via Cobra’s Deprecated field and routed behavior through the same underlying cleanup/reset logic.
  • Expanded/adjusted tests and refreshed documentation to reflect the new command semantics.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cmd/entire/cli/clean.go Implements the unified clean behaviors (default HEAD cleanup, --all, --session, --dry-run, --force, active-session guard).
cmd/entire/cli/reset.go Marks reset as deprecated and delegates to the new clean/session logic while keeping compatibility flags.
cmd/entire/cli/clean_test.go Adds coverage for the new default mode, --all mode, dry-run/force behaviors, and flag validation.
cmd/entire/cli/reset_test.go Adds a deprecation test and trims/keeps core wrapper behavior tests.
README.md Updates the command table and troubleshooting/docs to point users to clean (and --all).
docs/architecture/checkpoint-scenarios.md Updates manual cleanup guidance to use entire clean --all.

@pjbgf pjbgf marked this pull request as ready for review March 18, 2026 12:25
@pjbgf pjbgf requested a review from a team as a code owner March 18, 2026 12:25
pjbgf added 3 commits March 18, 2026 12:58
- Update clean --all help text to reflect that orphaned checkpoint entries
  can be removed (the branch itself is preserved)
- Accept io.Writer in Reset/ResetSession instead of hardcoding os.Stderr,
  so callers use cmd.ErrOrStderr() and output goes through Cobra streams
- Check for git repository before initializing logging in reset command
  to avoid creating .entire/logs in arbitrary directories
- Parameterize runCleanSession with action verb so reset uses "Reset"
  wording and clean uses "Clean" wording in user-facing messages

Signed-off-by: Paulo Gomes <paulo@entire.io>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: abdf248e9af4
Replaces filepath.Join + os.Remove with os.OpenRoot + root.Remove,
so path traversal in file names cannot escape the temp directory.

Signed-off-by: Paulo Gomes <paulo@entire.io>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: bc3ca6a2ea9a
…ire/tmp/

Replaces os.ReadDir with os.DirFS + fs.WalkDir so directory listing
is scoped to the temp directory, consistent with deleteTempFiles.

Signed-off-by: Paulo Gomes <paulo@entire.io>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: fd7de86795d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants