Documentation ¶
Index ¶
- Constants
- Variables
- func AddChanges(repoPath string, all bool, files ...string) error
- func BinVersion() (string, error)
- func ButtonContextLineCount(lines []*DiffLine) int
- func CheckRemoteHttpRepo(repoUrl string, username string, password string) error
- func Checkout(repoPath string, opts CheckoutOptions) error
- func CommitChanges(repoPath string, opts CommitChangesOptions) error
- func CommitsCount(repoPath, revision string) (int64, error)
- func Fsck(repoPath string, timeout time.Duration, args ...string) error
- func GetLatestCommitDate(repoPath, branch string) (time.Time, error)
- func GetMirrorRepoUrl(repoPath string) string
- func GetUrlWithBasicAuth(repoUrl string, username string, password string) (string, error)
- func InitExternalRepository(repoPath string, url string, username string, password string) error
- func InitRepository(repoPath string, bare bool) error
- func IsBranchExist(repoPath, name string) bool
- func IsErrExecTimeout(err error) bool
- func IsErrNoMergeBase(err error) bool
- func IsErrNotExist(err error) bool
- func IsErrUnsupportedVersion(err error) bool
- func IsReferenceExist(repoPath, name string) bool
- func IsTagExist(repoPath, name string) bool
- func MoveFile(repoPath, oldTreeName, newTreeName string) error
- func PushExternalRepository(repoPath string) error
- func RefEndName(refStr string) string
- func RemoveAuthInfo(input string, originUrl string) string
- func SyncExternalRepository(repoPath string) error
- func ToStr(value interface{}, args ...int) (s string)
- func UnescapeChars(in []byte) []byte
- func UpdateExternalRepository(repoPath string, url string, username string, password string) error
- func Version() string
- type AtomicInt
- type Blame
- type Blob
- type Branch
- type Branches
- type Cache
- type CacheStatus
- type CheckoutOptions
- type CloneRepoOptions
- type Command
- func (c *Command) AddArguments(args ...string) *Command
- func (c *Command) AddEnvs(envs ...string) *Command
- func (c *Command) Run() (string, error)
- func (c *Command) RunInDir(dir string) (string, error)
- func (c *Command) RunInDirBytes(dir string) ([]byte, error)
- func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error
- func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error)
- func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error
- func (c *Command) RunTimeout(timeout time.Duration) (string, error)
- func (c *Command) String() string
- type Commit
- func (c *Commit) CommitsBefore() (*list.List, error)
- func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error)
- func (c *Commit) CommitsBeforeUntil(commitID string) ([]*Commit, error)
- func (c *Commit) CommitsByRange(page int) ([]*Commit, error)
- func (c *Commit) CommitsByRangeSize(page, size int) ([]*Commit, error)
- func (c *Commit) CommitsCount() (int64, error)
- func (c *Commit) FileStatus() (*CommitFileStatus, error)
- func (c *Commit) GetCommitByPath(relpath string) (*Commit, error)
- func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error)
- func (c *Commit) GetSubModule(entryname string) (*SubModule, error)
- func (c *Commit) GetSubModules() (*objectCache, error)
- func (c *Commit) Git2Oid() *git.Oid
- func (c *Commit) Message() string
- func (c *Commit) Parent(n int) (*Commit, error)
- func (c *Commit) ParentCount() int
- func (c *Commit) ParentID(n int) (string, error)
- func (c *Commit) SearchCommits(keyword string) ([]*Commit, error)
- func (c *Commit) Summary() string
- type CommitChangesOptions
- type CommitFileStatus
- type CountObject
- type CreateCommit
- type Diff
- type DiffFile
- type DiffFileType
- type DiffLine
- type DiffLineType
- type DiffOptions
- type DiffSection
- type EditAction
- type EditActionItem
- type EditPathType
- type Entries
- func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interface{}, error)
- func (tes Entries) GetCommitsInfoWithCustomConcurrency(commit *Commit, treePath string, maxConcurrency int) ([][]interface{}, error)
- func (tes Entries) Len() int
- func (tes Entries) Less(i, j int) bool
- func (tes Entries) Sort()
- func (tes Entries) Swap(i, j int)
- type EntryMode
- type ErrExecTimeout
- type ErrNoMergeBase
- type ErrNotExist
- type ErrUnsupportedVersion
- type MemCache
- type MergeInfo
- type MergeStatusInfo
- type NetworkOptions
- type ObjectType
- type Repository
- func (repo *Repository) AddRemote(name, url string, fetch bool) error
- func (repo *Repository) AutoSetDefaultBranch() error
- func (repo *Repository) BlameFile(commit *Commit, filePath string) ([]*Blame, error)
- func (repo *Repository) CalcRepoSize() (int64, error)
- func (repo *Repository) CommitsAfterDate(date string) ([]*Commit, error)
- func (repo *Repository) CommitsBetween(last *Commit, before *Commit) ([]*Commit, error)
- func (repo *Repository) CommitsBetweenDuration(revision, start, end string) ([]*Commit, error)
- func (repo *Repository) CommitsBetweenIDs(last, before string) ([]*Commit, error)
- func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, skip int, limit int) ([]*Commit, error)
- func (repo *Repository) CommitsByFileAndRangeSize(revision, file string, searchText string, page, size int) ([]*Commit, error)
- func (repo *Repository) CommitsByRange(revision string, page int) ([]*Commit, error)
- func (repo *Repository) CommitsByRangeSize(id string, page, size int) ([]*Commit, error)
- func (repo *Repository) CommitsCountBetween(last *Commit, before *Commit) (int, error)
- func (repo *Repository) CreateBranch(name string, ref string) (*Commit, error)
- func (repo *Repository) CreateCommit(request *CreateCommit, etcdClient *clientv3.Client) (*Commit, error)
- func (repo *Repository) CreateTag(name, revision string, signature *Signature, message string) error
- func (repo *Repository) DeleteBranch(name string) error
- func (repo *Repository) DeleteTag(name string) error
- func (repo *Repository) DiskPath() string
- func (repo *Repository) FileCommitsCount(revision, file string) (int64, error)
- func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error)
- func (repo *Repository) FillSubmoduleInfo(commitID string, entries ...*TreeEntry)
- func (repo *Repository) FillTreeEntriesCommitInfo(id string, replath string, entries ...*TreeEntry) error
- func (repo *Repository) FullName() string
- func (repo *Repository) GetBranchCommit(name string) (*Commit, error)
- func (repo *Repository) GetBranchCommitID(name string) (string, error)
- func (repo *Repository) GetBranches() ([]string, error)
- func (repo *Repository) GetCommit(commitId string) (*Commit, error)
- func (repo *Repository) GetCommitByAny(ref string) (*Commit, error)
- func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error)
- func (repo *Repository) GetDefaultBranch() (string, error)
- func (repo *Repository) GetDetailBranches(onlyBranchNames bool, findBranch string) ([]*Branch, error)
- func (repo *Repository) GetDetailTags(findTags string) ([]*Tag, error)
- func (repo *Repository) GetDiff(newCommit *Commit, oldCommit *Commit) (*Diff, error)
- func (repo *Repository) GetDiffFile(newCommit *Commit, oldCommit *Commit, oldPath, newPath string) (*DiffFile, error)
- func (repo *Repository) GetDiffWithOptions(newCommit *Commit, oldCommit *Commit, diffOptions *DiffOptions) (*Diff, error)
- func (repo *Repository) GetMergeBase(last *Commit, before *Commit) (*Commit, error)
- func (repo *Repository) GetMergeStatus(ourBranch string, theirBranch string) (*MergeStatusInfo, error)
- func (repo *Repository) GetMergedBranches(baseBranch string) (map[string]int, error)
- func (repo *Repository) GetParsedTreeEntry() (*TreeEntry, error)
- func (repo *Repository) GetRawRepo() (*git.Repository, error)
- func (repo *Repository) GetRepoStats(path string) (map[string]interface{}, error)
- func (repo *Repository) GetSubmodules(commitID string) (map[string]string, error)
- func (repo *Repository) GetTag(name string) (*Tag, error)
- func (repo *Repository) GetTagCommit(name string) (*Commit, error)
- func (repo *Repository) GetTags() ([]string, error)
- func (repo *Repository) GetTree(idStr string) (*Tree, error)
- func (repo *Repository) GetTreeEntryByPath(idStr string, path string) (*TreeEntry, error)
- func (r *Repository) InfoPacksPath() string
- func (repo *Repository) IsBranchExist(name string) bool
- func (repo *Repository) IsProtectBranch(branch string) bool
- func (repo *Repository) IsProtectBranchWithRules(branch string, rules []*apistructs.BranchRule) bool
- func (repo *Repository) IsTagExist(name string) bool
- func (r *Repository) LooseObjectPath(prefix string, suffix string) string
- func (repo *Repository) Merge(ourBranch string, theirBranch string, signature *Signature, message string) (*Commit, error)
- func (r *Repository) PackIdxPath(pack string) string
- func (repo *Repository) ParseRefAndTreePath(path string) error
- func (repo *Repository) RemoveRemote(name string) error
- func (repo *Repository) Root() string
- func (repo *Repository) SetDefaultBranch(branch string) error
- type Signature
- type StrTo
- func (f StrTo) Exist() bool
- func (f StrTo) Float64() (float64, error)
- func (f StrTo) Int() (int, error)
- func (f StrTo) Int64() (int64, error)
- func (f StrTo) MustFloat64() float64
- func (f StrTo) MustInt() int
- func (f StrTo) MustInt64() int64
- func (f StrTo) MustUint8() uint8
- func (f StrTo) String() string
- func (f StrTo) Uint8() (uint8, error)
- type SubModule
- type SubModuleData
- type SubModuleFile
- type Tag
- type Tree
- type TreeEntry
Constants ¶
const ( REF_TYPE_BRANCH = "branch" REF_TYPE_TAG = "tag" REF_TYPE_COMMIT = "commit" REF_TYPE_TREE = "tree" )
const ( DIFF_LINE_CONTEXT = "context" DIFF_LINE_ADD = "add" DIFF_LINE_DEL = "delete" DIFF_LINE_SECTION = "section" )
const BRANCH_PREFIX = "refs/heads/"
const DEFAULT_TIMEOUT = 60 * time.Second
const INIT_COMMIT_ID = "0000000000000000000000000000000000000000"
const REMOTE_PREFIX = "refs/remotes/"
const TAG_PREFIX = "refs/tags/"
Variables ¶
var ( // Debug enables verbose logging on everything. // This should be false in case Gogs starts in SSH mode. Debug = false Prefix = "[git-module] " )
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") )
var DefaultCommitsPageSize = 30
var (
ERROR_PATH_NOT_FOUND = errors.New("路径不存在")
)
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 ¶
AddAllChanges marks local changes to be ready for commit.
func ButtonContextLineCount ¶
func CheckRemoteHttpRepo ¶
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 ¶
CommitsCount returns number of total commits of until given revision.
func GetLatestCommitDate ¶
GetLatestCommitDate returns the date of latest commit of repository. If branch is empty, it returns the latest commit across all branches.
func GetMirrorRepoUrl ¶
func GetUrlWithBasicAuth ¶
func InitExternalRepository ¶
InitExternalRepository 初始化外部托管仓库
func InitRepository ¶
InitRepository initializes a new Git repository.
func IsBranchExist ¶
IsBranchExist returns true if given branch exists in the repository.
func IsErrExecTimeout ¶
func IsErrNoMergeBase ¶
func IsErrNotExist ¶
func IsErrUnsupportedVersion ¶
func IsReferenceExist ¶
IsReferenceExist returns true if given reference exists in the repository.
func IsTagExist ¶
IsTagExist returns true if given tag exists in the repository.
func PushExternalRepository ¶
PushExternalRepository 推送到外部仓库
func RefEndName ¶
func RemoveAuthInfo ¶
func SyncExternalRepository ¶
SyncExternalRepository 同步外部仓库
func UnescapeChars ¶
UnescapeChars reverses escaped characters.
func UpdateExternalRepository ¶
UpdateExternalRepository 更新远程仓库配置
Types ¶
type Blob ¶
type Blob struct { *TreeEntry // contains filtered or unexported fields }
Blob represents a Git object.
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 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 CheckoutOptions ¶
type CloneRepoOptions ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a command with its subcommands or arguments.
func NewCommand ¶
NewCommand creates and returns a new Git Command based on given command and arguments.
func (*Command) AddArguments ¶
AddArguments adds new argument(s) to the command.
func (*Command) Run ¶
Run executes the command in defualt working directory and returns stdout in string and error (combined with stderr).
func (*Command) RunInDir ¶
RunInDir executes the command in given directory and returns stdout in string and error (combined with stderr).
func (*Command) RunInDirBytes ¶
RunInDir executes the command in given directory and returns stdout in []byte and error (combined with stderr).
func (*Command) RunInDirPipeline ¶
RunInDirPipeline executes the command in given directory, it pipes stdout and stderr to given io.Writer.
func (*Command) RunInDirTimeout ¶
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 ¶
RunTimeout executes the command in defualt working directory with given timeout, and returns stdout in string and error (combined with stderr).
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) CommitsBeforeUntil ¶
func (*Commit) CommitsByRangeSize ¶
func (*Commit) CommitsCount ¶
func (*Commit) FileStatus ¶
func (c *Commit) FileStatus() (*CommitFileStatus, error)
FileStatus returns file status of commit.
func (*Commit) GetCommitByPath ¶
GetCommitByPath return the commit of relative path object.
func (*Commit) GetFilesChangedSinceCommit ¶
func (*Commit) GetSubModules ¶
func (*Commit) Message ¶
Message returns the commit message. Same as retrieving CommitMessage directly.
func (*Commit) ParentCount ¶
ParentCount returns number of Parents of the commit. 0 if this is the root commit, otherwise 1,2, etc.
type CommitChangesOptions ¶
type CommitFileStatus ¶
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.
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 ¶
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 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 ¶
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.
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 ¶
func (ErrExecTimeout) Error ¶
func (err ErrExecTimeout) Error() string
type ErrNoMergeBase ¶
type ErrNoMergeBase struct{}
func (ErrNoMergeBase) Error ¶
func (err ErrNoMergeBase) Error() string
type ErrNotExist ¶
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 ¶
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) GetCacheMap ¶
func (*MemCache) RemoveOldest ¶
func (c *MemCache) RemoveOldest()
RemoveOldest remove the oldest key
func (*MemCache) Status ¶
func (c *MemCache) Status() *CacheStatus
Status return the status of cache
type MergeStatusInfo ¶
type NetworkOptions ¶
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 (*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) 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 (*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) 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 SubModuleData ¶
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
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.
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) GetTreeEntryByPath ¶
func (*Tree) ListEntries ¶
ListEntries returns all entries of current tree.
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) IsSubModule ¶
func (*TreeEntry) ListEntries ¶
Source Files ¶
- blob.go
- cache.go
- command.go
- commit.go
- convert.go
- error.go
- git.go
- repo.go
- repo_blame.go
- repo_branch.go
- repo_commit.go
- repo_diff.go
- repo_edit.go
- repo_merge.go
- repo_object.go
- repo_submodule.go
- repo_tag.go
- repo_tree.go
- setting.go
- signature.go
- submodule.go
- tag.go
- tree.go
- tree_blob.go
- tree_entry.go
- utils.go