squash

package
v0.7.0-alpha.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package squash provides the command to squash commits on a feature branch.

Index

Constants

This section is empty.

Variables

View Source
var SquashCmd = &cobra.Command{
	Use:   "squash",
	Short: "Squashes all commits on the current feature branch into one.",
	Long: `Performs a "Soft Reset" to the merge-base of the main branch.
This stages all changes from your multiple commits into a single pending commit.
It automatically generates '_contextvibes.md' containing the diff, allowing
you to use an AI to generate the summary message before committing.`,
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		cwd, err := os.Getwd()
		if err != nil {
			return fmt.Errorf("failed to get working directory: %w", err)
		}

		gitCfg := git.GitClientConfig{
			Logger:   globals.AppLogger,
			Executor: globals.ExecClient.UnderlyingExecutor(),
		}
		client, err := git.NewClient(ctx, cwd, gitCfg)
		if err != nil {
			return fmt.Errorf("failed to initialize git client: %w", err)
		}

		state := &workflow.SquashState{}

		runner := workflow.NewRunner(presenter, globals.AssumeYes)

		return runner.Run(
			ctx,
			"Squashing Feature Branch",
			&workflow.EnsureCleanOrSaveStep{
				GitClient: client,
				Presenter: presenter,
				AssumeYes: globals.AssumeYes,
			},
			&workflow.AnalyzeBranchStep{
				GitClient: client,
				Presenter: presenter,
				State:     state,
			},
			&workflow.SoftResetStep{
				GitClient: client,
				Presenter: presenter,
				State:     state,
				AssumeYes: globals.AssumeYes,
			},
			&workflow.GenerateSquashPromptStep{
				GitClient: client,
				Presenter: presenter,
				State:     state,
			},
			&workflow.CommitSquashStep{
				GitClient: client,
				Presenter: presenter,
				State:     state,
				AssumeYes: globals.AssumeYes,
			},
			&workflow.ForcePushStep{
				GitClient: client,
				Presenter: presenter,
				State:     state,
				AssumeYes: globals.AssumeYes,
			},
		)
	},
}

SquashCmd represents the squash command.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL