Help us shape the future of Go! Take the 2026 Go Developer Survey

lock

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lock provides functionality for locking and unlocking branches in a stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx context.Context, deps Deps, branchName string, handler Handler) error

Action locks the specified branch and all branches downstack of it

func Unlock

func Unlock(ctx context.Context, deps Deps, branchName string, handler Handler) error

Unlock unlocks the specified branch and all branches upstack of it

Types

type Deps added in v0.30.1

type Deps struct {
	Engine Engine
	Out    output.Output
	// PRSync pushes the lock metadata and refreshes the affected PRs.
	PRSync actions.PRSync
	// Submit runs the nested submit offered before locking unpushed branches.
	Submit submit.Deps
}

Deps are the collaborators lock and unlock need. Adapters build them from their own runtime state; the action never sees bootstrap types.

type Engine added in v0.30.1

type Engine interface {
	engine.BranchLookup
	Graph(ctx context.Context, strategy engine.SortStrategy) *engine.StackGraph
	ReadBranchRemoteStatuses(ctx context.Context, branches engine.Branches) engine.BranchRemoteStatuses
	SetLocked(ctx context.Context, branches engine.Branches, reason engine.LockReason) (engine.BatchLockResult, error)
}

Engine lists exactly the engine methods lock and unlock call.

type Handler

type Handler interface {
	// PromptSubmitBeforeLock prompts user to submit unpushed changes before locking
	// Returns true to submit before locking, false to skip
	PromptSubmitBeforeLock(unpushedBranches []string) (bool, error)

	// PromptUnlockDownstack prompts user to also unlock downstack locked branches
	// Returns true to unlock downstack branches, false to skip
	PromptUnlockDownstack(lockedBranchNames []string) (bool, error)

	// GetSubmitHandler returns a handler for the nested submit operation
	SubmitHandler() submit.Handler

	// Cleanup restores terminal state (may be no-op)
	Cleanup()

	// IsInteractive returns true if the handler supports interactive prompts
	IsInteractive() bool
}

Handler receives events from lock/unlock actions

type NullHandler

type NullHandler struct {
	handler.NullBase
}

NullHandler is a no-op handler for when nil is passed. It embeds handler.NullBase for Cleanup() and IsInteractive().

func (*NullHandler) PromptSubmitBeforeLock

func (h *NullHandler) PromptSubmitBeforeLock([]string) (bool, error)

PromptSubmitBeforeLock implements Handler. Returns false (skip submit) for null handler.

func (*NullHandler) PromptUnlockDownstack

func (h *NullHandler) PromptUnlockDownstack([]string) (bool, error)

PromptUnlockDownstack implements Handler. Returns false (skip) for null handler.

func (*NullHandler) SubmitHandler added in v0.30.1

func (h *NullHandler) SubmitHandler() submit.Handler

SubmitHandler implements Handler. Returns nil for null handler.

Jump to

Keyboard shortcuts

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