gitmodule

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REF_TYPE_BRANCH = "branch"
	REF_TYPE_TAG    = "tag"
	REF_TYPE_COMMIT = "commit"
	REF_TYPE_TREE   = "tree"
)
View Source
const (
	DIFF_LINE_CONTEXT = "context"
	DIFF_LINE_ADD     = "add"
	DIFF_LINE_DEL     = "delete"
	DIFF_LINE_SECTION = "section"
)
View Source
const BRANCH_PREFIX = "refs/heads/"
View Source
const DEFAULT_TIMEOUT = 60 * time.Second
View Source
const INIT_COMMIT_ID = "0000000000000000000000000000000000000000"
View Source
const REMOTE_PREFIX = "refs/remotes/"
View Source
const TAG_PREFIX = "refs/tags/"

Variables

View Source
var (
	// Debug enables verbose logging on everything.
	// This should be false in case Gogs starts in SSH mode.
	Debug  = false
	Prefix = "[git-module] "
)
View Source
var (
	ErrNotSupportType      = errors.New("not support path type")
	ErrNotSupportAction    = errors.New("not support action")
	ErrFileAlreadyExists   = errors.New("a file with the same name already exists")
	ErrFolderAlreadyExists = errors.New("a folder with the same name already exists")
)
View Source
var DefaultCommitsPageSize = 30
View Source
var (
	ERROR_PATH_NOT_FOUND = errors.New("路径不存在")
)
View Source
var Setting = struct {
	MaxGitDiffLines          int
	MaxGitDiffLineCharacters int
	MaxGitDiffFiles          int
	MaxGitDiffSize           int
	ContextLineCount         int
	RepoStatsCache           Cache
	RepoSubmoduleCache       Cache
	PathCommitCache          Cache
	CommitCache              Cache
	ObjectSizeCache          Cache
}{
	MaxGitDiffLines:          200,
	MaxGitDiffLineCharacters: 1500,
	MaxGitDiffFiles:          100,
	MaxGitDiffSize:           5000,
	ContextLineCount:         3,
	RepoStatsCache:           NewMemCache(1000, "Repo-"),
	RepoSubmoduleCache:       NewMemCache(1000, "Repo-Submodule-"),
	PathCommitCache:          NewMemCache(5000, "path_commit_"),
	CommitCache:              NewMemCache(5000, "commit_"),
	ObjectSizeCache:          NewMemCache(10000, "object_size_"),
}

Functions

func AddChanges

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

AddAllChanges marks local changes to be ready for commit.

func BinVersion

func BinVersion() (string, error)

Version returns current Git version from shell.

func ButtonContextLineCount

func ButtonContextLineCount(lines []*DiffLine) int

func CheckRemoteHttpRepo

func CheckRemoteHttpRepo(repoUrl string, username string, password string) error

func Checkout

func Checkout(repoPath string, opts CheckoutOptions) error

Checkout checkouts a branch

func CommitChanges

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

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

CommitsCount returns number of total commits of until given revision.

func Fsck

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

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

func GetLatestCommitDate

func GetLatestCommitDate(repoPath, branch string) (time.Time, error)

GetLatestCommitDate returns the date of latest commit of repository. If branch is empty, it returns the latest commit across all branches.

func GetMirrorRepoUrl

func GetMirrorRepoUrl(repoPath string) string

func GetUrlWithBasicAuth

func GetUrlWithBasicAuth(repoUrl string, username string, password string) (string, error)

func InitExternalRepository

func InitExternalRepository(repoPath string, url string, username string, password string) error

InitExternalRepository 初始化外部托管仓库

func InitRepository

func InitRepository(repoPath string, bare bool) error

InitRepository initializes a new Git repository.

func IsBranchExist

func IsBranchExist(repoPath, name string) bool

IsBranchExist returns true if given branch exists in the repository.

func IsErrExecTimeout

func IsErrExecTimeout(err error) bool

func IsErrNoMergeBase

func IsErrNoMergeBase(err error) bool

func IsErrNotExist

func IsErrNotExist(err error) bool

func IsErrUnsupportedVersion

func IsErrUnsupportedVersion(err error) bool

func IsReferenceExist

func IsReferenceExist(repoPath, name string) bool

