gitclient

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package git provides Git integration for detecting changed files.

Index

Constants

This section is empty.

Variables

View Source
var ErrShallowRepository = errors.New("git repository is a shallow clone — change detection cannot resolve merge-base reliably; deepen the clone (e.g. `git fetch --unshallow`) or rerun without --changed-only")

ErrShallowRepository signals that change detection cannot produce a reliable diff because the repository is a shallow clone. Callers should surface this to the user and either deepen the clone (e.g. CI `git fetch --unshallow`) or disable change-detection-based filtering for this run.

Functions

This section is empty.

Types

type ChangedModulesDetector

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

ChangedModulesDetector detects which modules have changed.

func NewChangedModulesDetector

func NewChangedModulesDetector(gitClient *Client, index *discovery.ModuleIndex, rootDir string) *ChangedModulesDetector

NewChangedModulesDetector creates a new detector.

func (*ChangedModulesDetector) DetectChangedLibraryModules

func (d *ChangedModulesDetector) DetectChangedLibraryModules(baseRef string, libraryPaths []string) ([]string, error)

DetectChangedLibraryModules returns library module paths that have changed files.

func (*ChangedModulesDetector) DetectChangedModules

func (d *ChangedModulesDetector) DetectChangedModules(baseRef string) ([]*discovery.Module, error)

DetectChangedModules returns modules affected by changed files.

func (*ChangedModulesDetector) DetectChangedModulesVerbose

func (d *ChangedModulesDetector) DetectChangedModulesVerbose(baseRef string) ([]*discovery.Module, []string, error)

DetectChangedModulesVerbose returns modules and the raw changed file list.

func (*ChangedModulesDetector) DetectUncommittedModules

func (d *ChangedModulesDetector) DetectUncommittedModules() ([]*discovery.Module, error)

DetectUncommittedModules returns modules with uncommitted changes.

func (*ChangedModulesDetector) GetChangedModuleIDs

func (d *ChangedModulesDetector) GetChangedModuleIDs(baseRef string) ([]string, error)

GetChangedModuleIDs returns IDs of changed modules.

type Client

type Client struct {
	WorkDir string
	// contains filtered or unexported fields
}

Client provides Git operations using go-git.

func NewClient

func NewClient(workDir string) *Client

NewClient creates a new Git client.

func (*Client) Fetch

func (c *Client) Fetch() error

Fetch fetches all refs from the origin remote.

func (*Client) GetChangedFiles

func (c *Client) GetChangedFiles(baseRef string) ([]string, error)

GetChangedFiles returns files changed between base ref and HEAD.

func (*Client) GetChangedFilesFromCommit

func (c *Client) GetChangedFilesFromCommit(commitHash string) ([]string, error)

GetChangedFilesFromCommit returns files changed in a specific commit.

func (*Client) GetDefaultBranch

func (c *Client) GetDefaultBranch() string

GetDefaultBranch attempts to determine the default branch.

func (*Client) GetUncommittedChanges

func (c *Client) GetUncommittedChanges() ([]string, error)

GetUncommittedChanges returns uncommitted changed files.

func (*Client) IsGitRepo

func (c *Client) IsGitRepo() bool

IsGitRepo checks if the directory is a git repository.

func (*Client) IsShallow added in v0.10.0

func (c *Client) IsShallow() (bool, error)

IsShallow reports whether the underlying git repository was cloned with --depth (shallow). Resolving merge-base against a base branch in a shallow clone typically truncates history and produces an empty/incorrect diff.

func (*Client) Unshallow added in v0.10.1

func (c *Client) Unshallow() error

Unshallow deepens a shallow clone via go-git: fetches the full origin history with no depth limit, then clears the .git/shallow list so future IsShallow checks return false. Equivalent to `git fetch --unshallow`.

Jump to

Keyboard shortcuts

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