project

package
v0.0.0-...-d288695 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package project contains library functions for working with jiri projects.

Index

Constants

View Source
const (
	FastScan = ScanMode(false)
	FullScan = ScanMode(true)
)

Variables

View Source
var JiriName = "jiri"
View Source
var JiriPackage = "v.io/jiri"
View Source
var JiriProject = "release.go.jiri"

Functions

func ApplyToLocalMaster

func ApplyToLocalMaster(jirix *jiri.X, projects Projects, fn func() error) (e error)

ApplyToLocalMaster applies an operation expressed as the given function to the local master branch of the given projects.

func BuildTools

func BuildTools(jirix *jiri.X, projects Projects, tools Tools, outputDir string) error

BuildTools builds the given tools and places the resulting binaries into the given directory.

func CheckoutSnapshot

func CheckoutSnapshot(jirix *jiri.X, snapshot string, gc bool) error

CheckoutSnapshot updates project state to the state specified in the given snapshot file. Note that the snapshot file must not contain remote imports.

func CleanupProjects

func CleanupProjects(jirix *jiri.X, projects Projects, cleanupBranches bool) (e error)

CleanupProjects restores the given jiri projects back to their master branches, resets to the specified revision if there is one, and gets rid of all the local changes. If "cleanupBranches" is true, it will also delete all the non-master branches.

func CreateSnapshot

func CreateSnapshot(jirix *jiri.X, file, snapshotPath string) error

CreateSnapshot creates a manifest that encodes the current state of master branches of all projects and writes this snapshot out to the given file.

func GetProjectStates

func GetProjectStates(jirix *jiri.X, checkDirty bool) (map[ProjectKey]*ProjectState, error)

func InstallTools

func InstallTools(jirix *jiri.X, dir string) error

InstallTools installs the tools from the given directory into $JIRI_ROOT/.jiri_root/bin.

func LoadManifest

func LoadManifest(jirix *jiri.X) (Projects, Tools, error)

LoadManifest loads the manifest, starting with the .jiri_manifest file, resolving remote and local imports. Returns the projects and tools specified by the manifest.

WARNING: LoadManifest cannot be run multiple times in parallel! It invokes git operations which require a lock on the filesystem. If you see errors about ".git/index.lock exists", you are likely calling LoadManifest in parallel.

func LoadSnapshotFile

func LoadSnapshotFile(jirix *jiri.X, file string) (Projects, Tools, error)

LoadSnapshotFile loads the specified snapshot manifest. If the snapshot manifest contains a remote import, an error will be returned.

func TransitionBinDir

func TransitionBinDir(jirix *jiri.X) error

TransitionBinDir handles the transition from the old location $JIRI_ROOT/devtools/bin to the new $JIRI_ROOT/.jiri_root/bin. In InstallTools above we've already installed the tools to the new location.

For now we want $JIRI_ROOT/devtools/bin symlinked to the new location, so that users won't perceive a difference in behavior. In addition, we want to save the old binaries to $JIRI_ROOT/.jiri_root/bin.BACKUP the first time this is run. That way if we screwed something up, the user can recover their old binaries.

TODO(toddw): Remove this logic after the transition to .jiri_root is done.

func UpdateUniverse

func UpdateUniverse(jirix *jiri.X, gc bool) (e error)

UpdateUniverse updates all local projects and tools to match the remote counterparts identified in the manifest. Optionally, the 'gc' flag can be used to indicate that local projects that no longer exist remotely should be removed.

func WriteUpdateHistorySnapshot

func WriteUpdateHistorySnapshot(jirix *jiri.X, snapshotPath string) error

WriteUpdateHistorySnapshot creates a snapshot of the current state of all projects and writes it to the update history directory.

Types

type BranchState

type BranchState struct {
	HasGerritMessage bool
	Name             string
}

type CL

type CL struct {
	// Author identifies the author of the changelist.
	Author string
	// Email identifies the author's email.
	Email string
	// Description holds the description of the changelist.
	Description string
}

CL represents a changelist.

type Import

