Documentation ¶
Overview ¶
Package git implements internal git objects and related APIs.
Index ¶
- Constants
- type Blob
- type Commit
- func (commit *Commit) Author() (name, email string)
- func (commit *Commit) DataSize() int
- func (commit *Commit) Parents() []string
- func (commit *Commit) ParseData() error
- func (commit *Commit) PrettyPrint() (string, error)
- func (commit *Commit) Print() string
- func (commit *Commit) TreeHash() string
- func (commit *Commit) Type() string
- type ObjIntf
- type Object
- type RefEntry
- type Repo
- func (r *Repo) DirPath(create bool, paths ...string) (string, error)
- func (r *Repo) FilePath(create bool, paths ...string) (string, error)
- func (r *Repo) GetRefs(pattern string, getHead bool) ([]RefEntry, error)
- func (r *Repo) NameResolve(name string) ([]string, error)
- func (r *Repo) ObjectParse(objHash string) (*Object, error)
- func (r *Repo) ObjectWrite(obj *Object, write bool) (string, error)
- func (r *Repo) RefResolve(path string) (string, string, error)
- func (r *Repo) UniqueNameResolve(name string) (string, error)
- func (r *Repo) UpdateRef(ref string, newValue string) error
- func (r *Repo) ValidateRef(ref string) (string, error)
- type Tree
- type TreeEntry
Constants ¶
const ( // AuthorName is tbe name of the author used as part of metadata of a commit. AuthorName string = "Shyamsunder Rathi" // AuthorEmail is the email of the author used as part of metadata of a commit. AuthorEmail string = "sxxxxxx@gmail.com" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blob ¶ added in v0.2.0
Blob is a git object to represent the data of a single file.
func NewBlobFromFile ¶
NewBlobFromFile creates a new blob object by reading data from a file.
type Commit ¶ added in v0.2.0
type Commit struct { Repository *Repo *Object Entries entryMap // Keep the keys to maintain the insertion order. Keys []string Msg string }
Commit is a object with a map of "commit" entries, commit msg and a git object.
func NewCommitFromParams ¶
NewCommitFromParams builds a commit object using a 'tree' and optionall a 'parent' hash, and a given commit message. This can be used by CLI commands such as "gogit commit-tree".
func (*Commit) Author ¶ added in v0.3.0
Author returns the name and email of the author of the given commit.
func (*Commit) Parents ¶ added in v0.2.0
Parents returns a list of parents of the given commit. If there are no parent (base commit), then it returns an empty list.
func (*Commit) ParseData ¶ added in v0.2.0
ParseData parses a commit object's bytes and prepares a dictionary of its components.
func (*Commit) PrettyPrint ¶ added in v0.2.0
PrettyPrint prints a commit object in a human readable format, similar to what is shown by "git log" output.
type Object ¶ added in v0.2.0
Object is a struct holding the raw data for any git object type. ObjType can be one of "commit", "blob", "tree" or "tag".
type RefEntry ¶ added in v0.2.0
RefEntry keeps a mapping of a reference object with its associated reference.
type Repo ¶
Repo structure to hold the current repository details.
func GetRepo ¶
GetRepo is used by all commands other than "gogit init" to work on an existing repo. .git directory can be at given path, or can be at any parent up to rootdir.
func (*Repo) DirPath ¶
DirPath gets (and optionally creates) a directory path inside .git in the repo. Example: ["objects", "1e", "ab123"] returns ".git/objects/1e/ab123"
func (*Repo) FilePath ¶
FilePath gets a file path inside .git in the repo. Optionally create needed directories in the path. Last item in 'paths' is the file name.
func (*Repo) GetRefs ¶ added in v0.2.0
GetRefs gets all the references inside the .git directory. This can be used by commands such as "gogit show-ref".
func (*Repo) NameResolve ¶ added in v0.2.0
NameResolve resolves a given reference string to one or more equivalent hashes. Useful to:
- Convert a short hash to a list of matching full size hashes.
- Convert a symbolic, head or tag reference to a list of matching full size hashes.
func (*Repo) ObjectParse ¶
ObjectParse finds the data referred by the given sha1 hash and add the data to the object as per "Git" specifications.
func (*Repo) ObjectWrite ¶
ObjectWrite calculates the sha1 of a git object and optionally write it to a file as per "Git" specifications.
func (*Repo) RefResolve ¶
RefResolve converts a symbolic reference to its object hash.
func (*Repo) UniqueNameResolve ¶ added in v0.2.0
UniqueNameResolve converts a given name to a unique valid full object hash. It returns an error if there are less or more than 1 matching objects to the given name. This can be used by many commands to act on a single unique hash after taking a possible ambiguous name from the user.
func (*Repo) UpdateRef ¶ added in v0.3.0
UpdateRef updates the given strict reference to the full hash by resolving the value given by newValue. If 'ref' is a symbolic reference (such as HEAD), then the target reference is updated instaed (if HEAD is pointing to master, then master is updated).
func (*Repo) ValidateRef ¶ added in v0.2.0
ValidateRef strictly validates if a given reference is a valid reference in the local repository (or is HEAD). Returns the resolved object hash. This can be used by commands such as "gogit show-ref -verify".
type Tree ¶ added in v0.2.0
Tree is a object with a list of "tree" entries and a git object.
func NewTreeFromInput ¶
NewTreeFromInput parses the given string and create a tree from it.
func (*Tree) Checkout ¶ added in v0.2.0
Checkout recreates an entire worktree in a given path by recursively reading the blobs and trees inside this tree object.
func (*Tree) ParseData ¶ added in v0.2.0
ParseData parses a tree object's bytes and prepares a list of its components.