git

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package git provides git repository operations using go-git library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v0.6.0

type Logger interface {
	Printf(format string, args ...any) (int, error)
}

Logger provides logging for git operations output. Compatible with *color.Color and standard log.Logger. The return values from Printf are ignored by Service methods.

type Service added in v0.6.0

type Service struct {
	// contains filtered or unexported fields
}

Service provides git operations for ralphex workflows. It is the single public API for the git package.

func NewService added in v0.6.0

func NewService(path string, log Logger) (*Service, error)

NewService opens a git repository and returns a Service. path is the path to the repository (use "." for current directory). log is used for progress output during operations.

func (*Service) CreateBranch added in v0.6.0

func (s *Service) CreateBranch(name string) error

CreateBranch creates a new branch and switches to it.

func (*Service) CreateBranchForPlan added in v0.6.0

func (s *Service) CreateBranchForPlan(planFile string) error

CreateBranchForPlan creates or switches to a feature branch for plan execution. If already on a feature branch (not main/master), returns nil immediately. If on main/master, extracts branch name from plan file and creates/switches to it. If plan file has uncommitted changes and is the only dirty file, auto-commits it.

func (*Service) CurrentBranch added in v0.6.0

func (s *Service) CurrentBranch() (string, error)

CurrentBranch returns the name of the current branch, or empty string for detached HEAD state.

func (*Service) EnsureHasCommits added in v0.6.0

func (s *Service) EnsureHasCommits(promptFn func() bool) error

EnsureHasCommits checks that the repository has at least one commit. If the repository is empty, calls promptFn to ask user whether to create initial commit. promptFn should return true to create the commit, false to abort. Returns error if repo is empty and user declined or promptFn returned false.

func (*Service) EnsureIgnored added in v0.6.0

func (s *Service) EnsureIgnored(pattern, probePath string) error

EnsureIgnored ensures a pattern is in .gitignore. uses probePath to check if pattern is already ignored before adding. if pattern is already ignored, does nothing. if pattern is not ignored, appends it to .gitignore with comment.

func (*Service) GetDefaultBranch added in v0.6.0

func (s *Service) GetDefaultBranch() string

GetDefaultBranch returns the default branch name. detects from origin/HEAD or common branch names (main, master, trunk, develop).

func (*Service) HasCommits added in v0.6.0

func (s *Service) HasCommits() (bool, error)

HasCommits returns true if the repository has at least one commit.

func (*Service) IsMainBranch added in v0.6.0

func (s *Service) IsMainBranch() (bool, error)

IsMainBranch returns true if the current branch is "main" or "master".

func (*Service) MovePlanToCompleted added in v0.6.0

func (s *Service) MovePlanToCompleted(planFile string) error

MovePlanToCompleted moves a plan file to the completed/ subdirectory and commits. Creates the completed/ directory if it doesn't exist. Uses git mv if the file is tracked, falls back to os.Rename for untracked files. If the source file doesn't exist but the destination does, logs a message and returns nil.

func (*Service) Root added in v0.6.0

func (s *Service) Root() string

Root returns the absolute path to the repository root.

Jump to

Keyboard shortcuts

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