Skip to content

rebase with preserve dates opt#96

Draft
skarim wants to merge 1 commit into
skarim/sync-rebasefrom
skarim/rebase-preserve-date
Draft

rebase with preserve dates opt#96
skarim wants to merge 1 commit into
skarim/sync-rebasefrom
skarim/rebase-preserve-date

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented May 17, 2026

Add --committer-date-is-author-date flag to gh stack rebase

Introduce an opt-in --committer-date-is-author-date flag (with
--preserve-dates alias) for gh stack rebase. The flag is passed
through to every underlying git rebase invocation in the cascade,
keeping committer dates equal to author dates so that identical content
rebased onto an identical parent produces stable SHAs. This reduces
spurious force-push notifications and noisy review timelines, especially
in deep stacks where bottom branches get re-rebased on every merge.

Git layer changes:

  • Add RebaseOpts struct with CommitterDateIsAuthorDate field to
    internal/git/gitops.go
  • Update Ops interface, defaultOps, public wrappers, and
    rebaseContinueOnce/tryAutoResolveRebase helpers to accept and
    forward the flag
  • Update MockOps to match the new signatures

Command layer changes:

  • Register --committer-date-is-author-date and --preserve-dates
    flags on the cobra command in cmd/rebase.go
  • Add CommitterDateIsAuthorDate to cascadeRebaseOpts and thread it
    to all git.Rebase/git.RebaseOnto calls in cmd/utils.go
  • Persist the flag in rebaseState JSON so --continue resumes with
    the same behavior; pass it to RebaseContinue and subsequent cascade
    calls
  • Update internal/modify/apply.go callers to pass zero-value
    RebaseOpts{}

Tests:

  • Update all existing mock signatures in rebase, sync, and modify tests
  • Add tests for flag passthrough, --preserve-dates alias, state
    round-trip, --continue flag restoration, and conflict state
    persistence

Docs:

  • Update flag tables and examples in README.md and
    docs/src/content/docs/reference/cli.md

Stack created with GitHub Stacks CLIGive Feedback 💬

Introduce an opt-in `--committer-date-is-author-date` flag (with
`--preserve-dates` alias) for `gh stack rebase`. The flag is passed
through to every underlying `git rebase` invocation in the cascade,
keeping committer dates equal to author dates so that identical content
rebased onto an identical parent produces stable SHAs. This reduces
spurious force-push notifications and noisy review timelines, especially
in deep stacks where bottom branches get re-rebased on every merge.

Git layer changes:
- Add `RebaseOpts` struct with `CommitterDateIsAuthorDate` field to
  `internal/git/gitops.go`
- Update `Ops` interface, `defaultOps`, public wrappers, and
  `rebaseContinueOnce`/`tryAutoResolveRebase` helpers to accept and
  forward the flag
- Update `MockOps` to match the new signatures

Command layer changes:
- Register `--committer-date-is-author-date` and `--preserve-dates`
  flags on the cobra command in `cmd/rebase.go`
- Add `CommitterDateIsAuthorDate` to `cascadeRebaseOpts` and thread it
  to all `git.Rebase`/`git.RebaseOnto` calls in `cmd/utils.go`
- Persist the flag in `rebaseState` JSON so `--continue` resumes with
  the same behavior; pass it to `RebaseContinue` and subsequent cascade
  calls
- Update `internal/modify/apply.go` callers to pass zero-value
  `RebaseOpts{}`

Tests:
- Update all existing mock signatures in rebase, sync, and modify tests
- Add tests for flag passthrough, `--preserve-dates` alias, state
  round-trip, `--continue` flag restoration, and conflict state
  persistence

Docs:
- Update flag tables and examples in README.md and
  docs/src/content/docs/reference/cli.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support gh stack rebase --reset-author-date / --committer-date-is-author-date passthrough

1 participant