Documentation ¶
Overview ¶
Package vcs provides a more complete version control system (ex: git) interface, building on https://github.com/Masterminds/vcs.
Index ¶
- type Commit
- type FileStatus
- func (i FileStatus) Desc() string
- func (i FileStatus) Int64() int64
- func (i FileStatus) MarshalText() ([]byte, error)
- func (i *FileStatus) SetInt64(in int64)
- func (i *FileStatus) SetString(s string) error
- func (i FileStatus) String() string
- func (i *FileStatus) UnmarshalText(text []byte) error
- func (i FileStatus) Values() []enums.Enum
- type Files
- type GitRepo
- func (gr *GitRepo) Add(fname string) error
- func (gr *GitRepo) Blame(fname string) ([]byte, error)
- func (gr *GitRepo) CommitDesc(rev string, diffs bool) ([]byte, error)
- 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) FilesChanged(revA, revB string, diffs bool) ([]byte, 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)
- func (gr *GitRepo) Type() Types
- func (s *GitRepo) UpdateVersion(version string) error
- 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) CommitDesc(rev string, diffs bool) ([]byte, error)
- 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) FilesChanged(revA, revB string, diffs bool) ([]byte, 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)
- func (gr *SvnRepo) Type() Types
- type Types
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct { // revision number / hash code / unique id Rev string // date (author's time) when committed Date string // author's name Author string // author's email Email string // message / subject line for commit Message string `width:"100"` }
Commit is one VCS commit entry, as returned in a Log.
type FileStatus ¶
type FileStatus int32 //enums:enum
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 )
const FileStatusN FileStatus = 7
FileStatusN is the highest valid value for type FileStatus, plus one.
func FileStatusValues ¶
func FileStatusValues() []FileStatus
FileStatusValues returns all possible values for the type FileStatus.
func (FileStatus) Desc ¶
func (i FileStatus) Desc() string
Desc returns the description of the FileStatus value.
func (FileStatus) Int64 ¶
func (i FileStatus) Int64() int64
Int64 returns the FileStatus value as an int64.
func (FileStatus) MarshalText ¶
func (i FileStatus) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*FileStatus) SetInt64 ¶
func (i *FileStatus) SetInt64(in int64)
SetInt64 sets the FileStatus value from an int64.
func (*FileStatus) SetString ¶
func (i *FileStatus) SetString(s string) error
SetString sets the FileStatus value from its string representation, and returns an error if the string is invalid.
func (FileStatus) String ¶
func (i FileStatus) String() string
String returns the string representation of this FileStatus value.
func (*FileStatus) UnmarshalText ¶
func (i *FileStatus) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (FileStatus) Values ¶
func (i FileStatus) Values() []enums.Enum
Values returns all possible values for the type FileStatus.
type Files ¶
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 ¶
Blame returns an annotated report about the file, showing which revision last modified each line.
func (*GitRepo) CommitDesc ¶
CommitDesc returns the full textual description of the given commit, if rev is empty, defaults to current HEAD, -1, -2 etc also work as universal ways of specifying prior revisions. Optionally includes diffs for the changes (otherwise just a list of files with modification status).
func (*GitRepo) CommitFile ¶
CommitFile commits single file to repo staging
func (*GitRepo) Delete ¶
Delete removes the file from the repo; uses "force" option to ensure deletion
func (*GitRepo) DeleteRemote ¶
Delete removes the file from the repo
func (*GitRepo) FileContents ¶
FileContents returns the contents of given file, as a []byte array at given revision specifier. -1, -2 etc also work as universal ways of specifying prior revisions.
func (*GitRepo) FilesChanged ¶ added in v0.2.0
FilesChanged returns the list of files changed and their statuses, between two revisions. If revA is empty, defaults to current HEAD; revB defaults to HEAD-1. -1, -2 etc also work as universal ways of specifying prior revisions. Optionally includes diffs for the changes.
func (*GitRepo) Log ¶
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
func (*GitRepo) Status ¶
func (gr *GitRepo) Status(fname string) (FileStatus, string)
Status returns status of given file; returns Untracked on any error
func (*GitRepo) UpdateVersion ¶ added in v0.3.4
UpdateVersion sets the version of a package currently checked out via Git.
type Repo ¶
type Repo interface { vcs.Repo // Type returns the type of repo we are using Type() Types // 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. SVN only understands a // number as a maximum number of items to return. Log(fname string, since string) (Log, error) // CommitDesc returns the full textual description of the given commit, // if rev is empty, defaults to current HEAD, -1, -2 etc also work as universal // ways of specifying prior revisions. // Optionally includes diffs for the changes (otherwise just a list of files // with modification status). CommitDesc(rev string, diffs bool) ([]byte, error) // FilesChanged returns the list of files changed and their statuses, // between two revisions. // If revA is empty, defaults to current HEAD; revB defaults to HEAD-1. // -1, -2 etc also work as universal ways of specifying prior revisions. // Optionally includes diffs for the changes. FilesChanged(revA, revB string, diffs bool) ([]byte, 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 ¶
func (*SvnRepo) Blame ¶
Blame returns an annotated report about the file, showing which revision last modified each line.
func (*SvnRepo) CharToStat ¶
func (gr *SvnRepo) CharToStat(stat byte) FileStatus
func (*SvnRepo) CommitDesc ¶
CommitDesc returns the full textual description of the given commit, if rev is empty, defaults to current HEAD, -1, -2 etc also work as universal ways of specifying prior revisions. Optionally includes diffs for the changes (otherwise just a list of files with modification status).
func (*SvnRepo) CommitFile ¶
CommitFile commits single file to repo staging
func (*SvnRepo) Delete ¶
Delete removes the file from the repo -- uses "force" option to ensure deletion
func (*SvnRepo) DeleteRemote ¶
DeleteRemote removes the file from the repo, but keeps local copy
func (*SvnRepo) FileContents ¶
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) FilesChanged ¶ added in v0.2.0
func (*SvnRepo) Log ¶
Log returns the log history of commits for given filename (or all files if empty). If since is non-empty, it is the maximum number of entries to return (a number).
func (*SvnRepo) RevertFile ¶
RevertFile reverts a single file to last commit of master
type Types ¶ added in v0.3.2
type Types int32 //enums:enum -accept-lower
const TypesN Types = 5
TypesN is the highest valid value for type Types, plus one.
func DetectRepo ¶
DetectRepo attempts to detect the presence of a repository at the given directory path -- returns type of repository if found, else 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 rep.o
func TypesValues ¶ added in v0.3.2
func TypesValues() []Types
TypesValues returns all possible values for the type Types.
func (Types) MarshalText ¶ added in v0.3.2
MarshalText implements the encoding.TextMarshaler interface.
func (*Types) SetString ¶ added in v0.3.2
SetString sets the Types value from its string representation, and returns an error if the string is invalid.
func (*Types) UnmarshalText ¶ added in v0.3.2
UnmarshalText implements the encoding.TextUnmarshaler interface.