IsReferenceExist returns true if given reference exists in the repository.

func IsTagExist

func IsTagExist(repoPath, name string) bool

IsTagExist returns true if given tag exists in the repository.

func MoveFile

func MoveFile(repoPath, oldTreeName, newTreeName string) error

MoveFile moves a file to another file or directory.

func PushExternalRepository

func PushExternalRepository(repoPath string) error

PushExternalRepository 推送到外部仓库

func RefEndName

func RefEndName(refStr string) string

func RemoveAuthInfo

func RemoveAuthInfo(input string, originUrl string) string

func SyncExternalRepository

func SyncExternalRepository(repoPath string) error

SyncExternalRepository 同步外部仓库

func ToStr

func ToStr(value interface{}, args ...int) (s string)

Convert any type to string.

func UnescapeChars

func UnescapeChars(in []byte) []byte

UnescapeChars reverses escaped characters.

func UpdateExternalRepository

func UpdateExternalRepository(repoPath string, url string, username string, password string) error

UpdateExternalRepository 更新远程仓库配置

func Version

func Version() string

Types

type AtomicInt

type AtomicInt int64

An AtomicInt is an int64 to be accessed atomically.

func (*AtomicInt) Add

func (i *AtomicInt) Add(n int64)

Add atomically adds n to i.

func (*AtomicInt) Get

func (i *AtomicInt) Get() int64

Get atomically gets the value of i.

type Blame

type Blame struct {
	StartLineNo int     `json:"startLineNo"`
	EndLineNo   int     `json:"endLineNo"`
	Commit      *Commit `json:"commit"`
}

type Blob

type Blob struct {
	*TreeEntry
	// contains filtered or unexported fields
}

Blob represents a Git object.

func (*Blob) Data

func (b *Blob) Data() (io.Reader, error)

Data gets content of blob all at once and wrap it as io.Reader. This can be very slow and memory consuming for huge content.

func (*Blob) DataPipeline

func (b *Blob) DataPipeline(stdout, stderr io.Writer) error

type Branch

type Branch struct {
	Id        string  `json:"id"`
	Name      string  `json:"name"`
	Commit    *Commit `json:"commit"`
	IsDefault bool    `json:"isDefault"`
	IsProtect bool    `json:"isProtect"`
	IsMerged  bool    `json:"isMerged"` // 是否已合并到默认分支
}

Branch represents a Git branch.

type Branches

type Branches []*Branch

func (Branches) Len

func (branches Branches) Len() int

func (Branches) Less

func (branches Branches) Less(i, j int) (less bool)

func (Branches) Swap

func (branches Branches) Swap(i, j int)

type Cache

type Cache interface {
	Set(key string, value interface{}) error
	Get(key string, outValue interface{}) error
	Delete(key string) error
	Status() *CacheStatus
}

this is a interface which defines some common functions

type CacheStatus

type CacheStatus struct {
	Gets        int64
	Hits        int64
	MaxItemSize int
	CurrentSize int
}

type CheckoutOptions

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

type CloneRepoOptions

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

type Command

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

Command represents a command with its subcommands or arguments.

func NewCommand

func NewCommand(args ...string) *Command

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

func (*Command) AddArguments

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

AddArguments adds new argument(s) to the command.

func (*Command) AddEnvs

func (c *Command) AddEnvs(envs ...string) *Command

AddEnvs adds new environment variables to the command.

func (*Command) Run

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

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

func (*Command) RunInDir

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

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

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

func (*Command) RunInDirPipeline

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

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) RunInDirTimeoutPipeline

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) RunTimeout

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

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

func (*Command) String

func (c *Command) String() string

type Commit

type Commit struct {
	Tree
	ID            string     `json:"id"`
	Author        *Signature `json:"author"`
	Committer     *Signature `json:"committer"`
	CommitMessage string     `json:"commitMessage"`
	TreeSha       string     `json:"-"`
	Parents       []string   `json:"parents"`

	ParentDirPath string `json:"parentDirPath"`
	// contains filtered or unexported fields
}

Commit represents a git commit.

func NewCommitFromLibgit2

func NewCommitFromLibgit2(repo *Repository, rawCommit *git.Commit) *Commit

func (*Commit) CommitsBefore

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

func (*Commit) CommitsBeforeLimit

