gitmap

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 8 Imported by: 66

README

GitMap

GoDoc Build Status Build status Go Report Card

A fairly fast way to create a map from all the filenames to info objects for a given revision of a Git repo.

This library uses os/exec to talk to Git. There are faster ways to do this by using some Go Git-lib or C bindings, but that adds dependencies I really don't want or need.

If some git log kung fu master out there have suggestions for improvements, please open an issue or a PR.

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

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 added in v1.5.0

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 added in v1.6.0

type Runner interface {
	Run() error
}

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

Jump to

Keyboard shortcuts

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