type Import struct {
	// Manifest file to use from the remote manifest project.
	Manifest string `xml:"manifest,attr,omitempty"`
	// Name is the name of the remote manifest project, used to determine the
	// project key.
	Name string `xml:"name,attr,omitempty"`
	// Protocol is the version control protocol used by the remote manifest
	// project. If not set, "git" is used as the default.
	Protocol string `xml:"protocol,attr,omitempty"`
	// Remote is the remote manifest project to import.
	Remote string `xml:"remote,attr,omitempty"`
	// RemoteBranch is the name of the remote branch to track. It doesn't affect
	// the name of the local branch that jiri maintains, which is always
	// "master". If not set, "master" is used as the default.
	RemoteBranch string `xml:"remotebranch,attr,omitempty"`
	// Root path, prepended to all project paths specified in the manifest file.
	Root    string   `xml:"root,attr,omitempty"`
	XMLName struct{} `xml:"import"`
}

Import represents a remote manifest import.

func (*Import) ProjectKey

func (i *Import) ProjectKey() ProjectKey

ProjectKey returns the unique ProjectKey for the imported project.

type LocalImport

type LocalImport struct {
	// Manifest file to import from.
	File    string   `xml:"file,attr,omitempty"`
	XMLName struct{} `xml:"localimport"`
}

LocalImport represents a local manifest import.

type Manifest

type Manifest struct {
	Imports      []Import      `xml:"imports>import"`
	LocalImports []LocalImport `xml:"imports>localimport"`
	Projects     []Project     `xml:"projects>project"`
	Tools        []Tool        `xml:"tools>tool"`
	// SnapshotPath is the relative path to the snapshot file from JIRI_ROOT.
	// It is only set when creating a snapshot.
	SnapshotPath string   `xml:"snapshotpath,attr,omitempty"`
	XMLName      struct{} `xml:"manifest"`
}

Manifest represents a setting used for updating the universe.

func ManifestFromBytes

func ManifestFromBytes(data []byte) (*Manifest, error)

ManifestFromBytes returns a manifest parsed from data, with defaults filled in.

func ManifestFromFile

func ManifestFromFile(jirix *jiri.X, filename string) (*Manifest, error)

ManifestFromFile returns a manifest parsed from the contents of filename, with defaults filled in.

Note that unlike ProjectFromFile, ManifestFromFile does not convert project paths to absolute paths because it's possible to load a manifest with a specific root directory different from jirix.Root. The usual way to load a manifest is through LoadManifest, which does absolutize the paths, and uses the correct root directory.

func (*Manifest) ToBytes

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

ToBytes returns m as serialized bytes, with defaults unfilled.

func (*Manifest) ToFile

func (m *Manifest) ToFile(jirix *jiri.X, filename string) error

ToFile writes the manifest m to a file with the given filename, with defaults unfilled and all project paths relative to the jiri root.

type Project

type Project struct {
	// Name is the project name.
	Name string `xml:"name,attr,omitempty"`
	// Path is the path used to store the project locally. Project
	// manifest uses paths that are relative to the $JIRI_ROOT
	// environment variable. When a manifest is parsed (e.g. in
	// RemoteProjects), the program logic converts the relative
	// paths to an absolute paths, using the current value of the
	// $JIRI_ROOT environment variable as a prefix.
	Path string `xml:"path,attr,omitempty"`
	// Protocol is the version control protocol used by the
	// project. If not set, "git" is used as the default.
	Protocol string `xml:"protocol,attr,omitempty"`
	// Remote is the project remote.
	Remote string `xml:"remote,attr,omitempty"`
	// RemoteBranch is the name of the remote branch to track.  It doesn't affect
	// the name of the local branch that jiri maintains, which is always "master".
	RemoteBranch string `xml:"remotebranch,attr,omitempty"`
	// Revision is the revision the project should be advanced to during "jiri
	// update".  If Revision is set, RemoteBranch will be ignored.  If Revision
	// is not set, "HEAD" is used as the default.
	Revision string `xml:"revision,attr,omitempty"`
	// GerritHost is the gerrit host where project CLs will be sent.
	GerritHost string `xml:"gerrithost,attr,omitempty"`
	// GitHooks is a directory containing git hooks that will be installed for
	// this project.
	GitHooks string `xml:"githooks,attr,omitempty"`
	// RunHook is a script that will run when the project is created, updated,
	// or moved.  The argument to the script will be "create", "update" or
	// "move" depending on the type of operation being performed.
	RunHook string   `xml:"runhook,attr,omitempty"`
	XMLName struct{} `xml:"project"`
}

Project represents a jiri project.

func ProjectAtPath

func ProjectAtPath(jirix *jiri.X, path string) (Project, error)

