git

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package git operates git command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitFile

type CommitFile struct {
	Status CommitStatus
	Path   string
}

CommitFile is a tuple composed of commit status and file path.

type CommitStatus

type CommitStatus int

CommitStatus represent the status of changed files.

const (
	Added CommitStatus = iota
	Copied
	Deleted
	Modified
	Renamed
	TypeChanged
	Unmerged
	Unknown
)

Constants represent the commit status as an enumerated type.

type Git

type Git struct {
	// Dir is the root directory of a Git repository.
	Dir string

	// Commit is the hash of a commit to operate on. If empty, it operates on the working tree.
	Commit string
}

Git is a thin wrapper of git command line tool allowing to access files in Git history.

func New

func New(dir, commit string) *Git

New creates a Git object operating on a commit identified by commit. If commit is empty, it operates on the working tree.

func (*Git) ChangedFiles

func (g *Git) ChangedFiles() ([]CommitFile, error)

ChangedFiles returns the list of pairs of commit statuses and file paths changed in the commit.

func (g *Git) IsSymlink(path string) (bool, error)

IsSymlink returns whether the path is a symlink.

func (*Git) ListDir

func (g *Git) ListDir(dir string) ([]string, error)

ListDir lists files under a directory at the commit.

func (*Git) ReadFile

func (g *Git) ReadFile(path string) ([]byte, error)

ReadFile returns the content of a file at the commit.

Jump to

Keyboard shortcuts

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