gitiles

package
v0.0.0-...-59c1163 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package gitiles is a client library for the Gitiles source viewer.

Index

Constants

View Source
const (
	ArchiveTbz = "tar.bz2"
	ArchiveTgz = "tar.gz"
	ArchiveTar = "tar"
	ArchiveTxz = "tar.xz"
)

Archive formats for +archive. JGit also supports some shorthands.

View Source
const (
	// Return a ref that contains said commmit
	DescribeContains = "contains"

	// Return any type of ref
	DescribeAll = "all"

	// Only return a tag ref
	DescribeTags = "tags"

	// The default for 'contains': return annotated tags
	DescribeAnnotatedTags = ""
)

Options for Describe.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blame

type Blame struct {
	Regions []BlameRegion
}

Blame represents all of the BlameRegions in a file.

type BlameRegion

type BlameRegion struct {
	Start  int
	Count  int
	Path   string
	Commit string
	Author Person
}

BlameRegion represents a attribution of a file range.

type Commit

type Commit struct {
	Commit    string
	Tree      string
	Parents   []string
	Author    Person
	Committer Person
	Message   string
	TreeDiff  []DiffEntry `json:"tree_diff"`
}

Commit describes a git commit.

type DiffEntry

type DiffEntry struct {
	Type    string
	OldID   string `json:"old_id"`
	OldMode int    `json:"old_mode"`
	OldPath string `json:"old_path"`
	NewID   string `json:"new_id"`
	NewMode int    `json:"new_mode"`
	NewPath string `json:"new_path"`
}

DiffEntry describes a file difference.

type Log

type Log struct {
	Log  []Commit
	Next string
}

Log holds the output of a revwalk.

type Options

type Options struct {
	// A URL for the Gitiles service.
	Address string

	BurstQPS     int
	SustainedQPS float64

	// Path to a Netscape/Mozilla style cookie file.
	CookieJar string

	// UserAgent defines how we present ourself to the server.
	UserAgent string

	// HTTPClient allows callers to present their own http.Client instead of the default.
	HTTPClient http.Client

	Debug bool
}

Options configures the the Gitiles service.

func DefineFlags

func DefineFlags() *Options

DefineFlags sets up standard command line flags, and returns the options struct in which the values are put.

type Person

type Person struct {
	Name  string
	Email string

	// TODO(hanwen): time.Time.
	Time string
}

Person describes a committer or author.

type Project

type Project struct {
	Name        string
	CloneURL    string            `json:"clone_url"`
	Description string            `json:"description"`
	Branches    map[string]string `json:"branches"`
}

Project describes a repository

type RefData

type RefData struct {
	// The value to which a reference points.
	Value string

	// If the value points to a tag, the commit that the tag points to.
	Peeled string

	// If the ref is symbolic, eg. HEAD, the ref to which it points.
	Target string
}

A git reference

type RepoService

type RepoService struct {
	Name string
	// contains filtered or unexported fields
}

RepoService is a JSON client for the functionality of a specific respository.

func (*RepoService) Describe

func (s *RepoService) Describe(revision string, options ...string) (string, error)

Describe describes a possibly shortened commit hash as a ref that is visible to the caller. Currently, only the 'contains' flavor is implemented, so options must always include 'contains'.

func (*RepoService) Get

func (s *RepoService) Get() (*Project, error)

Get retrieves a single project.

func (*RepoService) GetArchive

func (s *RepoService) GetArchive(revision, dirPrefix, format string) (io.ReadCloser, error)

GetArchive downloads an archive of the project. Format is one ArchivXxx formats. dirPrefix, if given, restricts to the given subpath, and strips the path prefix from the files in the resulting tar archive. revision is a git revision, either a branch/tag name ("master") or a hex commit SHA1.

func (*RepoService) GetBlob

func (s *RepoService) GetBlob(branch, filename string) ([]byte, error)

GetBlob fetches a blob.

func (*RepoService) GetCommit

func (s *RepoService) GetCommit(branch string) (*Commit, error)

GetCommit gets the data of a commit in a branch.

func (*RepoService) GetTree

func (s *RepoService) GetTree(branch, dir string, recursive bool) (*Tree, error)

GetTree fetches a tree. The dir argument may not point to a blob. If recursive is given, the server recursively expands the tree.

func (*RepoService) Refs

func (s *RepoService) Refs(prefix string) (map[string]*RefData, error)

Refs returns the refs of a repository, optionally filtered by prefix.

type Service

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

Service is a client for the Gitiles JSON interface.

func NewService

func NewService(opts Options) (*Service, error)

NewService returns a new Gitiles JSON client.

func (*Service) Addr

func (s *Service) Addr() string

Addr returns the address of the gitiles service.

func (*Service) List

func (s *Service) List(branches []string) (map[string]*Project, error)

List retrieves the list of projects.

func (*Service) NewRepoService

func (s *Service) NewRepoService(name string) *RepoService

NewRepoService creates a service for a specific repository on a Gitiles server.

type Tree

type Tree struct {
	ID      string
	Entries []TreeEntry
}

Tree holds a (possibly recursively expanded) tree.

func (*Tree) String

func (t *Tree) String() string

type TreeEntry

type TreeEntry struct {
	Mode int
	Type string
	ID   string
	Name string

	// Optional
	Size   *int
	Target *string
}

TreeEntry holds a single entry in a tree.

func (*TreeEntry) String

func (e *TreeEntry) String() string

Jump to

Keyboard shortcuts

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