gitea: Index | Files

package git

import ""


Package Files

blame.go blob.go cache.go command.go commit.go commit_archive.go commit_info.go error.go git.go hook.go notes.go parse.go ref.go repo.go repo_blame.go repo_blob.go repo_branch.go repo_commit.go repo_commitgraph.go repo_compare.go repo_hook.go repo_index.go repo_object.go repo_ref.go repo_stats.go repo_tag.go repo_tree.go sha1.go signature.go submodule.go tag.go tree.go tree_blob.go tree_entry.go utils.go


const BranchPrefix = "refs/heads/"

BranchPrefix base dir of the branch information file store on git

const EmptySHA = "0000000000000000000000000000000000000000"

EmptySHA defines empty git SHA

const (
    // GitTimeLayout is the (default) time layout used by git.
    GitTimeLayout = "Mon Jan _2 15:04:05 2006 -0700"
const (
    // HookPathUpdate hook update path
    HookPathUpdate = "hooks/update"
const NotesRef = "refs/notes/commits"

NotesRef is the git ref where Gitea will look for git-notes data. The value ("refs/notes/commits") is the default ref used by git-notes.

const TagPrefix = "refs/tags/"

TagPrefix tags prefix path on the repository


var (
    // GlobalCommandArgs global command args for external package setting
    GlobalCommandArgs []string

    // DefaultCommandExecutionTimeout default command execution timeout duration
    DefaultCommandExecutionTimeout = 60 * time.Second
var (
    // Debug enables verbose logging on everything.
    // This should be false in case Gogs starts in SSH mode.
    Debug = false
    // Prefix the log prefix
    Prefix = "[git-module] "
    // GitVersionRequired is the minimum Git version required
    GitVersionRequired = "1.7.2"

    // GitExecutable is the command name of git
    // Could be updated to an absolute path while initialization
    GitExecutable = "git"
var CommitsRangeSize = 50

CommitsRangeSize the default commits range size

var (
    // ErrNotValidHook error when a git hook is not valid
    ErrNotValidHook = errors.New("not a valid Git hook")

func AddChanges Uses

func AddChanges(repoPath string, all bool, files ...string) error

AddChanges marks local changes to be ready for commit.

func BinVersion Uses

func BinVersion() (string, error)

BinVersion returns current Git version from shell.

func Checkout Uses

func Checkout(repoPath string, opts CheckoutOptions) error

Checkout checkouts a branch

func Clone Uses

func Clone(from, to string, opts CloneRepoOptions) (err error)

Clone clones original repository to target path.

func CommitChanges Uses

func CommitChanges(repoPath string, opts CommitChangesOptions) error

CommitChanges commits local changes with given committer, author and message. If author is nil, it will be the same as committer.

func CommitsCount Uses

func CommitsCount(repoPath, revision string) (int64, error)

CommitsCount returns number of total commits of until given revision.

func Fsck Uses

func Fsck(repoPath string, timeout time.Duration, args ...string) error

Fsck verifies the connectivity and validity of the objects in the database

func GetFullCommitID Uses

func GetFullCommitID(repoPath, shortID string) (string, error)

GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.

func GetLatestCommitTime Uses

func GetLatestCommitTime(repoPath string) (time.Time, error)

GetLatestCommitTime returns time for latest commit in repository (across all branches)

func GetNote Uses

func GetNote(repo *Repository, commitID string, note *Note) error

GetNote retrieves the git-notes data for a given commit.

func Init Uses

func Init() error

Init initializes git module

func InitRepository Uses

func InitRepository(repoPath string, bare bool) error

InitRepository initializes a new Git repository.

func IsBranchExist Uses

func IsBranchExist(repoPath, name string) bool

IsBranchExist returns true if given branch exists in the repository.

func IsErrBranchNotExist Uses

func IsErrBranchNotExist(err error) bool

IsErrBranchNotExist checks if an error is a ErrBranchNotExist.

func IsErrExecTimeout Uses

func IsErrExecTimeout(err error) bool

IsErrExecTimeout if some error is ErrExecTimeout

func IsErrNotExist Uses

func IsErrNotExist(err error) bool

IsErrNotExist if some error is ErrNotExist

func IsErrUnsupportedVersion Uses

func IsErrUnsupportedVersion(err error) bool

IsErrUnsupportedVersion if some error is ErrUnsupportedVersion

func IsReferenceExist Uses

func IsReferenceExist(repoPath, name string) bool

IsReferenceExist returns true if given reference exists in the repository.

func IsRepoURLAccessible Uses

func IsRepoURLAccessible(url string) bool

IsRepoURLAccessible checks if given repository URL is accessible.

func IsTagExist Uses

func IsTagExist(repoPath, name string) bool

IsTagExist returns true if given tag exists in the repository.

func IsValidHookName Uses

func IsValidHookName(name string) bool

IsValidHookName returns true if given name is a valid Git hook.

func MoveFile Uses

func MoveFile(repoPath, oldTreeName, newTreeName string) error

MoveFile moves a file to another file or directory.

func Pull Uses

func Pull(repoPath string, opts PullRemoteOptions) error

Pull pulls changes from remotes.

func Push Uses

func Push(repoPath string, opts PushOptions) error

Push pushs local commits to given remote branch.

func RefEndName Uses

func RefEndName(refStr string) string

RefEndName return the end name of a ref name

func ResetHEAD Uses

func ResetHEAD(repoPath string, hard bool, revision string) error

ResetHEAD resets HEAD to given revision or head of branch.

func SetExecutablePath Uses

func SetExecutablePath(path string) error

SetExecutablePath changes the path of git executable and checks the file permission and version.

func SetUpdateHook Uses

func SetUpdateHook(repoPath, content string) (err error)

SetUpdateHook writes given content to update hook of the reposiotry.

func Version Uses

func Version() string

Version return this package's current version

type ArchiveType Uses

type ArchiveType int

ArchiveType archive types

const (
    // ZIP zip archive type
    ZIP ArchiveType = iota + 1
    // TARGZ tar gz archive type

type BlamePart Uses

type BlamePart struct {
    Sha   string
    Lines []string

BlamePart represents block of blame - continuous lines with one sha

type BlameReader Uses

type BlameReader struct {
    // contains filtered or unexported fields

BlameReader returns part of file blame one by one

func CreateBlameReader Uses

func CreateBlameReader(repoPath, commitID, file string) (*BlameReader, error)

CreateBlameReader creates reader for given repository, commit and file

func (*BlameReader) Close Uses

func (r *BlameReader) Close() error

Close BlameReader - don't run NextPart after invoking that

func (*BlameReader) NextPart Uses

func (r *BlameReader) NextPart() (*BlamePart, error)

NextPart returns next part of blame (sequencial code lines with the same commit)

type Blob Uses

type Blob struct {
    ID SHA1
    // contains filtered or unexported fields

Blob represents a Git object.

func (*Blob) DataAsync Uses

func (b *Blob) DataAsync() (io.ReadCloser, error)

DataAsync gets a ReadCloser for the contents of a blob without reading it all. Calling the Close function on the result will discard all unread output.

func (*Blob) GetBlobContent Uses

func (b *Blob) GetBlobContent() (string, error)

GetBlobContent Gets the content of the blob as raw text

func (*Blob) GetBlobContentBase64 Uses

func (b *Blob) GetBlobContentBase64() (string, error)

GetBlobContentBase64 Reads the content of the blob with a base64 encode and returns the encoded string

func (*Blob) Name Uses

func (b *Blob) Name() string

Name returns name of the tree entry this blob object was created from (or empty string)

func (*Blob) Size Uses

func (b *Blob) Size() int64

Size returns the uncompressed size of the blob

type Branch Uses

type Branch struct {
    Name string
    Path string
    // contains filtered or unexported fields

Branch represents a Git branch.

func GetBranchesByPath Uses

func GetBranchesByPath(path string) ([]*Branch, error)

GetBranchesByPath returns a branch by it's path

func (*Branch) GetCommit Uses

func (branch *Branch) GetCommit() (*Commit, error)

GetCommit returns the head commit of a branch

type CheckoutOptions Uses

type CheckoutOptions struct {
    Timeout   time.Duration
    Branch    string
    OldBranch string

CheckoutOptions options when heck out some branch

type CloneRepoOptions Uses

type CloneRepoOptions struct {
    Timeout    time.Duration
    Mirror     bool
    Bare       bool
    Quiet      bool
    Branch     string
    Shared     bool
    NoCheckout bool

CloneRepoOptions options when clone a repository

type CodeActivityStats Uses

type CodeActivityStats struct {
    AuthorCount              int64
    CommitCount              int64
    ChangedFiles             int64
    Additions                int64
    Deletions                int64
    CommitCountInAllBranches int64
    Authors                  map[string]int64

CodeActivityStats represents git statistics data

type Command Uses

type Command struct {
    // contains filtered or unexported fields

Command represents a command with its subcommands or arguments.

func NewCommand Uses

func NewCommand(args ...string) *Command

NewCommand creates and returns a new Git Command based on given command and arguments.

func (*Command) AddArguments Uses

func (c *Command) AddArguments(args ...string) *Command

AddArguments adds new argument(s) to the command.

func (*Command) Run Uses

func (c *Command) Run() (string, error)

Run executes the command in default working directory and returns stdout in string and error (combined with stderr).

func (*Command) RunInDir Uses

func (c *Command) RunInDir(dir string) (string, error)

RunInDir executes the command in given directory and returns stdout in string and error (combined with stderr).

func (*Command) RunInDirBytes Uses

func (c *Command) RunInDirBytes(dir string) ([]byte, error)

RunInDirBytes executes the command in given directory and returns stdout in []byte and error (combined with stderr).

func (*Command) RunInDirFullPipeline Uses

func (c *Command) RunInDirFullPipeline(dir string, stdout, stderr io.Writer, stdin io.Reader) error

RunInDirFullPipeline executes the command in given directory, it pipes stdout and stderr to given io.Writer.

func (*Command) RunInDirPipeline Uses

func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error

RunInDirPipeline executes the command in given directory, it pipes stdout and stderr to given io.Writer.

func (*Command) RunInDirTimeout Uses

func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error)

RunInDirTimeout executes the command in given directory with given timeout, and returns stdout in []byte and error (combined with stderr).

func (*Command) RunInDirTimeoutEnv Uses

func (c *Command) RunInDirTimeoutEnv(env []string, timeout time.Duration, dir string) ([]byte, error)

RunInDirTimeoutEnv executes the command in given directory with given timeout, and returns stdout in []byte and error (combined with stderr).

func (*Command) RunInDirTimeoutEnvFullPipeline Uses

func (c *Command) RunInDirTimeoutEnvFullPipeline(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader) error

RunInDirTimeoutEnvFullPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer and passes in an io.Reader as stdin.

func (*Command) RunInDirTimeoutEnvPipeline Uses

func (c *Command) RunInDirTimeoutEnvPipeline(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer) error

RunInDirTimeoutEnvPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer.

func (*Command) RunInDirTimeoutFullPipeline Uses

func (c *Command) RunInDirTimeoutFullPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader) error

RunInDirTimeoutFullPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer, and stdin from the given io.Reader

func (*Command) RunInDirTimeoutPipeline Uses

func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error

RunInDirTimeoutPipeline executes the command in given directory with given timeout, it pipes stdout and stderr to given io.Writer.

func (*Command) RunInDirWithEnv Uses

func (c *Command) RunInDirWithEnv(dir string, env []string) (string, error)

RunInDirWithEnv executes the command in given directory and returns stdout in string and error (combined with stderr).

func (*Command) RunTimeout Uses

func (c *Command) RunTimeout(timeout time.Duration) (string, error)

RunTimeout executes the command in default working directory with given timeout, and returns stdout in string and error (combined with stderr).

func (*Command) String Uses

func (c *Command) String() string

type Commit Uses

type Commit struct {
    Branch string // Branch this commit belongs to
    ID            SHA1 // The ID of this commit object
    Author        *Signature
    Committer     *Signature
    CommitMessage string
    Signature     *CommitGPGSignature
    // contains filtered or unexported fields

Commit represents a git commit.

func (*Commit) CommitsBefore Uses

func (c *Commit) CommitsBefore() (*list.List, error)

CommitsBefore returns all the commits before current revision

func (*Commit) CommitsBeforeLimit Uses

func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error)

CommitsBeforeLimit returns num commits before current revision

func (*Commit) CommitsBeforeUntil Uses

func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error)

CommitsBeforeUntil returns the commits between commitID to current revision

func (*Commit) CommitsByRange Uses

func (c *Commit) CommitsByRange(page int) (*list.List, error)

CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize

func (*Commit) CommitsCount Uses

func (c *Commit) CommitsCount() (int64, error)

CommitsCount returns number of total commits of until current revision.

func (*Commit) CreateArchive Uses

func (c *Commit) CreateArchive(target string, archiveType ArchiveType) error

CreateArchive create archive content to the target path

func (*Commit) FileChangedSinceCommit Uses

func (c *Commit) FileChangedSinceCommit(filename, pastCommit string) (bool, error)

FileChangedSinceCommit Returns true if the file given has changed since the the past commit YOU MUST ENSURE THAT pastCommit is a valid commit ID.

func (*Commit) GetBranchName Uses

func (c *Commit) GetBranchName() (string, error)

GetBranchName gets the closes branch name (as returned by 'git name-rev')

func (*Commit) GetCommitByPath Uses

func (c *Commit) GetCommitByPath(relpath string) (*Commit, error)

GetCommitByPath return the commit of relative path object.

func (*Commit) GetFilesChangedSinceCommit Uses

func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error)

GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision

func (*Commit) GetSubModule Uses

func (c *Commit) GetSubModule(entryname string) (*SubModule, error)

GetSubModule get the sub module according entryname

func (*Commit) GetSubModules Uses

func (c *Commit) GetSubModules() (*ObjectCache, error)

GetSubModules get all the sub modules of current revision git tree

func (*Commit) HasFile Uses

func (c *Commit) HasFile(filename string) (bool, error)

HasFile returns true if the file given exists on this commit This does only mean it's there - it does not mean the file was changed during the commit.

func (*Commit) ImageInfo Uses

func (c *Commit) ImageInfo(name string) (*ImageMetaData, error)

ImageInfo returns information about the dimensions of an image

func (*Commit) IsImageFile Uses

func (c *Commit) IsImageFile(name string) bool

IsImageFile is a file image type

func (*Commit) Message Uses

func (c *Commit) Message() string

Message returns the commit message. Same as retrieving CommitMessage directly.

func (*Commit) Parent Uses

func (c *Commit) Parent(n int) (*Commit, error)

Parent returns n-th parent (0-based index) of the commit.

func (*Commit) ParentCount Uses

func (c *Commit) ParentCount() int

ParentCount returns number of parents of the commit. 0 if this is the root commit, otherwise 1,2, etc.

func (*Commit) ParentID Uses

func (c *Commit) ParentID(n int) (SHA1, error)

ParentID returns oid of n-th parent (0-based index). It returns nil if no such parent exists.

func (*Commit) SearchCommits Uses

func (c *Commit) SearchCommits(opts SearchCommitsOptions) (*list.List, error)

SearchCommits returns the commits match the keyword before current revision

func (*Commit) Summary Uses

func (c *Commit) Summary() string

Summary returns first line of commit message.

type CommitChangesOptions Uses

type CommitChangesOptions struct {
    Committer *Signature
    Author    *Signature
    Message   string

CommitChangesOptions the options when a commit created

type CommitFileStatus Uses

type CommitFileStatus struct {
    Added    []string
    Removed  []string
    Modified []string

CommitFileStatus represents status of files in a commit.

func GetCommitFileStatus Uses

func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error)

GetCommitFileStatus returns file status of commit in given repository.

func NewCommitFileStatus Uses

func NewCommitFileStatus() *CommitFileStatus

NewCommitFileStatus creates a CommitFileStatus

type CommitGPGSignature Uses

type CommitGPGSignature struct {
    Signature string
    Payload   string //TODO check if can be reconstruct from the rest of commit information to not have duplicate data

CommitGPGSignature represents a git commit signature part.

type CommitTreeOpts Uses

type CommitTreeOpts struct {
    Parents   []string
    Message   string
    KeyID     string
    NoGPGSign bool

CommitTreeOpts represents the possible options to CommitTree

type CompareInfo Uses

type CompareInfo struct {
    MergeBase string
    Commits   *list.List
    NumFiles  int

CompareInfo represents needed information for comparing references.

type CountObject Uses

type CountObject struct {
    Count       int64
    Size        int64
    InPack      int64
    Packs       int64
    SizePack    int64
    PrunePack   int64
    Garbage     int64
    SizeGarbage int64

CountObject represents repository count objects report

func GetRepoSize Uses

func GetRepoSize(repoPath string) (*CountObject, error)

GetRepoSize returns disk consumption for repo in path

type DeleteBranchOptions Uses

type DeleteBranchOptions struct {
    Force bool

DeleteBranchOptions Option(s) for delete branch

type DivergeObject Uses

type DivergeObject struct {
    Ahead  int
    Behind int

DivergeObject represents commit count diverging commits

func GetDivergingCommits Uses

func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string) (DivergeObject, error)

GetDivergingCommits returns the number of commits a targetBranch is ahead or behind a baseBranch

type Entries Uses

type Entries []*TreeEntry

Entries a list of entry

func (Entries) CustomSort Uses

func (tes Entries) CustomSort(cmp func(s1, s2 string) bool)

CustomSort customizable string comparing sort entry list

func (Entries) GetCommitsInfo Uses

func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, *Commit, error)

GetCommitsInfo gets information of all commits that are corresponding to these entries

func (Entries) Sort Uses

func (tes Entries) Sort()

Sort sort the list of entry

type EntryMode Uses

type EntryMode int

EntryMode the type of the object in the git tree

const (
    // EntryModeBlob
    EntryModeBlob EntryMode = 0100644
    // EntryModeExec
    EntryModeExec EntryMode = 0100755
    // EntryModeSymlink
    EntryModeSymlink EntryMode = 0120000
    // EntryModeCommit
    EntryModeCommit EntryMode = 0160000
    // EntryModeTree
    EntryModeTree EntryMode = 0040000

There are only a few file modes in Git. They look like unix file modes, but they can only be one of these.

type ErrBadLink struct {
    Name    string
    Message string

ErrBadLink entry.FollowLink error

func (ErrBadLink) Error Uses

func (err ErrBadLink) Error() string

type ErrBranchNotExist Uses

type ErrBranchNotExist struct {
    Name string

ErrBranchNotExist represents a "BranchNotExist" kind of error.

func (ErrBranchNotExist) Error Uses

func (err ErrBranchNotExist) Error() string

type ErrExecTimeout Uses

type ErrExecTimeout struct {
    Duration time.Duration

ErrExecTimeout error when exec timed out

func (ErrExecTimeout) Error Uses

func (err ErrExecTimeout) Error() string

type ErrNotExist Uses

type ErrNotExist struct {
    ID      string
    RelPath string

ErrNotExist commit not exist error

func (ErrNotExist) Error Uses

func (err ErrNotExist) Error() string

type ErrUnsupportedVersion Uses

type ErrUnsupportedVersion struct {
    Required string

ErrUnsupportedVersion error when required git version not matched

func (ErrUnsupportedVersion) Error Uses

func (err ErrUnsupportedVersion) Error() string

type Hook Uses

type Hook struct {
    IsActive bool   // Indicates whether repository has this hook.
    Content  string // Content of hook if it's active.
    Sample   string // Sample content from Git.
    // contains filtered or unexported fields

Hook represents a Git hook.

func GetHook Uses

func GetHook(repoPath, name string) (*Hook, error)

GetHook returns a Git hook by given name and repository.

func ListHooks Uses

func ListHooks(repoPath string) (_ []*Hook, err error)

ListHooks returns a list of Git hooks of given repository.

func (*Hook) Name Uses

func (h *Hook) Name() string

Name return the name of the hook

func (*Hook) Update Uses

func (h *Hook) Update() error

Update updates hook settings.

type ImageMetaData Uses

type ImageMetaData struct {
    ColorModel color.Model
    Width      int
    Height     int
    ByteSize   int64

ImageMetaData represents metadata of an image file

type LastCommitCache Uses

type LastCommitCache interface {
    Get(repoPath, ref, entryPath string) (*Commit, error)
    Put(repoPath, ref, entryPath string, commit *Commit) error

LastCommitCache cache

type Note Uses

type Note struct {
    Message []byte
    Commit  *Commit

Note stores information about a note created using git-notes.

type ObjectCache Uses

type ObjectCache struct {
    // contains filtered or unexported fields

ObjectCache provides thread-safe cache opeations.

func (*ObjectCache) Get Uses

func (oc *ObjectCache) Get(id string) (interface{}, bool)

Get get cached obj by id

func (*ObjectCache) Set Uses

func (oc *ObjectCache) Set(id string, obj interface{})

Set add obj to cache

type ObjectType Uses

type ObjectType string

ObjectType git object type

const (
    // ObjectCommit commit object type
    ObjectCommit ObjectType = "commit"
    // ObjectTree tree object type
    ObjectTree ObjectType = "tree"
    // ObjectBlob blob object type
    ObjectBlob ObjectType = "blob"
    // ObjectTag tag object type
    ObjectTag ObjectType = "tag"
    // ObjectBranch branch object type
    ObjectBranch ObjectType = "branch"

type PullRemoteOptions Uses

type PullRemoteOptions struct {
    Timeout time.Duration
    All     bool
    Rebase  bool
    Remote  string
    Branch  string

PullRemoteOptions options when pull from remote

type PushOptions Uses

type PushOptions struct {
    Remote string
    Branch string
    Force  bool
    Env    []string

PushOptions options when push to remote

type Reference Uses

type Reference struct {
    Name string

    Object SHA1 // The id of this commit object
    Type   string
    // contains filtered or unexported fields

Reference represents a Git ref.

func (*Reference) Commit Uses

func (ref *Reference) Commit() (*Commit, error)

Commit return the commit of the reference

type Repository Uses

type Repository struct {
    Path string
    // contains filtered or unexported fields

Repository represents a Git repository.

func OpenRepository Uses

func OpenRepository(repoPath string) (*Repository, error)

OpenRepository opens the repository at the given path.

func (*Repository) AddObjectToIndex Uses

func (repo *Repository) AddObjectToIndex(mode string, object SHA1, filename string) error

AddObjectToIndex adds the provided object hash to the index at the provided filename

func (*Repository) AddRemote Uses

func (repo *Repository) AddRemote(name, url string, fetch bool) error

AddRemote adds a new remote to repository.

func (*Repository) CommitNodeIndex Uses

func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File)

CommitNodeIndex returns the index for walking commit graph

func (*Repository) CommitTree Uses

func (repo *Repository) CommitTree(sig *Signature, tree *Tree, opts CommitTreeOpts) (SHA1, error)

CommitTree creates a commit from a given tree id for the user with provided message

func (*Repository) CommitsBetween Uses

func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error)

CommitsBetween returns a list that contains commits between [last, before).

func (*Repository) CommitsBetweenIDs Uses

func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error)

CommitsBetweenIDs return commits between twoe commits

func (*Repository) CommitsByFileAndRange Uses

func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error)

CommitsByFileAndRange return the commits according revison file and the page

func (*Repository) CommitsByFileAndRangeNoFollow Uses

func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error)

CommitsByFileAndRangeNoFollow return the commits according revison file and the page

func (*Repository) CommitsCountBetween Uses

func (repo *Repository) CommitsCountBetween(start, end string) (int64, error)

CommitsCountBetween return numbers of commits between two commits

func (*Repository) ConvertToSHA1 Uses

func (repo *Repository) ConvertToSHA1(commitID string) (SHA1, error)

ConvertToSHA1 returns a Hash object from a potential ID string

func (*Repository) CreateAnnotatedTag Uses

func (repo *Repository) CreateAnnotatedTag(name, message, revision string) error

CreateAnnotatedTag create one annotated tag in the repository

func (*Repository) CreateBranch Uses

func (repo *Repository) CreateBranch(branch, oldbranchOrCommit string) error

CreateBranch create a new branch

func (*Repository) CreateTag Uses

func (repo *Repository) CreateTag(name, revision string) error

CreateTag create one tag in the repository

func (*Repository) DeleteBranch Uses

func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) error

DeleteBranch delete a branch by name on repository.

func (*Repository) EmptyIndex Uses

func (repo *Repository) EmptyIndex() error

EmptyIndex empties the index

func (*Repository) FileBlame Uses

func (repo *Repository) FileBlame(revision, path, file string) ([]byte, error)

FileBlame return the Blame object of file

func (*Repository) FileChangedBetweenCommits Uses

func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bool, error)

FileChangedBetweenCommits Returns true if the file changed between commit IDs id1 and id2 You must ensure that id1 and id2 are valid commit ids.

func (*Repository) FileCommitsCount Uses

func (repo *Repository) FileCommitsCount(revision, file string) (int64, error)

FileCommitsCount return the number of files at a revison

func (*Repository) FilesCountBetween Uses

func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)

FilesCountBetween return the number of files changed between two commits

func (*Repository) GetAnnotatedTag Uses

func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error)

GetAnnotatedTag returns a Git tag by its SHA, must be an annotated tag

func (*Repository) GetBlob Uses

func (repo *Repository) GetBlob(idStr string) (*Blob, error)

GetBlob finds the blob object in the repository.

func (*Repository) GetBranch Uses

func (repo *Repository) GetBranch(branch string) (*Branch, error)

GetBranch returns a branch by it's name

func (*Repository) GetBranchCommit Uses

func (repo *Repository) GetBranchCommit(name string) (*Commit, error)

GetBranchCommit returns the last commit of given branch.

func (*Repository) GetBranchCommitID Uses

func (repo *Repository) GetBranchCommitID(name string) (string, error)

GetBranchCommitID returns last commit ID string of given branch.

func (*Repository) GetBranches Uses

func (repo *Repository) GetBranches() ([]string, error)

GetBranches returns all branches of the repository.

func (*Repository) GetCodeActivityStats Uses

func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) (*CodeActivityStats, error)

GetCodeActivityStats returns code statistics for acitivity page

func (*Repository) GetCommit Uses

func (repo *Repository) GetCommit(commitID string) (*Commit, error)

GetCommit returns commit object of by ID string.

func (*Repository) GetCommitByPath Uses

func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error)

GetCommitByPath returns the last commit of relative path.

func (*Repository) GetCompareInfo Uses

func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string) (_ *CompareInfo, err error)

GetCompareInfo generates and returns compare information between base and head branches of repositories.

func (*Repository) GetFormatPatch Uses

func (repo *Repository) GetFormatPatch(base, head string) (io.Reader, error)

GetFormatPatch generates and returns format-patch data between given revisions.

func (*Repository) GetHEADBranch Uses

func (repo *Repository) GetHEADBranch() (*Branch, error)

GetHEADBranch returns corresponding branch of HEAD.

func (*Repository) GetHook Uses

func (repo *Repository) GetHook(name string) (*Hook, error)

GetHook get one hook according the name on a repository

func (*Repository) GetMergeBase Uses

func (repo *Repository) GetMergeBase(tmpRemote string, base, head string) (string, string, error)

GetMergeBase checks and returns merge base of two branches and the reference used as base.

func (*Repository) GetPatch Uses

func (repo *Repository) GetPatch(base, head string) ([]byte, error)

GetPatch generates and returns patch data between given revisions.

func (*Repository) GetRefCommitID Uses

func (repo *Repository) GetRefCommitID(name string) (string, error)

GetRefCommitID returns the last commit ID string of given reference (branch or tag).

func (*Repository) GetRefType Uses

func (repo *Repository) GetRefType(ref string) ObjectType

GetRefType gets the type of the ref based on the string

func (*Repository) GetRefs Uses

func (repo *Repository) GetRefs() ([]*Reference, error)

GetRefs returns all references of the repository.

func (*Repository) GetRefsFiltered Uses

func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error)

GetRefsFiltered returns all references of the repository that matches patterm exactly or starting with.

func (*Repository) GetTag Uses

func (repo *Repository) GetTag(name string) (*Tag, error)

GetTag returns a Git tag by given name.

func (*Repository) GetTagCommit Uses

func (repo *Repository) GetTagCommit(name string) (*Commit, error)

GetTagCommit get the commit of the specific tag via name

func (*Repository) GetTagCommitID Uses

func (repo *Repository) GetTagCommitID(name string) (string, error)

GetTagCommitID returns last commit ID string of given tag.

func (*Repository) GetTagID Uses

func (repo *Repository) GetTagID(name string) (string, error)

GetTagID returns the object ID for a tag (annotated tags have both an object SHA AND a commit SHA)

func (*Repository) GetTagInfos Uses

func (repo *Repository) GetTagInfos() ([]*Tag, error)

GetTagInfos returns all tag infos of the repository.

func (*Repository) GetTagNameBySHA Uses

func (repo *Repository) GetTagNameBySHA(sha string) (string, error)

GetTagNameBySHA returns the name of a tag from its tag object SHA or commit SHA

func (*Repository) GetTagType Uses

func (repo *Repository) GetTagType(id SHA1) (string, error)

GetTagType gets the type of the tag, either commit (simple) or tag (annotated)

func (*Repository) GetTags Uses

func (repo *Repository) GetTags() ([]string, error)

GetTags returns all tags of the repository.

func (*Repository) GetTree Uses

func (repo *Repository) GetTree(idStr string) (*Tree, error)

GetTree find the tree object in the repository.

func (*Repository) HashObject Uses

func (repo *Repository) HashObject(reader io.Reader) (SHA1, error)

HashObject takes a reader and returns SHA1 hash for that reader

func (*Repository) Hooks Uses

func (repo *Repository) Hooks() ([]*Hook, error)

Hooks get all the hooks on the repository

func (*Repository) IsBranchExist Uses

func (repo *Repository) IsBranchExist(name string) bool

IsBranchExist returns true if given branch exists in current repository.

func (*Repository) IsCommitExist Uses

func (repo *Repository) IsCommitExist(name string) bool

IsCommitExist returns true if given commit exists in current repository.

func (*Repository) IsEmpty Uses

func (repo *Repository) IsEmpty() (bool, error)

IsEmpty Check if repository is empty.

func (*Repository) IsTagExist Uses

func (repo *Repository) IsTagExist(name string) bool

IsTagExist returns true if given tag exists in the repository.

func (*Repository) LineBlame Uses

func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error)

LineBlame returns the latest commit at the given line

func (*Repository) LsFiles Uses

func (repo *Repository) LsFiles(filenames ...string) ([]string, error)

LsFiles checks if the given filenames are in the index

func (*Repository) ReadTreeToIndex Uses

func (repo *Repository) ReadTreeToIndex(treeish string) error

ReadTreeToIndex reads a treeish to the index

func (*Repository) RemoveFilesFromIndex Uses

func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error

RemoveFilesFromIndex removes given filenames from the index - it does not check whether they are present.

func (*Repository) RemoveRemote Uses

func (repo *Repository) RemoveRemote(name string) error

RemoveRemote removes a remote from repository.

func (*Repository) SetDefaultBranch Uses

func (repo *Repository) SetDefaultBranch(name string) error

SetDefaultBranch sets default branch of repository.

func (*Repository) WriteTree Uses

func (repo *Repository) WriteTree() (*Tree, error)

WriteTree writes the current index as a tree to the object db and returns its hash

type SHA1 Uses

type SHA1 = plumbing.Hash

SHA1 a git commit name

func MustID Uses

func MustID(b []byte) SHA1

MustID always creates a new SHA1 from a [20]byte array with no validation of input.

func MustIDFromString Uses

func MustIDFromString(s string) SHA1

MustIDFromString always creates a new sha from a ID with no validation of input.

func NewID Uses

func NewID(b []byte) (SHA1, error)

NewID creates a new SHA1 from a [20]byte array.

func NewIDFromString Uses

func NewIDFromString(s string) (SHA1, error)

NewIDFromString creates a new SHA1 from a ID string of length 40.

type SearchCommitsOptions Uses

type SearchCommitsOptions struct {
    Keywords            []string
    Authors, Committers []string
    After, Before       string
    All                 bool

SearchCommitsOptions specify the parameters for SearchCommits

func NewSearchCommitsOptions Uses

func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommitsOptions

NewSearchCommitsOptions construct a SearchCommitsOption from a space-delimited search string

type Signature Uses

type Signature = object.Signature

Signature represents the Author or Committer information.

type SubModule Uses

type SubModule struct {
    Name string
    URL  string

SubModule submodule is a reference on git repository

type SubModuleFile Uses

type SubModuleFile struct {
    // contains filtered or unexported fields

SubModuleFile represents a file with submodule type.

func NewSubModuleFile Uses

func NewSubModuleFile(c *Commit, refURL, refID string) *SubModuleFile

NewSubModuleFile create a new submodule file

func (*SubModuleFile) RefID Uses

func (sf *SubModuleFile) RefID() string

RefID returns reference ID.

func (*SubModuleFile) RefURL Uses

func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string

RefURL guesses and returns reference URL.

type Tag Uses

type Tag struct {
    Name string
    ID   SHA1

    Object  SHA1 // The id of this commit object
    Type    string
    Tagger  *Signature
    Message string
    // contains filtered or unexported fields

Tag represents a Git tag.

func (*Tag) Commit Uses

func (tag *Tag) Commit() (*Commit, error)

Commit return the commit of the tag reference

type Tree Uses

type Tree struct {
    ID         SHA1
    ResolvedID SHA1
    // contains filtered or unexported fields

Tree represents a flat directory listing.

func NewTree Uses

func NewTree(repo *Repository, id SHA1) *Tree

NewTree create a new tree according the repository and tree id

func (*Tree) GetBlobByPath Uses

func (t *Tree) GetBlobByPath(relpath string) (*Blob, error)

GetBlobByPath get the blob object according the path

func (*Tree) GetTreeEntryByPath Uses

func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error)

GetTreeEntryByPath get the tree entries according the sub dir

func (*Tree) ListEntries Uses

func (t *Tree) ListEntries() (Entries, error)

ListEntries returns all entries of current tree.

func (*Tree) ListEntriesRecursive Uses

func (t *Tree) ListEntriesRecursive() (Entries, error)

ListEntriesRecursive returns all entries of current tree recursively including all subtrees

func (*Tree) SubTree Uses

func (t *Tree) SubTree(rpath string) (*Tree, error)

SubTree get a sub tree by the sub dir path

type TreeEntry Uses

type TreeEntry struct {
    ID SHA1
    // contains filtered or unexported fields

TreeEntry the leaf in the git tree

func ParseTreeEntries Uses

func ParseTreeEntries(data []byte) ([]*TreeEntry, error)

ParseTreeEntries parses the output of a `git ls-tree` command.

func (*TreeEntry) Blob Uses

func (te *TreeEntry) Blob() *Blob

Blob returns the blob object the entry

func (te *TreeEntry) FollowLink() (*TreeEntry, error)

FollowLink returns the entry pointed to by a symlink

func (*TreeEntry) GetSubJumpablePathName Uses

func (te *TreeEntry) GetSubJumpablePathName() string

GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory )

func (*TreeEntry) IsDir Uses

func (te *TreeEntry) IsDir() bool

IsDir if the entry is a sub dir

func (*TreeEntry) IsExecutable Uses

func (te *TreeEntry) IsExecutable() bool

IsExecutable if the entry is an executable file (not necessarily binary)

func (te *TreeEntry) IsLink() bool

IsLink if the entry is a symlink

func (*TreeEntry) IsRegular Uses

func (te *TreeEntry) IsRegular() bool

IsRegular if the entry is a regular file

func (*TreeEntry) IsSubModule Uses

func (te *TreeEntry) IsSubModule() bool

IsSubModule if the entry is a sub module

func (*TreeEntry) Mode Uses

func (te *TreeEntry) Mode() EntryMode

Mode returns the mode of the entry

func (*TreeEntry) Name Uses

func (te *TreeEntry) Name() string

Name returns the name of the entry

func (*TreeEntry) Size Uses

func (te *TreeEntry) Size() int64

Size returns the size of the entry

func (*TreeEntry) Type Uses

func (te *TreeEntry) Type() string

Type returns the type of the entry (commit, tree, blob)

Package git imports 42 packages (graph) and is imported by 43 packages. Updated 2019-09-16. Refresh now. Tools for package owners.