func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error)

func (*Commit) CommitsBeforeUntil

func (c *Commit) CommitsBeforeUntil(commitID string) ([]*Commit, error)

func (*Commit) CommitsByRange

func (c *Commit) CommitsByRange(page int) ([]*Commit, error)

func (*Commit) CommitsByRangeSize

func (c *Commit) CommitsByRangeSize(page, size int) ([]*Commit, error)

func (*Commit) CommitsCount

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

func (*Commit) FileStatus

func (c *Commit) FileStatus() (*CommitFileStatus, error)

FileStatus returns file status of commit.

func (*Commit) GetCommitByPath

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

GetCommitByPath return the commit of relative path object.

func (*Commit) GetFilesChangedSinceCommit

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

func (*Commit) GetSubModule

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

func (*Commit) GetSubModules

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

func (*Commit) Git2Oid

func (c *Commit) Git2Oid() *git.Oid

func (*Commit) Message

func (c *Commit) Message() string

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

func (*Commit) Parent

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

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

func (*Commit) ParentCount

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

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

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

func (*Commit) SearchCommits

func (c *Commit) SearchCommits(keyword string) ([]*Commit, error)

func (*Commit) Summary

func (c *Commit) Summary() string

Summary returns first line of commit message.

type CommitChangesOptions

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

type CommitFileStatus

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

CommitFileStatus represents status of files in a commit.

func GetCommitFileStatus

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

GetCommitFileStatus returns file status of commit in given repository.

func NewCommitFileStatus

func NewCommitFileStatus() *CommitFileStatus

type CountObject

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

CountObject represents disk usage report of Git repository.

type CreateCommit

type CreateCommit struct {
	Signature *Signature        `json:"-"`
	Message   string            `json:"message"`
	Actions   []*EditActionItem `json:"actions"`
	Branch    string            `json:"branch"`
}

func (*CreateCommit) Validate

func (req *CreateCommit) Validate() error

type Diff

type Diff struct {
	FilesChanged  int         `json:"filesChanged"`
	TotalAddition int         `json:"totalAddition"`
	TotalDeletion int         `json:"totalDeletion"`
	Files         []*DiffFile `json:"files"`
	IsFinish      bool        `json:"isFinish"`
}

Diff contains all information of a specific diff output.

func (*Diff) NumFiles

func (diff *Diff) NumFiles() int

type DiffFile

type DiffFile struct {
	Name        string         `json:"name"`
	OldName     string         `json:"oldName"`
	Index       string         `json:"index"` // 40-byte SHA, Changed/New: new SHA; Deleted: old SHA
	Addition    int            `json:"addition"`
	Deletion    int            `json:"deletion"`
	Type        DiffFileType   `json:"type"`
	IsBin       bool           `json:"isBin"`
	IsSubmodule bool           `json:"isSubmodule"`
	Sections    []*DiffSection `json:"sections"`
	IsFinish    bool           `json:"-"`
	HasMore     bool           `json:"hasMore"`
	OldMode     string         `json:"oldMode"`
	NewMode     string         `json:"newMode"`
}

DiffFile represents a file in diff.

func (*DiffFile) NumSections

func (diffFile *DiffFile) NumSections() int

type DiffFileType

type DiffFileType string

DiffFileType represents the file status in diff.

const (
	DIFF_FILE_ADD      DiffFileType = "add"
	DIFF_FILE_MODIFIED DiffFileType = "modified"
	DIFF_FILE_DEL      DiffFileType = "delete"
	DIFF_FILE_RENAME   DiffFileType = "rename"
)

type DiffLine

type DiffLine struct {
	OldLineNo int          `json:"oldLineNo"`
	NewLineNo int          `json:"newLineNo"`
	Type      DiffLineType `json:"type"`
	Content   string       `json:"content"`
}

DiffLine represents a line in diff.

type DiffLineType

type DiffLineType string

DiffLineType represents the type of a line in diff.

type DiffOptions

type DiffOptions struct {
	Pathspec              []string //指定路径格式diff
	ShowAll               bool     //是否全量返回
	MaxDiffLineCharacters int      //最大diff一行内容,如果设置ShowAll忽略此值
	MaxDiffLines          int
	MaxDiffFiles          int
	ContextLineCount      int
	MaxSize               int
}

