gotwc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package gotwc implements working copies of Got repositories

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditConfig

func EditConfig(wcRoot *os.Root, fn func(x Config) Config) error

func Init

func Init(repo *gotrepo.Repo, wcRoot *os.Root, cfg Config) error

Init initializes a new working copy in wcdir The working copy will be associated with the given repo. cfg.RepoDir will be overriden with repo.Dir().

func SaveConfig

func SaveConfig(wcRoot *os.Root, cfg Config) error

Types

type CommitParams

type CommitParams struct {
	// Message is the commit message, it is taken from this value as is.
	Message string
	// Authors is the list of authors of the commit
	// if not-nil, it is taken from this value as is.
	// If nil, then the Author will be the same as the committer.
	Authors []inet256.ID
	// AuthoredAt is the time at which the commit was authored, it is taken from this value as is.
	AuthoredAt tai64.TAI64

	// CommittedAt, if not zero, overrides the commit time
	// If CommittedAt is not zero and not >= that of all the parents,
	// then an error is returned.
	CommittedAt tai64.TAI64
	// Committer if not zero, overrides the ID of the committer
	Committer inet256.ID
}

type Config

type Config struct {
	ID      gotrepo.WorkingCopyID `json:"id"`
	Head    string                `json:"head"`
	ActAs   string                `json:"act_as"`
	RepoDir string                `json:"repo"`
	// Tracking is a list of tracked prefixes
	Tracking []string `json:"tracking"`
}

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig(wcRoot *os.Root) (*Config, error)

type ErrWouldClobber

type ErrWouldClobber = porting.ErrWouldClobber

type FileOperation

type FileOperation struct {
	Delete *staging.DeleteOp

	Create *staging.PutOp
	Modify *staging.PutOp
}

type Span

type Span = porting.Span

func PrefixSpan

func PrefixSpan(prefix string) Span

type WC

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

WC is a Working Copy A WC is a directory in the local filesystem, which has a .got/wc.db file WC are associated with a single repository each.

func New

func New(repo *gotrepo.Repo, root *os.Root) (*WC, error)

New creates a new working copy using root and the Repo

func Open

func Open(root *os.Root) (*WC, error)

Open opens a directory as a WorkingCopy `wcdir` is a directory containing a .got/wc-config file

func (*WC) Add

func (wc *WC) Add(ctx context.Context, paths ...string) error

Add adds paths from the working directory to the staging area. Directories are traversed, and only paths are added. Adding a directory will update any existing paths and add new ones, it will not remove paths from version control

func (*WC) Checkout

func (wc *WC) Checkout(ctx context.Context, name string) error

Checkout sets HEAD, and then performs an Export of all tracked spans.

func (*WC) Cleanup

func (wc *WC) Cleanup(ctx context.Context) error

Cleanup removes unreferenced data from the stage.

func (*WC) Clear

func (wc *WC) Clear(ctx context.Context) error

Clear clears all entries from the staging area

func (*WC) Clobber

func (wc *WC) Clobber(ctx context.Context, p string) error

func (*WC) Close

func (wc *WC) Close() error

func (*WC) Commit

func (wc *WC) Commit(ctx context.Context, params CommitParams) error

func (*WC) Dir

func (wc *WC) Dir() string

func (*WC) Discard

func (wc *WC) Discard(ctx context.Context, paths ...string) error

Discard removes any staged changes for a path

func (*WC) DoWithStore

func (wc *WC) DoWithStore(ctx context.Context, fn func(dst stores.RW) error) error

DoWithStore runs fn with a store for the desired branch

func (*WC) Export

func (wc *WC) Export(ctx context.Context) error

Export overwrites data in the filesystem with data from the Snapshot at HEAD. Only tracked paths are overwritten.

func (*WC) ForEachDirty

func (wc *WC) ForEachDirty(ctx context.Context, fn func(p string, modtime time.Time) error) error

ForEachDirty lists all the files which are not in either:

  1. the staging area
  2. the active branch head

func (*WC) ForEachStaging

func (wc *WC) ForEachStaging(ctx context.Context, fn func(p string, op FileOperation) error) error

func (*WC) Fork

func (wc *WC) Fork(ctx context.Context, next string) error

Fork calls CloneMark on the repo with the current head, creating a new mark `next`. Then the WC's head is set to next.

func (*WC) GetActAs

func (wc *WC) GetActAs() (string, error)

func (*WC) GetHead

func (wc *WC) GetHead() (string, error)

func (*WC) ListSpans

func (wc *WC) ListSpans(ctx context.Context) ([]Span, error)

ListSpans returns the tracked spans

func (*WC) Put

func (wc *WC) Put(ctx context.Context, paths ...string) error

Put replaces a path (file or directory) with whatever is in the working directory Adding a file updates the file. Adding a directory will delete paths not in the working directory, and add paths in the working directory.

func (*WC) Repo

func (wc *WC) Repo() *gotrepo.Repo

func (*WC) Rm

func (wc *WC) Rm(ctx context.Context, paths ...string) error

Rm deletes a path known to version control.

func (*WC) SetActAs

func (wc *WC) SetActAs(idenName string) error

func (*WC) SetHead

func (wc *WC) SetHead(ctx context.Context, name string) error

SetHead sets HEAD to name SetHead will check if the staging area is not empty, and if it's not the it will check that the desired branch has the same content parameters as the current branch. If one branch is a fork of another, or they have a common ancestor somewhere, the it is very likely that they have the same content parameters.

func (*WC) StageIsEmpty

func (wc *WC) StageIsEmpty(ctx context.Context) (bool, error)

StageIsEmpty returns (true, nil) IFF there are no changes staged.

func (*WC) Track

func (wc *WC) Track(ctx context.Context, span Span) error

Track causes the working copy to include another range of files.

func (*WC) Untrack

func (wc *WC) Untrack(ctx context.Context, span Span) error

Untrack causes the working copy to exclude a range of files.

Directories

Path Synopsis
internal
porting
package porting deals with importing and exporting to and from gotfs
package porting deals with importing and exporting to and from gotfs

Jump to

Keyboard shortcuts

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