Documentation
¶
Overview ¶
Package vci provides a version control interface for version control systems such as git, svn, etc. It extends vcs.Repo (https://github.com/Masterminds/vcs) with support for processing individual files within the repository.
Index ¶
- Variables
- func DetectRepo(path string) vcs.Type
- func FieldsThroughDelim(flds [][]byte, delim byte, idx int) (int, string)
- func RelPath(repo Repo, path string) string
- type Commit
- type FileStatus
- type Files
- type GitRepo
- func (gr *GitRepo) Add(fname string) error
- func (gr *GitRepo) Blame(fname string) ([]byte, error)
- func (gr *GitRepo) CharToStat(stat byte) FileStatus
- func (gr *GitRepo) CommitFile(fname string, message string) error
- func (gr *GitRepo) Delete(fname string) error
- func (gr *GitRepo) DeleteRemote(fname string) error
- func (gr *GitRepo) FileContents(fname string, rev string) ([]byte, error)
- func (gr *GitRepo) Files() (Files, error)
- func (gr *GitRepo) Log(fname string, since string) (Log, error)
- func (gr *GitRepo) Move(oldpath, newpath string) error
- func (gr *GitRepo) RevertFile(fname string) error
- func (gr *GitRepo) Status(fname string) (FileStatus, string)
- type Log
- type Repo
- type SvnRepo
- func (gr *SvnRepo) Add(fname string) error
- func (gr *SvnRepo) Blame(fname string) ([]byte, error)
- func (gr *SvnRepo) CharToStat(stat byte) FileStatus
- func (gr *SvnRepo) CommitFile(fname string, message string) error
- func (gr *SvnRepo) Delete(fname string) error
- func (gr *SvnRepo) DeleteRemote(fname string) error
- func (gr *SvnRepo) FileContents(fname string, rev string) ([]byte, error)
- func (gr *SvnRepo) Files() (Files, error)
- func (gr *SvnRepo) Log(fname string, since string) (Log, error)
- func (gr *SvnRepo) Move(oldpath, newpath string) error
- func (gr *SvnRepo) RevertFile(fname string) error
- func (gr *SvnRepo) Status(fname string) (FileStatus, string)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownVCS is returned when VCS cannot be determined from the vcs Repo ErrUnknownVCS = errors.New("Unknown VCS") )
var KiT_FileStatus = kit.Enums.AddEnum(FileStatusN, kit.NotBitFlag, nil)
Functions ¶
func DetectRepo ¶ added in v0.9.11
DetectRepo attemps to detect the presence of a repository at the given directory path -- returns type of repository if found, else vcs.NoVCS. Very quickly just looks for signature file name: .git for git .svn for svn -- but note that this will find any subdir in svn repo
func FieldsThroughDelim ¶ added in v0.9.11
FieldsThroughDelim gets the concatenated byte through to point where field ends with given delimiter, starting at given index
Types ¶
type Commit ¶ added in v0.9.11
type Commit struct {
Rev string `desc:"revision number / hash code / unique id"`
Date string `desc:"date (author's time) when comitted"`
Author string `desc:"author's name"`
Email string `desc:"author's email"`
Message string `desc:"message / subject line for commit"`
}
Commit is one VCS commit entry, as returned in a Log
type FileStatus ¶ added in v0.9.11
type FileStatus int32
FileStatus indicates the status of files in the repository
const ( // Untracked means file is not under VCS control Untracked FileStatus = iota // Stored means file is stored under VCS control, and has not been modified in working copy Stored // Modified means file is under VCS control, and has been modified in working copy Modified // Added means file has just been added to VCS but is not yet committed Added // Deleted means file has been deleted from VCS Deleted // Conflicted means file is in conflict -- has not been merged Conflicted // Updated means file has been updated in the remote but not locally Updated FileStatusN )
func (*FileStatus) FromString ¶ added in v0.9.11
func (i *FileStatus) FromString(s string) error
func (FileStatus) MarshalJSON ¶ added in v0.9.11
func (ev FileStatus) MarshalJSON() ([]byte, error)
func (FileStatus) String ¶ added in v0.9.11
func (i FileStatus) String() string
func (*FileStatus) UnmarshalJSON ¶ added in v0.9.11
func (ev *FileStatus) UnmarshalJSON(b []byte) error
type Files ¶ added in v0.9.11
type Files map[string]FileStatus
Files is a map used for storing files in a repository along with their status
type GitRepo ¶
func (*GitRepo) Blame ¶ added in v0.9.11
Blame returns an annotated report about the file, showing which revision last modified each line.
func (*GitRepo) CharToStat ¶ added in v0.9.11
func (gr *GitRepo) CharToStat(stat byte) FileStatus
func (*GitRepo) CommitFile ¶
CommitFile commits single file to repo staging
func (*GitRepo) Delete ¶ added in v0.9.11
Delete removes the file from the repo -- uses "force" option to ensure deletion
func (*GitRepo) DeleteRemote ¶ added in v0.9.11
Delete removes the file from the repo
func (*GitRepo) FileContents ¶ added in v0.9.11
FileContents returns the contents of given file, as a []byte array at given revision specifier (if empty, defaults to current HEAD). -1, -2 etc also work as universal ways of specifying prior revisions.
func (*GitRepo) Log ¶ added in v0.9.11
Log returns the log history of commits for given filename (or all files if empty). If since is non-empty, it should be a date-like expression that the VCS will understand, such as 1/1/2020, yesterday, last year, etc
func (*GitRepo) RevertFile ¶
RevertFile reverts a single file to last commit of master
type Repo ¶
type Repo interface {
// vcs.Repo includes those interface functions
vcs.Repo
// Files returns a map of the current files and their status.
Files() (Files, error)
// Status returns status of given file -- returns Untracked and error
// message on any error. FileStatus is a summary status category,
// and string return value is more detailed status information formatted
// according to standard conventions of given VCS.
Status(fname string) (FileStatus, string)
// Add adds the file to the repo
Add(fname string) error
// Move moves the file using VCS command to keep it updated
Move(oldpath, newpath string) error
// Delete removes the file from the repo and working copy.
// Uses "force" option to ensure deletion.
Delete(fname string) error
// DeleteRemote removes the file from the repo but keeps the local file itself
DeleteRemote(fname string) error
// CommitFile commits a single file
CommitFile(fname string, message string) error
// RevertFile reverts a single file to the version that it was last in VCS,
// losing any local changes (destructive!)
RevertFile(fname string) error
// FileContents returns the contents of given file, as a []byte array
// at given revision specifier (if empty, defaults to current HEAD).
// -1, -2 etc also work as universal ways of specifying prior revisions.
FileContents(fname string, rev string) ([]byte, error)
// Log returns the log history of commits for given filename
// (or all files if empty). If since is non-empty, it should be
// a date-like expression that the VCS will understand, such as
// 1/1/2020, yesterday, last year, etc
Log(fname string, since string) (Log, error)
// Blame returns an annotated report about the file, showing which revision last
// modified each line.
Blame(fname string) ([]byte, error)
}
Repo provides an interface extending vcs.Repo (https://github.com/Masterminds/vcs) with support for file status information and operations.
type SvnRepo ¶ added in v0.9.7
func (*SvnRepo) Blame ¶ added in v0.9.11
Blame returns an annotated report about the file, showing which revision last modified each line.
func (*SvnRepo) CharToStat ¶ added in v0.9.11
func (gr *SvnRepo) CharToStat(stat byte) FileStatus
func (*SvnRepo) CommitFile ¶ added in v0.9.7
CommitFile commits single file to repo staging
func (*SvnRepo) Delete ¶ added in v0.9.11
Delete removes the file from the repo -- uses "force" option to ensure deletion
func (*SvnRepo) DeleteRemote ¶ added in v0.9.11
DeleteRemote removes the file from the repo, but keeps local copy
func (*SvnRepo) FileContents ¶ added in v0.9.11
FileContents returns the contents of given file, as a []byte array at given revision specifier (if empty, defaults to current HEAD). -1, -2 etc also work as universal ways of specifying prior revisions.
func (*SvnRepo) Log ¶ added in v0.9.11
Log returns the log history of commits for given filename (or all files if empty). If since is non-empty, it should be a date-like expression that the VCS will understand, such as 1/1/2020, yesterday, last year, etc
func (*SvnRepo) RevertFile ¶ added in v0.9.7
RevertFile reverts a single file to last commit of master