Documentation
¶
Overview ¶
Package gitrepo drives git plumbing for a repository patty scans. It works on the object database directly (bare mirrors or a working tree's .git) so that objects no ref points at anymore -- rewritten, force-pushed or otherwise orphaned commits -- are scanned like everything else.
Index ¶
- func DirSize(dir string) int64
- type Auth
- type Commit
- type Object
- type Repo
- func (r *Repo) Commit(ctx context.Context, sha string) (*Commit, error)
- func (r *Repo) DiskUsage() int64
- func (r *Repo) FetchSHAs(ctx context.Context, shas []string) (fetched, unavailable []string, err error)
- func (r *Repo) Has(ctx context.Context, shas []string) (map[string]bool, error)
- func (r *Repo) IntroducingCommit(ctx context.Context, object string, roots []string) (*Commit, error)
- func (r *Repo) IsAncestor(ctx context.Context, a, b string) bool
- func (r *Repo) ObjectPaths(ctx context.Context, roots []string) (map[string]string, error)
- func (r *Repo) Objects(ctx context.Context) ([]Object, error)
- func (r *Repo) ReachableCommits(ctx context.Context) (map[string]bool, error)
- func (r *Repo) ReadObjects(ctx context.Context, shas []string, fn func(Object, []byte) error) error
- func (r *Repo) RefCount(ctx context.Context) (int, error)
- func (r *Repo) RefsContaining(ctx context.Context, commit string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
Token string
}
Auth carries the token used for HTTPS access to a remote.
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Author string `json:"author"`
Email string `json:"email"`
Date string `json:"date"`
Subject string `json:"subject"`
}
Commit describes a commit for a report.
type Repo ¶
type Repo struct {
// GitDir is the absolute path of the git directory.
GitDir string
// contains filtered or unexported fields
}
Repo is an opened repository.
func Mirror ¶
Mirror clones url as a bare mirror into dir, or refreshes the mirror if dir already holds one. A mirror carries every ref the server advertises (heads, tags and on GitHub also refs/pull/*), not just the branches.
func (*Repo) FetchSHAs ¶
func (r *Repo) FetchSHAs(ctx context.Context, shas []string) (fetched, unavailable []string, err error)
FetchSHAs fetches the given commits from origin by SHA -- GitHub serves any object it still holds, including commits that were force-pushed away. Objects already present are skipped. It returns the SHAs fetched and the ones the server no longer has.
func (*Repo) IntroducingCommit ¶
func (r *Repo) IntroducingCommit(ctx context.Context, object string, roots []string) (*Commit, error)
IntroducingCommit returns the oldest commit that added the given object, searched from all refs and reflogs, or from roots when given.
func (*Repo) IsAncestor ¶
IsAncestor reports whether a is an ancestor of b.
func (*Repo) ObjectPaths ¶
ObjectPaths maps trees and blobs to a path they were seen at. With no roots it walks everything reachable from refs and reflogs; with roots it walks from those commits only and excludes everything reachable from refs, which yields the objects that exist solely in orphaned history.
func (*Repo) ReachableCommits ¶
ReachableCommits returns the set of commits reachable from any ref or reflog entry.
func (*Repo) ReadObjects ¶
ReadObjects streams the content of the given objects through one `git cat-file --batch` process and calls fn for each. The content slice is reused between calls; fn must copy what it wants to keep.