func NewDefaultDiffOptions

func NewDefaultDiffOptions() *DiffOptions

func (*DiffOptions) SetShowAll

func (d *DiffOptions) SetShowAll(showAll bool) *DiffOptions

type DiffSection

type DiffSection struct {
	Lines []*DiffLine `json:"lines"`
}

DiffSection represents a section in diff.

func (*DiffSection) Line

func (diffSection *DiffSection) Line(lineType DiffLineType, idx int) *DiffLine

Line returns a specific line by type (add or del) and file line number from a section.

type EditAction

type EditAction string
const (
	EDIT_ACTION_ADD    EditAction = "add"
	EDIT_ACTION_UPDATE EditAction = "update"
	EDIT_ACTION_DELETE EditAction = "delete"
	EDIT_ACTION_MOVE   EditAction = "move"
)

type EditActionItem

type EditActionItem struct {
	Action   EditAction   `json:"action"`
	Content  string       `json:"content"`
	Path     string       `json:"path"`
	PathType EditPathType `json:"pathType"`
}

type EditPathType

type EditPathType string
const (
	EDIT_PATH_TYPE_TREE EditPathType = "tree"
	EDIT_PATH_TYPE_BLOB EditPathType = "blob"
)

type Entries

type Entries []*TreeEntry

func (Entries) GetCommitsInfo

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

GetCommitsInfo takes advantages of concurrency to speed up getting information of all commits that are corresponding to these entries. This method will automatically choose the right number of goroutine (concurrency) to use related of the host CPU.

func (Entries) GetCommitsInfoWithCustomConcurrency

func (tes Entries) GetCommitsInfoWithCustomConcurrency(commit *Commit, treePath string, maxConcurrency int) ([][]interface{}, error)

GetCommitsInfoWithCustomConcurrency takes advantages of concurrency to speed up getting information of all commits that are corresponding to these entries. If the given maxConcurrency is negative or equal to zero: the right number of goroutine (concurrency) to use will be choosen related of the host CPU.

func (Entries) Len

func (tes Entries) Len() int

func (Entries) Less

func (tes Entries) Less(i, j int) bool

func (Entries) Sort

func (tes Entries) Sort()

func (Entries) Swap

func (tes Entries) Swap(i, j int)

type EntryMode

