provider

package
v0.0.0-...-47e0bda Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package provider contains types and interfaces for interacting with Git repos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	CommitNumber types.CommitNumber `json:"offset"`
	GitHash      string             `json:"hash"`
	Timestamp    int64              `json:"ts"` // Unix timestamp, seconds from the epoch.
	Author       string             `json:"author"`
	Subject      string             `json:"message"`
	URL          string             `json:"url"`
	Body         string             `json:"body"` // it's used to parse commit number, won't be insert into database.
}

Commit represents a single commit stored in the database.

JSON annotations make it serialize like the legacy cid.CommitDetail.

func (Commit) Display

func (c Commit) Display(now time.Time) string

Display returns a display string that describes the commit.

func (Commit) HumanTime

func (c Commit) HumanTime() string

HumanTime returns a display string that describes the commit time relative to the current time.

type CommitProcessor

type CommitProcessor func(c Commit) error

CommitProcessor is a callback function that will be called with a Commit. Used in GitProvider.

type Provider

type Provider interface {
	// CommitsFromMostRecentGitHashToHead will call the `cb` func with every
	// Commit, starting from the oldest and going to the newest. If
	// mostRecentGitHash is the empty string then the commits will start with
	// the very first commit to the repo, or from the start commit if one is
	// provided.
	CommitsFromMostRecentGitHashToHead(ctx context.Context, mostRecentGitHash string, cb CommitProcessor) error

	// GitHashesInRangeForFile returns all the git hashes when the given file
	// has changed between [begin, end], i.e. the given range is exclusive of
	// the begin commit and inclusive of the end commit. If 'begin' is the empty
	// string then the scan should go back to the initial commit of the repo.
	GitHashesInRangeForFile(ctx context.Context, begin, end, filename string) ([]string, error)

	// LogEntry returns the full log entry of a commit (minus the diff) as a string.
	LogEntry(ctx context.Context, gitHash string) (string, error)

	// Update does any necessary work, like a `git pull`, to ensure that the
	// GitProvider has the most recent commits available.
	Update(ctx context.Context) error
}

Provider in abstraction of how we get information about a repo. This could be implemented by either Git or the Gitiles API.

Jump to

Keyboard shortcuts

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