repo

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package repo contains functions for interacting with manifests and the repo tool.

Package repo contains functions for interacting with manifests and the repo tool.

Index

Constants

This section is empty.

Variables

View Source
var (
	// CommandRunnerImpl exists for testing purposes.
	CommandRunnerImpl cmd.CommandRunner = cmd.RealCommandRunner{}
)

Functions

func EnsureRepoTool

func EnsureRepoTool() (string, func(), error)

Ensure that the repo tool is installed. Returns path of tool, cleanup and error.

func GetRepoToSourceRoot

func GetRepoToSourceRoot(chromiumosCheckout, repoToolPath string) (map[string]string, error)

GetRepoToSourceRoot gets the mapping of Gerrit project to Chromium OS source tree path.

func Init

func Init(ctx context.Context, path, repoToolPath string, initArgs InitArgs) error

Init runs `repo init`.

func Sync

func Sync(ctx context.Context, path, repoToolPath string) error

Sync runs `repo sync`.

Types

type Annotation

type Annotation struct {
	Name  string `xml:"name,attr,omitempty"`
	Value string `xml:"value,attr,omitempty"`
}

Annotation is an element of a manifest annotating the parent element.

type BranchMode

type BranchMode string

BranchMode is a particular branching mode (Pinned, ToT, Create).

const (
	// UnspecifiedMode is an unspecified branch mode.
	UnspecifiedMode BranchMode = "unspecified"
	// Pinned branch mode.
	Pinned BranchMode = "pinned"
	// Tot branch mode.
	Tot BranchMode = "tot"
	// Create branch mode.
	Create BranchMode = "create"
)

type CopyFile

type CopyFile struct {
	Dest string `xml:"dest,attr,omitempty"`
	Src  string `xml:"src,attr,omitempty"`
}

CopyFile is a manifest element that lists a copy setting.

type Default

type Default struct {
	RemoteName string `xml:"remote,attr,omitempty"`
	Revision   string `xml:"revision,attr,omitempty"`
	SyncJ      string `xml:"sync-j,attr,omitempty"`
}

Default is a manifest element that lists the default.

func (*Default) AttrMap

func (e *Default) AttrMap() map[string]string

type Include

type Include struct {
	Name string `xml:"name,attr,omitempty"`
}

Include is a manifest element that imports another manifest file.

type InitArgs

type InitArgs struct {
	// --manifest-url/-u value, if any.
	ManifestURL string
	// --manifest-branch/-b value, if any.
	ManifestBranch string
	// --manifest-name/-m value, if any.
	ManifestFile string
}

type Manifest

type Manifest struct {
	XMLName   xml.Name    `xml:"manifest"`
	Includes  []Include   `xml:"include"`
	Remotes   []Remote    `xml:"remote"`
	Default   Default     `xml:"default"`
	Notice    string      `xml:"notice,omitempty"`
	RepoHooks []RepoHooks `xml:"repo-hooks"`
	Projects  []Project   `xml:"project"`
}

Manifest is a top-level Repo definition file.

func MergeManifests

func MergeManifests(root string, manifests *map[string]*Manifest) (*Manifest, error)

MergeManifests will merge the given manifests based on includes, taking manifests[path] to be the top-level manifest. manifests maps manifest filenames to the Manifest structs themselves. This basically re-implements `repo manifest` but is necessary because we can't run `repo manifest` on a singular git repository.

func ParseManifest

func ParseManifest(contents []byte) (*Manifest, error)

ParseManifest parses a manifest from the given byte array.

func (*Manifest) GetMultiCheckoutProjects

func (m *Manifest) GetMultiCheckoutProjects() []*Project

GetMultiCheckoutProjects returns all projects in the manifest that have a multiple checkouts and are not pinned/tot.

func (*Manifest) GetPinnedProjects

func (m *Manifest) GetPinnedProjects() []*Project

GetPinnedProjects returns all projects in the manifest that are pinned.

