bulk

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cmd *cobra.Command)

Init the bulk commands given a parent command.

Types

type File

type File struct {
	// Path is the relative path to the local file
	Path string `json:"path"`
	// URL to the remote file
	URL string `json:"url"`

	// ETag header used for conditional updates
	ETag string `json:"etag,omitempty"`
	// LastModified header used for conditional updates
	LastModified string `json:"last_modified,omitempty"`

	// VersionRemote used to compare when listing
	VersionRemote string `json:"version_remote,omitempty"`
	// VersionLocal tracks the local copy of the file
	VersionLocal string `json:"version_local,omitempty"`

	// Schema is used to describe the type of the resource, if available.
	Schema string `json:"schema,omitempty"`

	// Hash is used for detecting local changes
	Hash []byte `json:"hash,omitempty"`
}

File represents a checked out file with metadata about the remote and local version(s) of the file.

func (*File) Fetch

func (f *File) Fetch() ([]byte, error)

Fetch pulls the remote file and updates the metadata.

func (*File) GetData

func (f *File) GetData() ([]byte, error)

GetData returns the file contents.

func (*File) IsChangedLocal

func (f *File) IsChangedLocal(ignoreDeleted bool) bool

IsChangedLocal returns whether a file has been modified locally. The `ignoreDeleted` parameter sets whether deleted files are considered to be changed or not.

func (*File) IsChangedRemote

func (f *File) IsChangedRemote() bool

IsChangedRemote returns whether the local and remote versions mismatch.

func (*File) Reset

func (f *File) Reset() error

Reset overwrites the local file with the remote contents.

func (*File) Write

func (f *File) Write(b []byte) error

Write writes the file to disk. This also updates the local file hash used to determine if the file has been modified.

func (*File) WriteCached

func (f *File) WriteCached(b []byte) error

WriteCached writes the file to disk in the special cache directory.

type Meta

type Meta struct {
	URL         string           `json:"url"`
	Filter      string           `json:"filter,omitempty"`
	Base        string           `json:"base,omitempty"`
	Schema      string           `json:"schema,omitempty"`
	URLTemplate string           `json:"url_template,omitempty"`
	Files       map[string]*File `json:"files,omitempty"`
}

Meta represents metadata about the remote and local status of the checkout.

func (*Meta) GetChanged

func (m *Meta) GetChanged(files []string) ([]changedFile, []changedFile, error)

GetChanged calculates all the changed local and remote files using the following rules after refreshing the index: Remote: - Added: No local version or file - Changed: Local version != remote version - Removed: No remote version Local: - Added: Local file with no metadata entry - Changed: Local file hash != remote file hash - Removed: Metadata entry without local file

func (*Meta) Init

func (m *Meta) Init(url, template string) error

Init initializes the metadata file, saves it to disk, and then performs the initial pull to fetch each file.

func (*Meta) Pull

func (m *Meta) Pull() error

Pull files from the remote. In the case of local changes this will update the index but *not* overwrite the local file containing the edits. When the pull completes, the metadata file is saved.

func (*Meta) PullIndex

func (m *Meta) PullIndex() error

PullIndex updates the index of remote files and their versions. It does not save the metadata file.

func (*Meta) Push

func (m *Meta) Push() error

Push uploads changed files to the server, using conditional updates when possible.

func (*Meta) Save

func (m *Meta) Save() error

Save the metadata file to disk.

Jump to

Keyboard shortcuts

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