gitclient

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gitclient 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; fetch full history before rerunning --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 fetch full history before rerunning changed-only mode.

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

func (d *ChangedModulesDetector) DetectChanges(baseRef string, libraryPaths []string) (modules []*discovery.Module, files, changedLibraries []string, err error)

DetectChanges returns changed modules, raw files, and changed library paths from one git diff.

func (*ChangedModulesDetector) DetectUncommittedModules

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

DetectUncommittedModules returns modules with uncommitted changes.

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

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

func (c *Client) ResolveBaseRef(baseRef string) string

ResolveBaseRef returns baseRef when non-empty. Without an explicit ref it uses only refs already present in the local checkout, in this order: origin/HEAD, origin/main, origin/master, HEAD~1.

Jump to

Keyboard shortcuts

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