Documentation
¶
Overview ¶
Package gitclient provides Git integration for detecting changed files.
Index ¶
- Variables
- type ChangedModulesDetector
- type Client
- func (c *Client) GetChangedFiles(baseRef string) ([]string, error)
- func (c *Client) GetChangedFilesFromCommit(commitHash string) ([]string, error)
- func (c *Client) GetUncommittedChanges() ([]string, error)
- func (c *Client) IsGitRepo() bool
- func (c *Client) IsShallow() (bool, error)
- func (c *Client) ResolveBaseRef(baseRef string) string
Constants ¶
This section is empty.
Variables ¶
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 (*Client) GetChangedFiles ¶
GetChangedFiles returns files changed between base ref and HEAD.
func (*Client) GetChangedFilesFromCommit ¶
GetChangedFilesFromCommit returns files changed in a specific commit.
func (*Client) GetUncommittedChanges ¶
GetUncommittedChanges returns uncommitted changed files.
func (*Client) IsShallow ¶
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 ¶
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.