ProjectAtPath returns a Project struct corresponding to the project at the path in the filesystem.

func ProjectFromFile

func ProjectFromFile(jirix *jiri.X, filename string) (*Project, error)

ProjectFromFile returns a project parsed from the contents of filename, with defaults filled in and all paths absolute.

func (Project) Key

func (p Project) Key() ProjectKey

Key returns the unique ProjectKey for the project.

func (Project) ToFile

func (p Project) ToFile(jirix *jiri.X, filename string) error

ToFile writes the project p to a file with the given filename, with defaults unfilled and all paths relative to the jiri root.

type ProjectKey

type ProjectKey string

ProjectKey is a unique string for a project.

func CurrentProjectKey

func CurrentProjectKey(jirix *jiri.X) (ProjectKey, error)

CurrentProjectKey gets the key of the current project from the current directory by reading the jiri project metadata located in a directory at the root of the current repository.

func MakeProjectKey

func MakeProjectKey(name, remote string) ProjectKey

MakeProjectKey returns the project key, given the project name and remote.

type ProjectKeys

type ProjectKeys []ProjectKey

ProjectKeys is a slice of ProjectKeys implementing the Sort interface.

func (ProjectKeys) Len

func (pks ProjectKeys) Len() int

func (ProjectKeys) Less

func (pks ProjectKeys) Less(i, j int) bool

func (ProjectKeys) Swap

func (pks ProjectKeys) Swap(i, j int)

type ProjectState

type ProjectState struct {
	Branches       []BranchState
	CurrentBranch  string
	HasUncommitted bool
	HasUntracked   bool
	Project        Project
}

func GetProjectState

func GetProjectState(jirix *jiri.X, key ProjectKey, checkDirty bool) (*ProjectState, error)

type Projects

type Projects map[ProjectKey]Project

Projects maps ProjectKeys to Projects.

func LocalProjects

func LocalProjects(jirix *jiri.X, scanMode ScanMode) (Projects, error)

LocalProjects returns projects on the local filesystem. If all projects in the manifest exist locally and scanMode is set to FastScan, then only the projects in the manifest that exist locally will be returned. Otherwise, a full scan of the filesystem will take place, and all found projects will be returned.

func ParseNames

func ParseNames(jirix *jiri.X, args []string, defaultProjects map[string]struct{}) (Projects, error)

ParseNames identifies the set of projects that a jiri command should be applied to.

func (Projects) Find

func (ps Projects) Find(keyOrName string) Projects

Find returns all projects in Projects with the given key or name.

func (Projects) FindUnique

func (ps Projects) FindUnique(keyOrName string) (Project, error)

FindUnique returns the project in Projects with the given key or name, and returns an error if none or multiple matching projects are found.

type ScanMode

type ScanMode bool

ScanMode determines whether LocalProjects should scan the local filesystem for projects (FullScan), or optimistically assume that the local projects will match those in the manifest (FastScan).

type Tool

type Tool struct {
	// Data is a relative path to a directory for storing tool data
	// (e.g. tool configuration files). The purpose of this field is to
	// decouple the configuration of the data directory from the tool
	// itself so that the location of the data directory can change
	// without the need to change the tool.
	Data string `xml:"data,attr,omitempty"`
	// Name is the name of the tool binary.
	Name string `xml:"name,attr,omitempty"`
	// Package is the package path of the tool.
	Package string `xml:"package,attr,omitempty"`
	// Project identifies the project that contains the tool. If not
	// set, "https://vanadium.googlesource.com/<JiriProject>" is
	// used as the default.
	Project string   `xml:"project,attr,omitempty"`
	XMLName struct{} `xml:"tool"`
}

Tool represents a jiri tool.

type Tools

type Tools map[string]Tool

Tools maps jiri tool names, to their detailed description.

type UnsupportedProtocolErr

type UnsupportedProtocolErr string

func (UnsupportedProtocolErr) Error

func (e UnsupportedProtocolErr) Error() string

type Update

type Update map[string][]CL

Update represents an update of projects as a map from project names to a collections of commits.

func PollProjects

func PollProjects(jirix *jiri.X, projectSet map[string]struct{}) (_ Update, e error)

PollProjects returns the set of changelists that exist remotely but not locally. Changes are grouped by projects and contain author identification and a description of their content.

Jump to

Keyboard shortcuts

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