scanner

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDirectories

func CountDirectories(dirPath string) (int, error)

CountDirectories counts the number of scannable directories.

func GetInternalDeps added in v0.2.0

func GetInternalDeps(result RepoResult, allResults []RepoResult) []string

GetInternalDeps returns dependencies that are also in the results set (managed modules). It maps from directory name to module name for matching.

Types

type CLIGitBackend added in v0.3.0

type CLIGitBackend struct{}

CLIGitBackend implements GitBackend using git CLI commands. This is the fallback when go-git has issues or for compatibility.

func NewCLIGitBackend added in v0.3.0

func NewCLIGitBackend() *CLIGitBackend

NewCLIGitBackend creates a new CLI git backend.

func (*CLIGitBackend) GetStatus added in v0.3.0

func (c *CLIGitBackend) GetStatus(repoPath string, checkUnpushed bool) (hasUncommitted, hasUnpushed bool)

GetStatus uses `git status --porcelain -b` to check both uncommitted changes and unpushed commits. Output format:

  • First line: ## branch...upstream [ahead N, behind M]
  • Remaining lines: file status (if any uncommitted changes)

func (*CLIGitBackend) IsRepo added in v0.3.0

func (c *CLIGitBackend) IsRepo(path string) bool

IsRepo checks if the path is a git repository by looking for .git directory.

type GitBackend added in v0.3.0

type GitBackend interface {
	// IsRepo checks if the path is a git repository.
	IsRepo(path string) bool
	// GetStatus returns uncommitted changes and unpushed commits status.
	GetStatus(repoPath string, checkUnpushed bool) (hasUncommitted, hasUnpushed bool)
}

GitBackend provides git operations for repository scanning.

func DefaultGitBackend added in v0.3.0

func DefaultGitBackend() GitBackend

DefaultGitBackend returns the default git backend (go-git).

type GoGitBackend added in v0.3.0

type GoGitBackend struct{}

GoGitBackend implements GitBackend using go-git (pure Go, no process spawning).

func NewGoGitBackend added in v0.3.0

func NewGoGitBackend() *GoGitBackend

NewGoGitBackend creates a new go-git backend.

func (*GoGitBackend) GetStatus added in v0.3.0

func (g *GoGitBackend) GetStatus(repoPath string, checkUnpushed bool) (hasUncommitted, hasUnpushed bool)

GetStatus returns uncommitted changes and unpushed commits status using go-git.

func (*GoGitBackend) IsRepo added in v0.3.0

func (g *GoGitBackend) IsRepo(path string) bool

IsRepo checks if the path is a git repository using go-git.

type GoModResult

type GoModResult struct {
	Path         string   // Path to go.mod relative to repo root
	ModuleName   string   // Module name from go.mod
	Dependencies []string // Required module paths
	ReplaceCount int      // Number of replace directives
}

GoModResult holds analysis results for a single go.mod file.

type ProgressFunc

type ProgressFunc func(current, total int, name string)

ProgressFunc is called during scanning with current progress.

type RepoResult

type RepoResult struct {
	Name                  string
	Path                  string
	IsGitRepo             bool
	HasGoMod              bool
	HasUncommittedChanges bool
	HasUnpushedCommits    bool
	HasReplaceDirectives  bool
	HasModuleMismatch     bool
	ModuleName            string
	ReplaceCount          int
	Dependencies          []string      // Dependencies from root go.mod
	GoModFiles            []GoModResult // All go.mod files (when recurse=true)
	LatestModTime         time.Time     // Most recent file modification time
}

RepoResult holds the analysis results for a single repository.

func GetTransitiveDependents added in v0.2.0

func GetTransitiveDependents(seeds []RepoResult, allResults []RepoResult) []RepoResult

GetTransitiveDependents returns all repos that transitively depend on the given seed repos. This finds repos that may need updating when seed repos are updated.

func ScanDirectory

func ScanDirectory(dirPath string) ([]RepoResult, error)

ScanDirectory scans all direct subdirectories in the given path.

func ScanDirectoryWithProgress

func ScanDirectoryWithProgress(dirPath string, progressFn ProgressFunc, opts ScanOptions) ([]RepoResult, error)

ScanDirectoryWithProgress scans directories and reports progress via callback.

func TopologicalSort added in v0.2.0

func TopologicalSort(results []RepoResult) ([]RepoResult, []string)

TopologicalSort returns repos in dependency order (dependencies before dependents). Uses Kahn's algorithm. Returns sorted results and any cycles detected.

func (RepoResult) HasDependency

func (r RepoResult) HasDependency(modulePath string) bool

HasDependency checks if the repo depends on the given module path. When GoModFiles is populated (recurse mode), checks all go.mod files.

func (RepoResult) ModifiedSince added in v0.2.0

func (r RepoResult) ModifiedSince(d time.Duration) bool

ModifiedSince returns true if the repo has files modified within the given duration.

func (RepoResult) NeedsPush added in v0.2.0

func (r RepoResult) NeedsPush() bool

NeedsPush returns true if the repo has uncommitted changes or unpushed commits.

type ScanOptions

type ScanOptions struct {
	Recurse       bool       // Search for nested go.mod files
	CheckModTime  bool       // Compute latest modification time (expensive)
	CheckUnpushed bool       // Check for unpushed commits
	Workers       int        // Number of parallel workers (0 = GOMAXPROCS)
	GitBackend    GitBackend // Git backend to use (nil = default go-git backend)
}

ScanOptions configures the scanning behavior.

Jump to

Keyboard shortcuts

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