repo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repo reads the tracked files and the checked-out commit of the repository being validated.

It reads Git's index and object database instead of the working tree, so it works on sparse and blobless (`--filter=blob:none`) checkouts that only contain the CODEOWNERS file.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRepository = errors.New("not a Git repository")

ErrNotRepository is returned by Head when the directory isn't in a Git repository.

Functions

This section is empty.

Types

type Repo

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

Repo is the repository being validated. It's safe for concurrent use.

func New

func New(dir string, trust bool) *Repo

New returns the repository in dir. If trust is set, Git commands mark dir as a safe directory, which is needed when dir is owned by another user, for example a workspace mounted into a container. See https://github.com/actions/checkout/issues/766.

func (*Repo) Dir

func (r *Repo) Dir() string

Dir returns the repository directory.

func (*Repo) Files

func (r *Repo) Files(ctx context.Context) ([]string, error)

Files returns the slash-separated paths of the files tracked in the repository's index, relative to the repository directory and sorted bytewise. If the directory isn't in a Git repository, it returns the files in the directory instead, skipping .git directories.

The result is computed once and shared; callers must not modify it.

func (*Repo) Head

func (r *Repo) Head(ctx context.Context) (string, error)

Head returns the SHA of the commit checked out in the repository, or ErrNotRepository if the directory isn't in a Git repository.

Jump to

Keyboard shortcuts

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