type EntryMode string
const (
	ENTRY_MODE_BLOB    EntryMode = "0100644"
	ENTRY_MODE_EXEC    EntryMode = "0100755"
	ENTRY_MODE_SYMLINK EntryMode = "0120000"
	ENTRY_MODE_COMMIT  EntryMode = "0160000"
	ENTRY_MODE_TREE    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 ErrExecTimeout

type ErrExecTimeout struct {
	Duration time.Duration
}

func (ErrExecTimeout) Error

func (err ErrExecTimeout) Error() string

type ErrNoMergeBase

type ErrNoMergeBase struct{}

func (ErrNoMergeBase) Error

func (err ErrNoMergeBase) Error() string

type ErrNotExist

type ErrNotExist struct {
	ID      string
	RelPath string
}

func (ErrNotExist) Error

func (err ErrNotExist) Error() string

type ErrUnsupportedVersion

type ErrUnsupportedVersion struct {
	Required string
}

func (ErrUnsupportedVersion) Error

func (err ErrUnsupportedVersion) Error() string

type MemCache

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

MemCache is an LRU cache. It is safe for concurrent access.

func NewMemCache

func NewMemCache(maxItemSize int, prefix string) *MemCache

NewMemCache If maxItemSize is zero, the cache has no limit. if maxItemSize is not zero, when cache's size beyond maxItemSize,start to swap

func (*MemCache) Delete

func (c *MemCache) Delete(key string) error

Delete delete the key

func (*MemCache) Get

func (c *MemCache) Get(key string, out interface{}) error

Get value with key

func (*MemCache) GetCacheMap

func (c *MemCache) GetCacheMap() map[string]interface{}

func (*MemCache) RemoveOldest

func (c *MemCache) RemoveOldest()

RemoveOldest remove the oldest key

func (*MemCache) Set

func (c *MemCache) Set(key string, value interface{}) error

Set a value with key

func (*MemCache) Status

func (c *MemCache) Status() *CacheStatus

Status return the status of cache

type MergeInfo

type MergeInfo struct {
	OurBranch   string
	TheirBranch string
	OurCommit   *Commit
	TheirCommit *Commit
	BaseCommit  *Commit
	BaseTree    *git.Tree
	OurTree     *git.Tree
	TheirTree   *git.Tree
}

type MergeStatusInfo

type MergeStatusInfo struct {
	HasConflict bool   `json:"hasConflict"`
	IsMerged    bool   `json:"isMerged"`
	HasError    bool   `json:"hasError"`
	ErrorMsg    string `json:"errorMsg"`
}

type NetworkOptions

type NetworkOptions struct {
	URL     string
	Timeout time.Duration
}

type ObjectType

type ObjectType string
const (
	OBJECT_COMMIT ObjectType = "commit"
	OBJECT_TREE   ObjectType = "tree"
	OBJECT_BLOB   ObjectType = "blob"
	OBJECT_TAG    ObjectType = "tag"
)

type Repository

type Repository struct {
	ID              int64  `json:"id"`
	ProjectId       int64  `json:"project_id"`
	ProjectName     string `json:"project_name"`
	ApplicationId   int64  `json:"application_id"`
	ApplicationName string `json:"application_name"`
	OrgId           int64  `json:"org_id"`
	OrgName         string `json:"org_name"`
	Url             string `json:"url"`
	Path            string `json:"path"` //相对路径
	Bundle          *bundle.Bundle

	Size     int64   `json:"-"`
	RootPath string  `json:"-"`
	RefName  string  `json:"-"` //需要调用ParseRefAndTreePath才能得到
	TreePath string  `json:"-"` //需要调用ParseRefAndTreePath才能得到
	RefType  string  `json:"-"`
	Commit   *Commit `json:"-"`

	IsLocked   bool `json:"-"`
	IsExternal bool // 是否是外置仓库
	// contains filtered or unexported fields
}

Repository represents a Git repository.

func OpenRepository

func OpenRepository(rootPath string, path string) (*Repository, error)

func OpenRepositoryWithInit

func OpenRepositoryWithInit(rootPath string, repoPath string) (*Repository, error)

func (*Repository) AddRemote

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

AddRemote adds a new remote to repository.

func (*Repository) AutoSetDefaultBranch

func (repo *Repository) AutoSetDefaultBranch() error

AutoSetDefaultBranch 自动选择一个分支作为默认分支,优先选择 master / develop 分支

func (*Repository) BlameFile

func (repo *Repository) BlameFile(commit *Commit, filePath string) ([]*Blame, error)

BlameFile

func (*Repository) CalcRepoSize

func (repo *Repository) CalcRepoSize() (int64, error)

CalcRepoSize returns disk usage report of repository in given path.

func (*Repository) CommitsAfterDate

func (repo *Repository) CommitsAfterDate(date string) ([]*Commit, error)

CommitsAfterDate returns a list of commits which committed after given date. The format of date should be in RFC3339.

func (*Repository) CommitsBetween

func (repo *Repository) CommitsBetween(last *Commit, before *Commit) ([]*Commit, error)

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

func (*Repository) CommitsBetweenDuration

func (repo *Repository) CommitsBetweenDuration(revision, start, end string) ([]*Commit, error)

func (*Repository) CommitsBetweenIDs

func (repo *Repository) CommitsBetweenIDs(last, before string) ([]*Commit, error)

func (*Repository) CommitsBetweenLimit

func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, skip int, limit int) ([]*Commit, error)

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

func (*Repository) CommitsByFileAndRangeSize

func (repo *Repository) CommitsByFileAndRangeSize(revision, file string, searchText string, page, size int) ([]*Commit, error)

func (*Repository) CommitsByRange

func (repo *Repository) CommitsByRange(revision string, page int) ([]*Commit, error)

func (*Repository) CommitsByRangeSize

func (repo *Repository) CommitsByRangeSize(id string, page, size int) ([]*Commit, error)

func (*Repository) CommitsCountBetween

func (repo *Repository) CommitsCountBetween(last *Commit, before *Commit) (int, error)

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

func (*Repository) CreateBranch

func (repo *Repository) CreateBranch(name string, ref string) (*Commit, error)

