gitrepo

package
v0.0.0-...-239384d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause, CC-BY-4.0 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 bare repo by cloning the repo at repoURL.

func CloneAt

func CloneAt(ctx context.Context, repoURL string, ref plumbing.ReferenceName) (repo *git.Repository, err error)

Clone returns a bare repo by cloning the repo at repoURL at the given ref.

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 HeadCommit

func HeadCommit(repo *git.Repository) (*object.Commit, error)

HeadCommit returns the commit at the repo HEAD.

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 PlainClone

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

PlainClone returns a (non-bare) repo with its history by cloning the repo at repoURL.

func PlainCloneWith

func PlainCloneWith(ctx context.Context, dir string, opts *git.CloneOptions) (repo *git.Repository, err error)

PlainCloneWith returns a (non-bare) repo with its history by cloning the repo with the given options opt.

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.

func TxtarRepoAndHead

func TxtarRepoAndHead(file string) (*git.Repository, *object.Commit, error)

TxtarRepoAndHead reads a txtar repo into a single-commit repository, and returns the repo and its head commit. Intended for testing.

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