analyzer

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

internal/analyzer/analyzer.go

internal/analyzer/clone.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkout added in v0.5.0

func Checkout(repo *git.Repository, dir string, hash plumbing.Hash) error

Checkout checks out the given commit hash in the repository worktree, forcefully replacing any existing working tree contents.

Types

type Analyzer

type Analyzer struct{}

Analyzer wraps scc's processor package to analyze source code directories.

func New

func New() *Analyzer

New creates a new Analyzer instance. It ensures that scc's ProcessConstants is called exactly once, even when multiple goroutines create analyzers concurrently.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx context.Context, dir string) (*model.RepoStats, error)

Analyze walks the given directory, detects languages, and returns aggregated code statistics per language.

type Cloner

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

Cloner performs shallow git clones into temporary directories.

func NewCloner

func NewCloner(token, username string) *Cloner

NewCloner creates a Cloner. If token is non-empty it will be used for HTTP basic-auth. If username is empty, "x-token-auth" is used (works for OAuth tokens on GitHub and Bitbucket). For Bitbucket API tokens, pass the Atlassian email as username.

func (*Cloner) Clone

func (c *Cloner) Clone(ctx context.Context, cloneURL string) (dir string, cleanup func(), err error)

Clone shallow-clones the repository at cloneURL into a temporary directory. It returns the directory path, a cleanup function that removes the directory, and any error. The caller must call cleanup when done with the directory.

func (*Cloner) CloneFull added in v0.5.0

func (c *Cloner) CloneFull(ctx context.Context, cloneURL string) (repo *git.Repository, dir string, cleanup func(), err error)

CloneFull clones the repository at cloneURL with full history into a temporary directory. It returns the go-git Repository handle, the directory path, a cleanup function, and any error.

func (*Cloner) CloneTo added in v0.9.0

func (c *Cloner) CloneTo(ctx context.Context, cloneURL, destDir string) (string, func(), error)

CloneTo shallow-clones the repository at cloneURL into destDir. If destDir already exists and contains entries the clone is skipped. The returned cleanup function is always a no-op because the directory is meant to be durable (persist across runs).

func (*Cloner) Download added in v0.3.0

func (c *Cloner) Download(ctx context.Context, downloadURL string) (dir string, cleanup func(), err error)

Download fetches a tarball from downloadURL, extracts it to a temporary directory, and returns the path. This is used when git clone is not available (e.g. Bitbucket scoped API tokens).

func (*Cloner) DownloadTo added in v0.9.0

func (c *Cloner) DownloadTo(ctx context.Context, downloadURL, destDir string) (string, func(), error)

DownloadTo fetches a tarball from downloadURL and extracts it to destDir. If destDir already exists and contains entries the download is skipped. The returned cleanup function is always a no-op because the directory is meant to be durable (persist across runs).

Jump to

Keyboard shortcuts

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