core

package
v0.0.0-...-d106742 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	White = iota
	Gray
	Black
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobObject

type BlobObject struct {
	Obj GitObject
}

func NewBlobObject

func NewBlobObject(rootDir string) *BlobObject

func (*BlobObject) CreateFromFile

func (blob *BlobObject) CreateFromFile(filename string)

func (*BlobObject) ReadFromExistingObject

func (blob *BlobObject) ReadFromExistingObject(sha1Name string)

type Branch

type Branch struct {
	// contains filtered or unexported fields
}

func NewBranch

func NewBranch(name string, rootDir string) *Branch

func (*Branch) Commit

func (branch *Branch) Commit() string

func (*Branch) Read

func (branch *Branch) Read()

func (*Branch) SetCommit

func (branch *Branch) SetCommit(commit string)

func (*Branch) Write

func (branch *Branch) Write()

type Color

type Color int

type CommitGraph

type CommitGraph struct {
	// contains filtered or unexported fields
}

func NewCommitGraph

func NewCommitGraph(root_commit *CommitObject, rootDir string) *CommitGraph

func (*CommitGraph) LoadAllCommits

func (cg *CommitGraph) LoadAllCommits() []*CommitObject

func (*CommitGraph) PrintCommitLogs

func (cg *CommitGraph) PrintCommitLogs()

type CommitObject

type CommitObject struct {
	Obj GitObject
	// contains filtered or unexported fields
}

func NewCommitObject

func NewCommitObject(rootDir string) *CommitObject

func (*CommitObject) GenerateContent

func (commit *CommitObject) GenerateContent()

func (*CommitObject) ReadFromExistingObject

func (commit *CommitObject) ReadFromExistingObject(sha1Name string)

func (*CommitObject) SetAuthor

func (commit *CommitObject) SetAuthor(author string)

func (*CommitObject) SetCommitter

func (commit *CommitObject) SetCommitter(committer string)

func (*CommitObject) SetMessage

func (commit *CommitObject) SetMessage(message string)

func (*CommitObject) SetParents

func (commit *CommitObject) SetParents(parents []string)

func (*CommitObject) SetTree

func (commit *CommitObject) SetTree(tree string)

type GitObject

type GitObject struct {
	HashedFilename []byte
	// contains filtered or unexported fields
}

func (*GitObject) WriteToFile

func (obj *GitObject) WriteToFile()

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph() *Graph

func (*Graph) AddEdge

func (graph *Graph) AddEdge(source string, target string)

func (*Graph) AddNode

func (graph *Graph) AddNode(typ string, name string, sha1Name []byte)

func (*Graph) BFS

func (graph *Graph) BFS(source_node *GraphNode, before_callback func(*GraphNode), after_callback func(*GraphNode))

func (*Graph) DFS

func (graph *Graph) DFS(before_callback func(*GraphNode), after_callback func(*GraphNode))

func (*Graph) LookUpNode

func (graph *Graph) LookUpNode(name string) (*GraphNode, bool)

type GraphNode

type GraphNode struct {
	// contains filtered or unexported fields
}
type HEAD struct {
	Content        string // SHA-1 for a commit or a branch name
	PointsToBranch bool
	// contains filtered or unexported fields
}

func NewHEAD

func NewHEAD(rootDir string) *HEAD

func (*HEAD) PointsTo

func (head *HEAD) PointsTo(name string, isBranchName bool)

func (*HEAD) Read

func (head *HEAD) Read()

type Index

