Documentation ¶
Overview ¶
Package project contains library functions for working with jiri projects.
Index ¶
- Constants
- Variables
- func ApplyToLocalMaster(jirix *jiri.X, projects Projects, fn func() error) (e error)
- func BuildTools(jirix *jiri.X, projects Projects, tools Tools, outputDir string) error
- func CheckoutSnapshot(jirix *jiri.X, snapshot string, gc bool) error
- func CleanupProjects(jirix *jiri.X, projects Projects, cleanupBranches bool) (e error)
- func CreateSnapshot(jirix *jiri.X, file, snapshotPath string) error
- func GetProjectStates(jirix *jiri.X, checkDirty bool) (map[ProjectKey]*ProjectState, error)
- func InstallTools(jirix *jiri.X, dir string) error
- func LoadManifest(jirix *jiri.X) (Projects, Tools, error)
- func LoadSnapshotFile(jirix *jiri.X, file string) (Projects, Tools, error)
- func TransitionBinDir(jirix *jiri.X) error
- func UpdateUniverse(jirix *jiri.X, gc bool) (e error)
- func WriteUpdateHistorySnapshot(jirix *jiri.X, snapshotPath string) error
- type BranchState
- type CL
- type Import
- type LocalImport
- type Manifest
- type Project
- type ProjectKey
- type ProjectKeys
- type ProjectState
- type Projects
- type ScanMode
- type Tool
- type Tools
- type UnsupportedProtocolErr
- type Update
Constants ¶
const ( FastScan = ScanMode(false) FullScan = ScanMode(true) )
Variables ¶
var JiriName = "jiri"
var JiriPackage = "v.io/jiri"
var JiriProject = "release.go.jiri"
Functions ¶
func ApplyToLocalMaster ¶
ApplyToLocalMaster applies an operation expressed as the given function to the local master branch of the given projects.
func BuildTools ¶
BuildTools builds the given tools and places the resulting binaries into the given directory.
func CheckoutSnapshot ¶
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 ¶
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 ¶
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 ¶
InstallTools installs the tools from the given directory into $JIRI_ROOT/.jiri_root/bin.
func LoadManifest ¶
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 ¶
LoadSnapshotFile loads the specified snapshot manifest. If the snapshot manifest contains a remote import, an error will be returned.
func TransitionBinDir ¶
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 ¶
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.
Types ¶
type BranchState ¶
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 ¶
ManifestFromBytes returns a manifest parsed from data, with defaults filled in.
func ManifestFromFile ¶
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.
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 ¶
ProjectAtPath returns a Project struct corresponding to the project at the path in the filesystem.
func ProjectFromFile ¶
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.
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 ¶
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.
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 UnsupportedProtocolErr ¶
type UnsupportedProtocolErr string
func (UnsupportedProtocolErr) Error ¶
func (e UnsupportedProtocolErr) Error() string