vcs

package
v0.0.0-...-9c39a02 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Version Control for Go

This package will utimately support creation, manipulation, introspection, and deletion of mercurial repositories using mercurial command server. Right now this package runs shell commands.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src string, dst string) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

Types

type GitVCS

type GitVCS struct {
	Path string
}

GitVCS represents a local Git repo.

func (*GitVCS) CloneTo

func (g *GitVCS) CloneTo(ctx context.Context, target string) error

CloneTo - makes a local clone of repo into given target

func (*GitVCS) Commit

func (g *GitVCS) Commit(ctx context.Context, message string) error

Commit everything to a repository

func (*GitVCS) GetFile

func (g *GitVCS) GetFile(ctx context.Context, rev string, pathFromRoot string) (*[]byte, error)

GetFile - Gets a single file with a given revision from the repo.

func (*GitVCS) Init

func (g *GitVCS) Init(ctx context.Context) error

Init - initializes the version control repository. Git Path must exist.

func (*GitVCS) InitRepo

func (g *GitVCS) InitRepo(ctx context.Context) error

InitRepo - Inits the version control repository and commits all files found. Git Path must exist.

func (GitVCS) NewRepo

func (g GitVCS) NewRepo(dirpath string) VCS

NewRepo creates a new GitVCS repository object.

func (*GitVCS) ReplaceFiles

func (g *GitVCS) ReplaceFiles(ctx context.Context, folder, owner string) error

ReplaceFiles - replaces all files from repo HEAD with the files from the given folder. owner is an optional argument used to set the git commit user. If empty, then the default git user will be used.

func (*GitVCS) RevisionCount

func (g *GitVCS) RevisionCount(ctx context.Context, rev string) (int, error)

RevisionCount - get the number of revisions up to a specific revision If revision is empty, last commit from "master" branch will be used. Returns the number of revisions.

func (*GitVCS) Tag

func (g *GitVCS) Tag(ctx context.Context, tag string) error

Tag the current repository.

func (*GitVCS) Walk

func (g *GitVCS) Walk(ctx context.Context, rev string, includeFolders bool, fn WalkFn) error

Walk - given a revision, Walk func iterates over the repository and invokes the WalkFn on each leaf file. If includeFolders argument is true then WalkFn will be invoked with folder nodes too. The function returns error if any WalkFn invocation ended with error. Revision argument can be an empty string; in that case "master" will be used.

func (*GitVCS) Zip

func (g *GitVCS) Zip(ctx context.Context, rev, output string) (*string, error)

Zip - creates a zip with the repository files, at a given revision. If revision is empty or "tip", last commit from "master" branch will be used. If output is empty, then a zip file in the tmp folder will be created. Returns a string path pointing to the created zip file.

type GoGitVCS

type GoGitVCS struct {
	Path string
	// contains filtered or unexported fields
}

GoGitVCS represents a local Git repo.

func (*GoGitVCS) CloneTo

func (g *GoGitVCS) CloneTo(ctx context.Context, target string) error

CloneTo - makes a local clone of repo into given target.

func (*GoGitVCS) GetFile

func (g *GoGitVCS) GetFile(ctx context.Context, rev string, pathFromRoot string) (*[]byte, error)

GetFile - Gets a single file with a given revision from the repo.

func (*GoGitVCS) HasTag

func (g *GoGitVCS) HasTag(tag string) (bool, error)

HasTag - Checks for the existence of the given tag. Return bool, and an error if something unexpected happened.

func (*GoGitVCS) InitRepo

func (g *GoGitVCS) InitRepo(ctx context.Context) error

InitRepo - Inits the version control repository and commits all files found. Git Path must exist.

func (GoGitVCS) NewRepo

func (g GoGitVCS) NewRepo(dirpath string) VCS

NewRepo creates a new GoGitVCS repository object.

func (*GoGitVCS) ReplaceFiles

func (g *GoGitVCS) ReplaceFiles(ctx context.Context, folder, owner string) error

ReplaceFiles - replaces all files from repo HEAD with the files from the given folder. owner is an optional argument used to set the git commit user. If empty, then the default git user will be used.

func (*GoGitVCS) RevisionCount

func (g *GoGitVCS) RevisionCount(ctx context.Context, rev string) (int, error)

RevisionCount - get the number of revisions up to a specific revision If revision is empty, last commit from "master" branch will be used. Returns the number of revisions.

func (*GoGitVCS) Tag

func (g *GoGitVCS) Tag(ctx context.Context, tag string) error

Tag the current repository.

func (*GoGitVCS) Walk

func (g *GoGitVCS) Walk(ctx context.Context, rev string, includeFolders bool, fn WalkFn) error

Walk - given a revision, Walk func iterates over the repository and invokes the WalkFn on each leaf file. If includeFolders argument is true then WalkFn will be invoked with folder nodes too. The function returns error if any WalkFn invocation ended with error. Revision argument can be an empty string; in that case the master branch will be used.

func (*GoGitVCS) Zip

func (g *GoGitVCS) Zip(ctx context.Context, rev, output string) (*string, error)

Zip - creates a zip with the repository files, at a given revision. If revision is empty or "tip" , last commit from "master" branch will be used. If output is empty, then a zip file in the tmp folder will be created. Returns a string path pointing to the created zip file.

type VCS

type VCS interface {
	CloneTo(ctx context.Context, target string) error
	GetFile(ctx context.Context, rev string, pathFromRoot string) (*[]byte, error)
	InitRepo(ctx context.Context) error
	ReplaceFiles(ctx context.Context, folder, owner string) error
	RevisionCount(ctx context.Context, rev string) (int, error)
	Tag(ctx context.Context, tag string) error
	Walk(ctx context.Context, rev string, includeFolders bool, fn WalkFn) error
	Zip(ctx context.Context, rev, output string) (*string, error)
}

VCS - Version Control System basic interface.

type WalkFn

type WalkFn func(path, parent string, isDir bool) error

WalkFn allows to process a repository file entry when using the Walk func. WalkFn receives a file and its folder parent paths. isDir argument is true when the given path is a folder.

Jump to

Keyboard shortcuts

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