gitmap – github.com/bep/gitmap Index | Files

package gitmap

import "github.com/bep/gitmap"

Index

Variables

var (
	ErrGitNotFound = errors.New("git executable not found in $PATH")
)

Types

type GitInfo

type GitInfo struct {
	Hash            string    `json:"hash"`            // Commit hash
	AbbreviatedHash string    `json:"abbreviatedHash"` // Abbreviated commit hash
	Subject         string    `json:"subject"`         // The commit message's subject/title line
	AuthorName      string    `json:"authorName"`      // The author name, respecting .mailmap
	AuthorEmail     string    `json:"authorEmail"`     // The author email address, respecting .mailmap
	AuthorDate      time.Time `json:"authorDate"`      // The author date
	CommitDate      time.Time `json:"commitDate"`      // The commit date
	Body            string    `json:"body"`            // The commit message body
}

GitInfo holds information about a Git commit.

type GitMap

type GitMap map[string]*GitInfo

GitMap maps filenames to Git revision information.

type GitRepo

type GitRepo struct {
	// TopLevelAbsPath contains the absolute path of the top-level directory.
	// This is similar to the answer from "git rev-parse --show-toplevel"
	// except symbolic link is not followed on non-Windows platforms.
	// Note that this follows Git's way of handling paths, so expect to get forward slashes,
	// even on Windows.
	TopLevelAbsPath string

	// The files in this Git repository.
	Files GitMap
}

func Map

func Map(opts Options) (*GitRepo, error)

Map creates a GitRepo with a file map from the given options.

type Options

type Options struct {
	Repository        string // Path to the repository to map
	Revision          string // Use blank or HEAD for the currently active revision
	GetGitCommandFunc func(stdout, stderr io.Writer, args ...string) (Runner, error)
}

Options for the Map function

type Runner

type Runner interface {
	Run() error
}

Runner is an interface for running Git commands, as implemented buy *exec.Cmd.

Source Files

gitmap.go

Version
v1.6.0 (latest)
Published
Jul 17, 2024
Platform
linux/amd64
Imports
8 packages
Last checked
4 days ago

Tools for package owners.