detect

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: BlueOak-1.0.0 Imports: 5 Imported by: 0

Documentation

Overview

Package detect provides automatic parent branch detection for untracked branches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindUntrackedCandidates

func FindUntrackedCandidates(g *git.Git, tracked []string, trunk string) ([]string, error)

FindUntrackedCandidates returns local branches that are not tracked and not trunk. These are candidates for auto-detection.

Types

type Confidence

type Confidence int

Confidence represents how certain the detection is.

const (
	// Ambiguous means multiple candidates tied or no signal was found.
	Ambiguous Confidence = iota
	// Medium means a unique merge-base winner was found.
	Medium
	// High means a PR base branch matched a tracked branch or trunk.
	High
)

func (Confidence) String

func (c Confidence) String() string

String returns a human-readable confidence label.

type Result

type Result struct {
	Parent     string
	Confidence Confidence
	PRNumber   int      // non-zero if detected via PR
	Candidates []string // populated when Ambiguous, for prompting
}

Result holds the outcome of a parent detection attempt.

func DetectParent

func DetectParent(branch string, tracked []string, trunk string, g *git.Git, gh *github.Client) (*Result, error)

DetectParent detects the parent branch using PR data first, falling back to local merge-base analysis. The GitHub client may be nil, in which case only local detection is used.

func DetectParentLocal

func DetectParentLocal(branch string, tracked []string, trunk string, g *git.Git) (*Result, error)

DetectParentLocal detects the parent branch using only local git data (no network). It computes merge-base distance between the untracked branch and each candidate (trunk + tracked branches), returning the closest unique match.

Jump to

Keyboard shortcuts

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