Documentation ¶
Overview ¶
Package repository contains helper methods for working with the Git repo.
Package repository contains helper methods for working with a Git repo.
Index ¶
- Variables
- func NewMockRepoForTest() *mockRepoForTest
- type ClockedRepo
- type GitRepo
- func (repo *GitRepo) AddRemote(name string, url string) error
- func (repo *GitRepo) CopyRef(source string, dest string) error
- func (repo *GitRepo) CreateTimeIncrement() (lamport.Time, error)
- func (repo *GitRepo) CreateWitness(time lamport.Time) error
- func (repo *GitRepo) EditTimeIncrement() (lamport.Time, error)
- func (repo *GitRepo) EditWitness(time lamport.Time) error
- func (repo *GitRepo) FetchRefs(remote, refSpec string) (string, error)
- func (repo *GitRepo) FindCommonAncestor(hash1 git.Hash, hash2 git.Hash) (git.Hash, error)
- func (repo *GitRepo) GetCoreEditor() (string, error)
- func (repo *GitRepo) GetPath() string
- func (repo *GitRepo) GetTreeHash(commit git.Hash) (git.Hash, error)
- func (repo *GitRepo) GetUserEmail() (string, error)
- func (repo *GitRepo) GetUserName() (string, error)
- func (repo *GitRepo) ListCommits(ref string) ([]git.Hash, error)
- func (repo *GitRepo) ListEntries(hash git.Hash) ([]TreeEntry, error)
- func (repo *GitRepo) ListRefs(refspec string) ([]string, error)
- func (repo *GitRepo) LoadClocks() error
- func (repo *GitRepo) PushRefs(remote string, refSpec string) (string, error)
- func (repo *GitRepo) ReadConfigs(keyPrefix string) (map[string]string, error)
- func (repo *GitRepo) ReadData(hash git.Hash) ([]byte, error)
- func (repo *GitRepo) RefExist(ref string) (bool, error)
- func (repo *GitRepo) RmConfigs(keyPrefix string) error
- func (repo *GitRepo) StoreCommit(treeHash git.Hash) (git.Hash, error)
- func (repo *GitRepo) StoreCommitWithParent(treeHash git.Hash, parent git.Hash) (git.Hash, error)
- func (repo *GitRepo) StoreConfig(key string, value string) error
- func (repo *GitRepo) StoreData(data []byte) (git.Hash, error)
- func (repo *GitRepo) StoreTree(entries []TreeEntry) (git.Hash, error)
- func (repo *GitRepo) UpdateRef(ref string, hash git.Hash) error
- func (repo *GitRepo) WriteClocks() error
- type ObjectType
- type Repo
- type RepoCommon
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
var ErrNotARepo = errors.New("not a git repository")
ErrNotARepo is the error returned when the git repo root wan't be found
Functions ¶
func NewMockRepoForTest ¶
func NewMockRepoForTest() *mockRepoForTest
Types ¶
type ClockedRepo ¶
type ClockedRepo interface { Repo // LoadClocks read the clocks values from the on-disk repo LoadClocks() error // WriteClocks write the clocks values into the repo WriteClocks() error // CreateTimeIncrement increment the creation clock and return the new value. CreateTimeIncrement() (lamport.Time, error) // EditTimeIncrement increment the edit clock and return the new value. EditTimeIncrement() (lamport.Time, error) // CreateWitness witness another create time and increment the corresponding // clock if needed. CreateWitness(time lamport.Time) error // EditWitness witness another edition time and increment the corresponding // clock if needed. EditWitness(time lamport.Time) error }
type GitRepo ¶
type GitRepo struct { Path string // contains filtered or unexported fields }
GitRepo represents an instance of a (local) git repository.
func InitBareGitRepo ¶
InitBareGitRepo create a new --bare empty git repo at the given path
func InitGitRepo ¶
InitGitRepo create a new empty git repo at the given path
func NewGitRepo ¶
NewGitRepo determines if the given working directory is inside of a git repository, and returns the corresponding GitRepo instance if it is.
func (*GitRepo) AddRemote ¶
AddRemote add a new remote to the repository Not in the interface because it's only used for testing
func (*GitRepo) CreateTimeIncrement ¶
CreateTimeIncrement increment the creation clock and return the new value.
func (*GitRepo) CreateWitness ¶
CreateWitness witness another create time and increment the corresponding clock if needed.
func (*GitRepo) EditTimeIncrement ¶
EditTimeIncrement increment the edit clock and return the new value.
func (*GitRepo) EditWitness ¶
EditWitness witness another edition time and increment the corresponding clock if needed.
func (*GitRepo) FindCommonAncestor ¶
FindCommonAncestor will return the last common ancestor of two chain of commit
func (*GitRepo) GetCoreEditor ¶
GetCoreEditor returns the name of the editor that the user has used to configure git.
func (*GitRepo) GetTreeHash ¶
GetTreeHash return the git tree hash referenced in a commit
func (*GitRepo) GetUserEmail ¶
GetUserEmail returns the email address that the user has used to configure git.
func (*GitRepo) GetUserName ¶
GetUserName returns the name the the user has used to configure git
func (*GitRepo) ListCommits ¶
ListCommits will return the list of commit hashes of a ref, in chronological order
func (*GitRepo) ListEntries ¶
ListEntries will return the list of entries in a Git tree
func (*GitRepo) LoadClocks ¶
LoadClocks read the clocks values from the on-disk repo
func (*GitRepo) ReadConfigs ¶
ReadConfigs read all key/value pair matching the key prefix
func (*GitRepo) StoreCommit ¶
StoreCommit will store a Git commit with the given Git tree
func (*GitRepo) StoreCommitWithParent ¶
StoreCommitWithParent will store a Git commit with the given Git tree
func (*GitRepo) StoreConfig ¶
StoreConfig store a single key/value pair in the config of the repo
func (*GitRepo) WriteClocks ¶
WriteClocks write the clocks values into the repo
type ObjectType ¶
type ObjectType int
const ( Unknown ObjectType = iota Blob Tree )
func ParseObjectType ¶
func ParseObjectType(mode, objType string) (ObjectType, error)
func (ObjectType) Format ¶
func (ot ObjectType) Format() string
type Repo ¶
type Repo interface { RepoCommon // FetchRefs fetch git refs from a remote FetchRefs(remote string, refSpec string) (string, error) // PushRefs push git refs to a remote PushRefs(remote string, refSpec string) (string, error) // StoreData will store arbitrary data and return the corresponding hash StoreData(data []byte) (git.Hash, error) // ReadData will attempt to read arbitrary data from the given hash ReadData(hash git.Hash) ([]byte, error) // StoreTree will store a mapping key-->Hash as a Git tree StoreTree(mapping []TreeEntry) (git.Hash, error) // StoreCommit will store a Git commit with the given Git tree StoreCommit(treeHash git.Hash) (git.Hash, error) // StoreCommit will store a Git commit with the given Git tree StoreCommitWithParent(treeHash git.Hash, parent git.Hash) (git.Hash, error) // UpdateRef will create or update a Git reference UpdateRef(ref string, hash git.Hash) error // ListRefs will return a list of Git ref matching the given refspec ListRefs(refspec string) ([]string, error) // RefExist will check if a reference exist in Git RefExist(ref string) (bool, error) // CopyRef will create a new reference with the same value as another one CopyRef(source string, dest string) error // ListCommits will return the list of tree hashes of a ref, in chronological order ListCommits(ref string) ([]git.Hash, error) // ListEntries will return the list of entries in a Git tree ListEntries(hash git.Hash) ([]TreeEntry, error) // FindCommonAncestor will return the last common ancestor of two chain of commit FindCommonAncestor(hash1 git.Hash, hash2 git.Hash) (git.Hash, error) // GetTreeHash return the git tree hash referenced in a commit GetTreeHash(commit git.Hash) (git.Hash, error) }
Repo represents a source code repository.
type RepoCommon ¶
type RepoCommon interface { // GetPath returns the path to the repo. GetPath() string // GetUserName returns the name the the user has used to configure git GetUserName() (string, error) // GetUserEmail returns the email address that the user has used to configure git. GetUserEmail() (string, error) // GetCoreEditor returns the name of the editor that the user has used to configure git. GetCoreEditor() (string, error) // StoreConfig store a single key/value pair in the config of the repo StoreConfig(key string, value string) error // ReadConfigs read all key/value pair matching the key prefix ReadConfigs(keyPrefix string) (map[string]string, error) // RmConfigs remove all key/value pair matching the key prefix RmConfigs(keyPrefix string) error }
RepoCommon represent the common function the we want all the repo to implement