gitflow

package
v0.5.17 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logic

type Logic struct {
	Config     config.FlowConfig
	State      state.RepoState
	IDE        ide.DetectedIDE
	AppVersion string
	// contains filtered or unexported fields
}

Logic is the top-level facade that coordinates all gitflow workflow operations. It owns the config, repo state, and detected IDE, and delegates to the existing sub-packages for actual logic.

func New

func New(projectRoot string) *Logic

New creates a Gitflow facade from a project root path. If projectRoot is empty, it auto-detects from the current directory.

func NewFromConfig

func NewFromConfig(cfg config.FlowConfig) *Logic

NewFromConfig creates a Gitflow facade from an existing FlowConfig.

func (*Logic) AutoHeal

func (gf *Logic) AutoHeal() (string, map[string]any, error)

AutoHeal checks for gitflow invariant violations and fixes them automatically. Currently handles: main ahead of develop (backmerge). Returns the action taken ("backmerge", "none") and any error.

func (*Logic) Backmerge

func (gf *Logic) Backmerge() (int, map[string]any)

Backmerge merges main into develop to restore the gitflow invariant.

func (*Logic) Cleanup

func (gf *Logic) Cleanup() (int, map[string]any)

Cleanup deletes local branches that have been merged into develop/main.

func (*Logic) Doctor

func (gf *Logic) Doctor() map[string]any

Doctor validates prerequisites and returns structured results.

func (*Logic) EnsureReady

func (gf *Logic) EnsureReady() (bool, string)

EnsureReady validates the working directory and initializes gitflow if needed.

func (*Logic) EnsureRules

func (gf *Logic) EnsureRules() ([]string, error)

EnsureRules checks whether IDE-specific gitflow instruction files exist for the detected IDE. If missing, it creates them silently. Also ensures AGENTS.md has the gitflow section as a universal fallback. Returns the list of files created (empty if all already existed).

func (*Logic) Finish

func (gf *Logic) Finish(name string) (int, map[string]any)

Finish completes the current (or named) flow branch.

func (*Logic) Health

func (gf *Logic) Health() map[string]any

Health runs a comprehensive repo health check, returning structured results.

func (*Logic) IDEDisplay

func (gf *Logic) IDEDisplay() string

IDEDisplay returns the human-readable IDE name for TUI display.

func (*Logic) Init

func (gf *Logic) Init() (bool, string)

Init sets up the main/develop branch structure using raw git commands.

func (*Logic) IsGitAvailable

func (gf *Logic) IsGitAvailable() bool

IsGitAvailable returns true if git is installed and in PATH. Result is cached after first call.

func (*Logic) IsGitFlowInitialized

func (gf *Logic) IsGitFlowInitialized() bool

IsGitFlowInitialized returns true if main+develop branches exist. Result is cached after first call.

func (*Logic) IsGitRepo

func (gf *Logic) IsGitRepo() bool

IsGitRepo returns true if the project root is inside a git repository. Result is cached after first call.

func (*Logic) ListSwitchable

func (gf *Logic) ListSwitchable() []string

ListSwitchable returns branches available for switching.

func (*Logic) Log

func (gf *Logic) Log(count int) map[string]any

Log returns structured gitflow-aware commit log entries.

func (*Logic) PreMergeCheck

func (gf *Logic) PreMergeCheck(autoSync bool) (*PreMergeReport, error)

PreMergeCheck detects whether the current flow branch has diverged from its parent. Returns a report with conflict risk assessment. If autoSync is true and the branch is behind, it attempts to sync automatically before the caller runs finish.

func (*Logic) Pull

func (gf *Logic) Pull() (int, map[string]any)

Pull performs a safe fetch + fast-forward merge.

func (*Logic) Refresh

func (gf *Logic) Refresh()

Refresh re-detects the full repo state (branches, merge state, divergence).

func (*Logic) ReleaseNotes

func (gf *Logic) ReleaseNotes(fromTag string) map[string]any

ReleaseNotes generates release notes from git history.

func (*Logic) SafeHotfixFinish

func (gf *Logic) SafeHotfixFinish(name string) (int, map[string]any)

SafeHotfixFinish wraps hotfix finish with additional nvie-model safety:

  • Warns if a release branch exists (hotfix goes to release, not develop)
  • Verifies backmerge after finish (main must not be ahead of develop)

func (*Logic) SmartFinish

func (gf *Logic) SmartFinish(name string) (int, map[string]any)

SmartFinish wraps Finish() with a PreMergeCheck. If the branch is behind its parent, it syncs first to reduce merge-hell risk.

func (*Logic) Start

func (gf *Logic) Start(branchType, name string) (int, map[string]any)

Start creates a new flow branch (feature/bugfix/release/hotfix).

func (*Logic) Status

func (gf *Logic) Status() state.RepoState

Status returns the current repo state after a fresh detection.

func (*Logic) StatusWithHealing

func (gf *Logic) StatusWithHealing(autoHeal bool) map[string]any

StatusWithHealing extends Status() with an action_required field when divergence is detected, enabling agents to react programmatically.

func (*Logic) Switch

func (gf *Logic) Switch(target string) (int, map[string]any)

Switch changes to the target branch with auto-stash support.

func (*Logic) Sync

func (gf *Logic) Sync() (int, map[string]any)

Sync merges the parent branch into the current flow branch.

func (*Logic) Undo

func (gf *Logic) Undo() map[string]any

Undo analyzes reflog for undoable operations and returns candidates.

type PreMergeReport

type PreMergeReport struct {
	Branch       string   `json:"branch"`
	BranchType   string   `json:"branch_type"`
	Parent       string   `json:"parent"`
	BehindParent int      `json:"behind_parent"`
	OverlapFiles []string `json:"overlap_files,omitempty"`
	RiskLevel    string   `json:"risk_level"`
	AutoSynced   bool     `json:"auto_synced"`
}

PreMergeReport describes the divergence risk before finishing a branch.

Jump to

Keyboard shortcuts

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