CreateBranch create a branch from repository.

func (*Repository) CreateCommit

func (repo *Repository) CreateCommit(request *CreateCommit, etcdClient *clientv3.Client) (*Commit, error)

func (*Repository) CreateTag

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

CreateTag 创建附注tag

func (*Repository) DeleteBranch

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

DeleteBranch deletes a branch from repository.

func (*Repository) DeleteTag

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

DeleteTag deletes a tag from the repository

func (*Repository) DiskPath

func (repo *Repository) DiskPath() string

func (*Repository) FileCommitsCount

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

func (*Repository) FilesCountBetween

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

func (*Repository) FillSubmoduleInfo

func (repo *Repository) FillSubmoduleInfo(commitID string, entries ...*TreeEntry)

func (*Repository) FillTreeEntriesCommitInfo

func (repo *Repository) FillTreeEntriesCommitInfo(id string, replath string, entries ...*TreeEntry) error

func (*Repository) FullName

func (repo *Repository) FullName() string

func (*Repository) GetBranchCommit

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

GetBranchCommit returns the last commit of given branch.

func (*Repository) GetBranchCommitID

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

GetBranchCommitID returns last commit ID string of given branch.

func (*Repository) GetBranches

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

GetBranches 获取分支名列表

func (*Repository) GetCommit

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

func (*Repository) GetCommitByAny

func (repo *Repository) GetCommitByAny(ref string) (*Commit, error)

func (*Repository) GetCommitByPath

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

GetCommitByPath returns the last commit of relative path.

func (*Repository) GetDefaultBranch

func (repo *Repository) GetDefaultBranch() (string, error)

GetDefaultBranch 获取默认分支

func (*Repository) GetDetailBranches

func (repo *Repository) GetDetailBranches(onlyBranchNames bool, findBranch string) ([]*Branch, error)

GetDetailBranches 获取分支详情列表

func (*Repository) GetDetailTags

func (repo *Repository) GetDetailTags(findTags string) ([]*Tag, error)

func (*Repository) GetDiff

func (repo *Repository) GetDiff(newCommit *Commit, oldCommit *Commit) (*Diff, error)

func (*Repository) GetDiffFile

func (repo *Repository) GetDiffFile(newCommit *Commit, oldCommit *Commit, oldPath, newPath string) (*DiffFile, error)

func (*Repository) GetDiffWithOptions

func (repo *Repository) GetDiffWithOptions(newCommit *Commit, oldCommit *Commit, diffOptions *DiffOptions) (*Diff, error)

func (*Repository) GetMergeBase

func (repo *Repository) GetMergeBase(last *Commit, before *Commit) (*Commit, error)

func (*Repository) GetMergeStatus

func (repo *Repository) GetMergeStatus(ourBranch string, theirBranch string) (*MergeStatusInfo, error)

func (*Repository) GetMergedBranches

func (repo *Repository) GetMergedBranches(baseBranch string) (map[string]int, error)

func (*Repository) GetParsedTreeEntry

func (repo *Repository) GetParsedTreeEntry() (*TreeEntry, error)

func (*Repository) GetRawRepo

func (repo *Repository) GetRawRepo() (*git.Repository, error)

func (*Repository) GetRepoStats

func (repo *Repository) GetRepoStats(path string) (map[string]interface{}, error)

func (*Repository) GetSubmodules

func (repo *Repository) GetSubmodules(commitID string) (map[string]string, error)

func (*Repository) GetTag

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

GetTag returns a Git tag by given name.

func (*Repository) GetTagCommit

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

GetTagCommit returns the commit of given tag.

func (*Repository) GetTags

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

GetTags returns all tags of the repository.

func (*Repository) GetTree

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

Find the tree object in the repository.

func (*Repository) GetTreeEntryByPath

func (repo *Repository) GetTreeEntryByPath(idStr string, path string) (*TreeEntry, error)

Find the tree object in the repository.

func (*Repository) InfoPacksPath

func (r *Repository) InfoPacksPath() string

InfoPacksPath for Repository

func (*Repository) IsBranchExist

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

func (*Repository) IsProtectBranch

func (repo *Repository) IsProtectBranch(branch string) bool

func (*Repository) IsProtectBranchWithRules