type Index struct {
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(rootDir string) *Index

func (*Index) ClearEntries

func (index *Index) ClearEntries()

func (*Index) Entries

func (index *Index) Entries() []*IndexEntry

func (*Index) Read

func (index *Index) Read()

func (*Index) Save

func (index *Index) Save()

func (*Index) WriteEmptyStatEntries

func (index *Index) WriteEmptyStatEntries(path_names []string, object_ids [][]byte, stages []uint16)

func (*Index) WriteEntries

func (index *Index) WriteEntries(path_names []string, object_ids [][]byte)

type IndexEntry

type IndexEntry struct {
	// 32-bit ctime seconds, the last time a file's metadata changed
	// this is stat(2) data
	Ctime_sec uint32
	// 32-bit ctime nanosecond fractions
	// this is stat(2) data
	Ctime_nanosec uint32
	// 32-bit mtime seconds, the last time a file's data changed
	// this is stat(2) data
	Mtime_sec uint32
	// 32-bit mtime nanosecond fractions
	// this is stat(2) data
	Mtime_nanosec uint32
	// 32-bit Dev
	// this is stat(2) data
	Dev uint32
	// 32-bit Ino
	// this is stat(2) data
	Ino uint32

	// 9-bit unix permission. Only 0755 and 0644 are valid for regular files.
	// Symbolic links and gitlinks have value 0 in this field.
	Mode uint32
	// 32-bit Uid
	// this is stat(2) data
	Uid uint32
	// 32-bit Gid
	// this is stat(2) data
	Gid uint32
	// 32-bit file size
	// This is the on-disk size from stat(2), truncated to 32-bit.
	File_size uint32
	// (SHA-1) Object name for the represented object
	Obj_name []byte

	// 12-bit name length if the length is less than 0xFFF; otherwise 0xFFF
	// is stored in this field.
	Flags uint16

	// The exact encoding is undefined, but the '.' and '/' characters
	// are encoded in 7-bit ASCII and the encoding cannot contain a NUL
	// byte (iow, this is a UNIX pathname).
	Path []byte
}

An index entry typically represents a file. However, if sparse-checkout

is enabled in cone mode (`core.sparseCheckoutCone` is enabled) and the
`extensions.sparseIndex` extension is enabled, then the index may
contain entries for directories outside of the sparse-checkout definition.
These entries have mode `040000`, include the `SKIP_WORKTREE` bit, and
the path ends in a directory separator.

func (*IndexEntry) Stage

func (entry *IndexEntry) Stage() uint16

type IndexHeader

type IndexHeader struct {
	// contains filtered or unexported fields
}

12-byte header

type List

type List struct {
	// contains filtered or unexported fields
}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(max_size int) *Queue

func (*Queue) Dequeue

func (queue *Queue) Dequeue() interface{}

func (*Queue) Enqueue

func (queue *Queue) Enqueue(element interface{})

func (*Queue) IsEmpty

func (queue *Queue) IsEmpty() bool

type ReGit

type ReGit struct {
	RootDir string
	Config  map[string]string
}

func NewReGit

func NewReGit(rootDir string) *ReGit

func (*ReGit) Add

func (regit *ReGit) Add(path_names []string)

func (*ReGit) Checkout

func (regit *ReGit) Checkout(path_names []string)

func (*ReGit) Commmit

func (regit *ReGit) Commmit(message string)

func (*ReGit) CreateBranch

func (regit *ReGit) CreateBranch(name string)

func (*ReGit) Init

func (regit *ReGit) Init()

func (*ReGit) Log

func (regit *ReGit) Log()

func (*ReGit) Merge

func (regit *ReGit) Merge(target_branch_name string)

type TreeEntry

type TreeEntry struct {
	FileType       string
	FileName       string
	HashedFilename []byte
}

type TreeGraph

type TreeGraph struct {
	// contains filtered or unexported fields
}

An auxiliary data structure for constructing tree objects based on the content of staging area (index)

func NewTreeGraph

func NewTreeGraph() *TreeGraph

func (*TreeGraph) AddEntry

func (tg *TreeGraph) AddEntry(path string, sha1Name []byte)

func (*TreeGraph) ConstructTreeObjects

func (tg *TreeGraph) ConstructTreeObjects(rootDir string) []byte

type TreeObject

type TreeObject struct {
	Obj             GitObject
	Entries         []*TreeEntry
	DescendentTrees map[string]*TreeObject
}

func NewTreeObject

func NewTreeObject(rootDir string) *TreeObject

func (*TreeObject) FilePathNames

func (tree *TreeObject) FilePathNames() []string

return all file path names stored by the tree object

func (*TreeObject) FilesSHA1

func (tree *TreeObject) FilesSHA1() [][]byte

func (*TreeObject) ReadFromExistingObject

func (tree *TreeObject) ReadFromExistingObject(sha1Name string)

func (*TreeObject) RecursiveRead

func (tree *TreeObject) RecursiveRead(sha1Name string)

func (*TreeObject) WriteEntries

func (tree *TreeObject) WriteEntries(entries []*TreeEntry)

Jump to

Keyboard shortcuts

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