package vcs

import "cuelang.org/go/internal/vcs"

Package vcs provides access to operations on the version control systems supported by the source field in module.cue.

Index

Types

type Status

type Status struct {
	Revision    string    // Optional.
	CommitTime  time.Time // Optional.
	Uncommitted bool      // Required.
}

Status is the current state of a local repository.

type VCS

type VCS interface {
	// Root returns the root of the directory controlled by
	// the VCS (e.g. the directory containing .git).
	Root() string

	// ListFiles returns a list of files tracked by VCS, rooted at dir. The
	// optional paths determine what should be listed. If no paths are provided,
	// then all of the files under VCS control under dir are returned. An empty
	// dir is interpretted as [VCS.Root]. A non-empty relative dir is
	// interpretted relative to [VCS.Root]. It us up to the caller to ensure
	// that dir and paths are contained by the VCS root Filepaths are relative
	// to dir and returned in lexical order.
	//
	// Note that ListFiles is generally silent in the case an arg is provided
	// that does correspond to a VCS-controlled file. For example, calling
	// with an arg of "BANANA" where no such file is controlled by VCS will
	// result in no filepaths being returned.
	ListFiles(ctx context.Context, dir string, paths ...string) ([]string, error)

	// Status returns the current state of the repository holding the given paths.
	// If paths is not provided it implies the state of
	// the VCS repository in its entirety, including untracked files. paths are
	// interpretted relative to the [VCS.Root].
	Status(ctx context.Context, paths ...string) (Status, error)
}

VCS provides the operations on a particular instance of a VCS.

func New

func New(vcsType string, dir string) (VCS, error)

New returns a new VCS value representing the version control system of the given type that controls the given directory dir.

It returns an error if a VCS of the specified type cannot be found.

Source Files

git.go vcs.go

Version
v0.9.2
Published
Jun 26, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
8 minutes ago

Tools for package owners.