func (repo *Repository) IsProtectBranchWithRules(branch string, rules []*apistructs.BranchRule) bool

func (*Repository) IsTagExist

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

func (*Repository) LooseObjectPath

func (r *Repository) LooseObjectPath(prefix string, suffix string) string

LooseObjectPath for Repository

func (*Repository) Merge

func (repo *Repository) Merge(ourBranch string, theirBranch string, signature *Signature, message string) (*Commit, error)

func (*Repository) PackIdxPath

func (r *Repository) PackIdxPath(pack string) string

PackIdxPath for Repository

func (*Repository) ParseRefAndTreePath

func (repo *Repository) ParseRefAndTreePath(path string) error

func (*Repository) RemoveRemote

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

RemoveRemote removes a remote from repository.

func (*Repository) Root

func (repo *Repository) Root() string

func (*Repository) SetDefaultBranch

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

SetDefaultBranch 设置默认分支

type Signature

type Signature struct {
	Email string    `json:"email"`
	Name  string    `json:"name"`
	When  time.Time `json:"when"`
}

Signature represents the Author or Committer information.

type StrTo

type StrTo string

Convert string to specify type.

func (StrTo) Exist

func (f StrTo) Exist() bool

func (StrTo) Float64

func (f StrTo) Float64() (float64, error)

func (StrTo) Int

func (f StrTo) Int() (int, error)

func (StrTo) Int64

func (f StrTo) Int64() (int64, error)

func (StrTo) MustFloat64

func (f StrTo) MustFloat64() float64

func (StrTo) MustInt

func (f StrTo) MustInt() int

func (StrTo) MustInt64

func (f StrTo) MustInt64() int64

func (StrTo) MustUint8

func (f StrTo) MustUint8() uint8

func (StrTo) String

func (f StrTo) String() string

func (StrTo) Uint8

func (f StrTo) Uint8() (uint8, error)

type SubModule

type SubModule struct {
	Name string
	URL  string
}

type SubModuleData

type SubModuleData struct {
	UrlMap map[string]string
	Exist  bool
}

type SubModuleFile

type SubModuleFile struct {
	*Commit
	// contains filtered or unexported fields
}

SubModuleFile represents a file with submodule type.

func NewSubModuleFile

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

func (*SubModuleFile) RefID

func (sf *SubModuleFile) RefID() string

RefID returns reference ID.

func (*SubModuleFile) RefURL

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

RefURL guesses and returns reference URL.

type Tag

type Tag struct {
	Name string `json:"name"`
	ID   string `json:"id"`

	Object  string     `json:"object"` // The id of this commit object
	Type    string     `json:"-"`
	Tagger  *Signature `json:"tagger"`
	Message string     `json:"message"`
	// contains filtered or unexported fields
}

Tag represents a Git tag.

func (*Tag) Commit

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

type Tree

type Tree struct {
	ID   string      `json:"id"`
	Repo *Repository `json:"-"`
	// contains filtered or unexported fields
}

Tree represents a flat directory listing.

func (*Tree) GetBlobByPath

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

func (*Tree) GetTreeEntryByPath

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

func (*Tree) ListEntries

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

ListEntries returns all entries of current tree.

func (*Tree) Search

func (t *Tree) Search(depth int64, pattern string, ctx context.Context) (Entries, error)

type TreeEntry

type TreeEntry struct {
	ID      string     `json:"id"`
	Type    ObjectType `json:"type"`
	Url     string     `json:"url,omitempty"`
	Name    string     `json:"name"`
	Mode    EntryMode  `json:"mode"`
	PtrTree *Tree      `json:"-"`

	Commit    *Commit `json:"commit"`
	EntrySize int64   `json:"size"`
	// contains filtered or unexported fields
}

func (*TreeEntry) Blob

func (te *TreeEntry) Blob() *Blob

func (*TreeEntry) IsDir

func (te *TreeEntry) IsDir() bool
func (te *TreeEntry) IsLink() bool

func (*TreeEntry) IsSubModule

func (te *TreeEntry) IsSubModule() bool

func (*TreeEntry) ListEntries

func (te *TreeEntry) ListEntries() (Entries, error)

func (*TreeEntry) Size

func (te *TreeEntry) Size() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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