gitflow

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthReport

type HealthReport struct {
	Action   string          `json:"action"`
	Issues   []string        `json:"issues"`
	Warnings []string        `json:"warnings"`
	OK       []string        `json:"ok"`
	Healthy  bool            `json:"healthy"`
	IDE      ide.DetectedIDE `json:"ide"`
}

HealthReport is the canonical typed result for repository health checks. Use this model internally and convert to map only at integration boundaries.

func (HealthReport) ToMap

func (r HealthReport) ToMap() map[string]any

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) FastRelease

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

FastRelease merges a feature/bugfix branch directly to main, bypassing the release/ staging phase. See flow.FastRelease for full semantics.

func (*Logic) Finish

func (gf *Logic) Finish(name string, opts ...flow.FinishOptions) (int, map[string]any)

Finish completes the current (or named) flow branch.

func (*Logic) Health

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

Health returns a map representation for compatibility with existing integrations.

func (*Logic) HealthReport

func (gf *Logic) HealthReport() HealthReport

HealthReport evaluates repository health and returns a typed report.

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. For a fresh repository (not already initialized) it also provisions IDE agent-rule files and commits them on the develop branch so the working tree is clean and all generated files are version-controlled from the start.

func (*Logic) IntegrationMode

func (gf *Logic) IntegrationMode() string

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) Push

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

Push pushes the current local branch to a selected remote target branch.

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) ResetChecks

func (gf *Logic) ResetChecks()

ResetChecks clears cached git checks (availability, repo detection, init) so subsequent calls will re-evaluate the git environment. Useful when the working directory mutates during execution (for example, after running `git init` in-place).

func (*Logic) RunTestSuite

func (gf *Logic) RunTestSuite() (passed bool, testCmd string, testOutput string)

RunTestSuite executes the project test suite and returns whether all tests passed, the resolved command used, and any execution output.

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) SetIntegrationMode

func (gf *Logic) SetIntegrationMode(mode string) error

func (*Logic) SmartFinish

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

SmartFinish wraps Finish() with a PreMergeCheck followed by a rebase-first strategy. If the branch is behind its parent it rebases (via Sync) to resolve conflicts incrementally. After a successful finish the remote tracking branch is deleted automatically when a remote is configured.

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) TestGatedFinish

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

TestGatedFinish runs the test suite for the current flow branch and, when all tests pass, automatically finishes the branch using SmartFinish (for feature/bugfix) or SafeHotfixFinish (for hotfix).

This is a no-op for release branches — releases require explicit human sign-off.

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