Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigPath(path string) string
- func DefaultPath() string
- func Exists(path string) bool
- func GenerateHash(data []byte) (string, error)
- func HeadPath(path string) string
- func HeadsPath(path string) string
- func IndexPath(path string) string
- func Init(path string, userJson []byte) error
- func ObjPath(path string) string
- func PathToBranch(branchName string) string
- type DefaultGitFileFormatter
- func (obj *DefaultGitFileFormatter) Deserialize(data []byte) (*DeserializedGitObject, error)
- func (obj *DefaultGitFileFormatter) Save(serialized *SerializedGitObject, objPath string) error
- func (obj *DefaultGitFileFormatter) Serialize(data []byte, objType GitObjectType) (*SerializedGitObject, error)
- type DeserializedGitObject
- type FileReader
- type GitFileFormatter
- type GitObjectType
- type Hash
- type IndexEntry
- type Mode
- type ObjectReader
- type SerializedGitObject
- type TreeAlreadyExistError
Constants ¶
View Source
const ( Objects = "/objects/" Refs = "/refs" Heads = "/heads/" Head = "/HEAD" Config = "/config.json" Description = "Description" Index = "/index" )
View Source
const ( FILE Mode = "100644" EXECUTABLE = "100755" DIR = "04000" )
View Source
const ( BLOB GitObjectType = "blob" TREE = "tree" COMMIT = "commit" )
View Source
const IndexParts = 5
Variables ¶
View Source
var ( //reader to read a raw content from given path Reader FileReader = func(path string) ([]byte, error) { return ioutil.ReadFile(path) } //reader to read raw content as git obj ObjReader ObjectReader = func(path string, formatter GitFileFormatter) (*DeserializedGitObject, error) { content, err := ioutil.ReadFile(path) if err != nil { return nil, err } return formatter.Deserialize(content) } )
Functions ¶
func ConfigPath ¶
func DefaultPath ¶
func DefaultPath() string
func GenerateHash ¶
func PathToBranch ¶
Types ¶
type DefaultGitFileFormatter ¶
type DefaultGitFileFormatter struct { }
func (*DefaultGitFileFormatter) Deserialize ¶
func (obj *DefaultGitFileFormatter) Deserialize(data []byte) (*DeserializedGitObject, error)
func (*DefaultGitFileFormatter) Save ¶
func (obj *DefaultGitFileFormatter) Save(serialized *SerializedGitObject, objPath string) error
func (*DefaultGitFileFormatter) Serialize ¶
func (obj *DefaultGitFileFormatter) Serialize(data []byte, objType GitObjectType) (*SerializedGitObject, error)
type DeserializedGitObject ¶
type DeserializedGitObject struct { ObjType GitObjectType Content string }
type FileReader ¶
type GitFileFormatter ¶
type GitFileFormatter interface { Serialize(data []byte, objType GitObjectType) (*SerializedGitObject, error) Deserialize(data []byte) (*DeserializedGitObject, error) Save(serialized *SerializedGitObject, path string) error }
type GitObjectType ¶
type GitObjectType string
func AsGitObjectType ¶
func AsGitObjectType(str string) (GitObjectType, error)
convert given string to git object type
func TypeByHash ¶
func TypeByHash( objPath string, hash Hash, reader FileReader, fileFormatter GitFileFormatter, ) (GitObjectType, error)
Get type of a object by given hash
type IndexEntry ¶
type IndexEntry struct {
// contains filtered or unexported fields
}
func NewIndex ¶
file - the file's name to index plainMode - the files' type hash - the hash of this file to index objPath - path to object repository
func ParseLineToIndex ¶
func ParseLineToIndex(line string) (*IndexEntry, error)
Parse given line to index entry
func (IndexEntry) BlobString ¶
func (entry IndexEntry) BlobString(part int) string
String representation of a single file in a tree
func (IndexEntry) Depth ¶
func (entry IndexEntry) Depth() int
Get the depth of a file for given index
func (IndexEntry) Path ¶
func (entry IndexEntry) Path() string
func (IndexEntry) PathParts ¶
func (entry IndexEntry) PathParts() []string
type ObjectReader ¶
type ObjectReader func( path string, formatter GitFileFormatter, ) (*DeserializedGitObject, error)
type SerializedGitObject ¶
type TreeAlreadyExistError ¶
type TreeAlreadyExistError struct {
// contains filtered or unexported fields
}
func NewTreeAlreadyExistError ¶
func NewTreeAlreadyExistError(message string) *TreeAlreadyExistError
func (*TreeAlreadyExistError) Error ¶
func (err *TreeAlreadyExistError) Error() string
Click to show internal directories.
Click to hide internal directories.