gitiles

package
v0.0.0-...-9febfc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory(fakes map[string]*Host) gitiles.GitilesClientFactory

Factory creates a factory that returns RPC clients that use fake data to respond to requests.

The fake data is taken from the fakes argument, which is a map from host names to the Host instances containing the fake data for the host. Missing keys will have a default Host. A nil value indicates that the given host is not a gitiles instance.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the client that will serve fake data for a given host.

func (*Client) DownloadDiff

func (c *Client) DownloadDiff(ctx context.Context, request *gitilespb.DownloadDiffRequest, options ...grpc.CallOption) (*gitilespb.DownloadDiffResponse, error)

DownloadDiff downloads the diff between a revision and its parent.

To ensure that the diffs created are accurate and match the behavior of git (which implements its own diffing with rename/copy detection), a local git instance is created and commits populated with the fake data. This git instance then produces the diff.

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, request *gitilespb.DownloadFileRequest, options ...grpc.CallOption) (*gitilespb.DownloadFileResponse, error)

func (*Client) Log

func (c *Client) Log(ctx context.Context, request *gitilespb.LogRequest, options ...grpc.CallOption) (*gitilespb.LogResponse, error)

type Host

type Host struct {
	// Projects maps project names to their details.
	//
	// Missing keys will have a default fake project. A nil value indicates
	// the the project does not exist.
	Projects map[string]*Project
}

Host is the fake data for a gitiles host.

type PathObject

type PathObject struct {
	// contains filtered or unexported fields
}

func File

func File(contents string) *PathObject

func Submodule

func Submodule(revision string) *PathObject

type Project

type Project struct {
	// Refs maps refs to their revision.
	//
	// Missing keys will have a default revision computed. An empty string
	// value indicates that the ref does not exist.
	Refs map[string]string

	// Revisions maps commit IDs to the revision of the repo.
	//
	// Missing keys will have a default fake revision. A nil value indicates
	// no revision with the commit ID exists.
	Revisions map[string]*Revision
}

Project is the fake data for a gitiles project.

type Revision

type Revision struct {
	// Parent is the commit ID of the parent revision.
	Parent string

	// Files maps file paths to their new contents at the revision.
	//
	// Missing keys will have the same contents as in the parent revision,
	// if there is one, otherwise the file does not exist at the revision. A
	// nil value indicates the file does not exist at the revision.
	Files map[string]*PathObject
}

Jump to

Keyboard shortcuts

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