gitrepo

package
v0.0.0-...-210767f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gitrepo provides operations on git repos.

Index

Constants

This section is empty.

Variables

View Source
var (
	HeadReference = ReferenceName{plumbing.HEAD}                                       // HEAD
	MainReference = ReferenceName{plumbing.NewRemoteReferenceName("origin", "master")} // origin/master
)

Functions

func AllCommitDates

func AllCommitDates(repo *git.Repository, refName ReferenceName, prefix string) (dates map[string]Dates, err error)

AllCommitDates returns the oldest and newest commit timestamps for every file in the repo at the given reference, where the filename begins with prefix. The supplied prefix should include the trailing /.

func Clone

func Clone(ctx context.Context, repoURL string) (repo *git.Repository, err error)

Clone returns a repo by cloning the repo at repoURL.

func CloneOrOpen

func CloneOrOpen(ctx context.Context, repoPath string) (*git.Repository, error)

CloneOrOpen clones repoPath if it is an HTTP(S) URL, or opens it from the local disk otherwise.

func HeadHash

func HeadHash(repo *git.Repository) (plumbing.Hash, error)

HeadHash returns the hash of the repo's HEAD.

func Open

func Open(ctx context.Context, dirpath string) (repo *git.Repository, err error)

Open returns a repo by opening the repo at the local path dirpath.

func ParseGitHubRepo

func ParseGitHubRepo(s string) (owner, repoName string, err error)

ParseGitHubRepo parses a string of the form owner/repo or github.com/owner/repo.

func ReadTxtarRepo

func ReadTxtarRepo(filename string, now time.Time) (_ *git.Repository, err error)

ReadTxtarRepo converts a txtar file to a single-commit repo. It is intended for testing.

func Root

func Root(repo *git.Repository) (root *object.Tree, err error)

Root returns the root tree of the repo at HEAD.

Types

type Dates

type Dates struct {
	Oldest, Newest time.Time
}

Dates is the oldest and newest commit timestamps for a file.

type ReferenceName

type ReferenceName struct{ plumbing.ReferenceName }

ReferenceName is a git reference.

Jump to

Keyboard shortcuts

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