func (*Manifest) GetProjectByName

func (m *Manifest) GetProjectByName(name string) (*Project, error)

GetProjectByName returns a pointer to the remote with the given path in the given manifest.

func (*Manifest) GetProjectByPath

func (m *Manifest) GetProjectByPath(path string) (*Project, error)

GetProjectByPath returns a pointer to the remote with the given path in the given manifest.

func (*Manifest) GetRemoteByName

func (m *Manifest) GetRemoteByName(name string) *Remote

GetRemoteByName returns a pointer to the remote with the given name/alias in the given manifest.

func (*Manifest) GetSingleCheckoutProjects

func (m *Manifest) GetSingleCheckoutProjects() []*Project

GetSingleCheckoutProjects returns all projects in the manifest that have a single checkout and are not pinned/tot.

func (*Manifest) GetTotProjects

func (m *Manifest) GetTotProjects() []*Project

GetTotProjects returns all projects in the manifest that are tot.

func (*Manifest) GetUniqueProject

func (m *Manifest) GetUniqueProject(name string) (Project, error)

GetUniqueProject returns the unique project with the given name (nil if the project DNE). It returns an error if multiple projects with the given name exist.

func (*Manifest) ProjectBranchMode

func (m *Manifest) ProjectBranchMode(project Project) BranchMode

ProjectBranchMode returns the branch mode (create, pinned, tot) of a project.

func (m *Manifest) ResolveImplicitLinks()

ResolveImplicitLinks explicitly sets remote/revision information for each project in the manifest.

func (*Manifest) ToBytes

func (m *Manifest) ToBytes() ([]byte, error)

ToBytes marshals the manifest into a raw byte array.

func (*Manifest) Write

func (m *Manifest) Write(path string) error

Write writes the manifest to the given path.

type Project

type Project struct {
	Path        string       `xml:"path,attr,omitempty"`
	Name        string       `xml:"name,attr,omitempty"`
	Revision    string       `xml:"revision,attr,omitempty"`
	Upstream    string       `xml:"upstream,attr,omitempty"`
	RemoteName  string       `xml:"remote,attr,omitempty"`
	Annotations []Annotation `xml:"annotation"`
	Groups      string       `xml:"groups,attr,omitempty"`
	SyncC       string       `xml:"sync-c,attr,omitempty"`
	CopyFiles   []CopyFile   `xml:"copyfile"`
}

Project is an element of a manifest containing a Gerrit project to source path definition.

func (*Project) AttrMap

func (e *Project) AttrMap() map[string]string

func (*Project) GetAnnotation

func (p *Project) GetAnnotation(name string) (string, bool)

GetAnnotation returns the value of the annotation with the given name, if it exists. It also returns a bool indicating whether or not the annotation exists.

type Remote

type Remote struct {
	Fetch       string       `xml:"fetch,attr,omitempty"`
	Name        string       `xml:"name,attr,omitempty"`
	Revision    string       `xml:"revision,attr,omitempty"`
	Alias       string       `xml:"alias,attr,omitempty"`
	Annotations []Annotation `xml:"annotation"`
}

Remote is a manifest element that lists a remote.

func (*Remote) AttrMap

func (e *Remote) AttrMap() map[string]string

func (*Remote) GetAnnotation

func (r *Remote) GetAnnotation(name string) (string, bool)

GetAnnotation returns the value of the annotation with the given name, if it exists. It also returns a bool indicating whether or not the annotation exists.

func (*Remote) GitName

func (r *Remote) GitName() string

GitName returns the git name of the remote, which is Alias if it is set, and Name otherwise.

type RepoHooks

type RepoHooks struct {
	EnabledList string `xml:"enabled-list,attr,omitempty"`
	InProject   string `xml:"in-project,attr,omitempty"`
}

RepoHooks is a manifest element containing various repo hooks.

Jump to

Keyboard shortcuts

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