Documentation
¶
Index ¶
- func AllCommitsCount(ctx context.Context, repo Repository, hidePRRefs bool, files ...string) (int64, error)
- func CalcRepositorySize(repo Repository) (int64, error)
- func CheckDelegateHooks(_ context.Context, repo Repository) ([]string, error)
- func Clone(ctx context.Context, fromRepo, toRepo Repository, opts git.CloneRepoOptions) error
- func CloneExternalRepo(ctx context.Context, fromRemoteURL string, toRepo Repository, ...) error
- func CloneRepoToLocal(ctx context.Context, fromRepo Repository, toLocalPath string, ...) error
- func CommitsCount(ctx context.Context, repo Repository, opts CommitsCountOptions) (int64, error)
- func CommitsCountBetween(ctx context.Context, repo Repository, start, end string) (int64, error)
- func CommitsCountOfCommit(ctx context.Context, repo Repository, commitID string) (int64, error)
- func CreateArchive(ctx context.Context, repo Repository, format string, target io.Writer, ...) error
- func CreateBranch(ctx context.Context, repo Repository, branch, oldbranchOrCommit string) error
- func CreateBundle(ctx context.Context, repo Repository, commit string, out io.Writer) error
- func CreateDelegateHooks(_ context.Context, repo Repository) (err error)
- func CreateRepoFile(ctx context.Context, repo Repository, relativeFilePath string) (io.WriteCloser, error)
- func DeleteBranch(ctx context.Context, repo Repository, name string, force bool) error
- func DeleteRepository(ctx context.Context, repo Repository) error
- func FileCommitsCount(ctx context.Context, repo Repository, revision, file string) (int64, error)
- func Fsck(ctx context.Context, repo Repository, timeout time.Duration, ...) error
- func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (string, error)
- func GetBranchesByPath(ctx context.Context, repo Repository, skip, limit int) ([]string, int, error)
- func GetDefaultBranch(ctx context.Context, repo Repository) (string, error)
- func GetDiffShortStatByCmdArgs(ctx context.Context, repo Repository, trustedArgs gitcmd.TrustedCmdArgs, ...) (numFiles, totalAdditions, totalDeletions int, err error)
- func GetFullCommitID(ctx context.Context, repo Repository, shortID string) (string, error)
- func GetLatestCommitTime(ctx context.Context, repo Repository) (time.Time, error)
- func GetRepoFS(repo Repository) fs.FS
- func GetReverseRawDiff(ctx context.Context, repo Repository, commitID string, writer io.Writer) error
- func GetSigningKey(ctx context.Context) (*git.SigningKey, *git.Signature)
- func GitConfigAdd(ctx context.Context, repo Repository, key, value string) error
- func GitConfigGet(ctx context.Context, repo Repository, key string) (string, error)
- func GitConfigSet(ctx context.Context, repo Repository, key, value string) error
- func GitRemoteAdd(ctx context.Context, repo Repository, remoteName, remoteURL string, ...) error
- func GitRemoteGetURL(ctx context.Context, repo Repository, remoteName string) (*giturl.GitURL, error)
- func GitRemotePrune(ctx context.Context, repo Repository, remoteName string, timeout time.Duration, ...) error
- func GitRemoteRemove(ctx context.Context, repo Repository, remoteName string) error
- func GitRemoteUpdatePrune(ctx context.Context, repo Repository, remoteName string, timeout time.Duration, ...) error
- func InitRepository(ctx context.Context, repo Repository, objectFormatName string) error
- func IsBranchExist(ctx context.Context, repo Repository, name string) bool
- func IsReferenceExist(ctx context.Context, repo Repository, name string) bool
- func IsRepoDirExist(ctx context.Context, repo Repository, relativeDirPath string) (bool, error)
- func IsRepoFileExist(ctx context.Context, repo Repository, relativeFilePath string) (bool, error)
- func IsRepositoryExist(ctx context.Context, repo Repository) (bool, error)
- func IsTagExist(ctx context.Context, repo Repository, name string) bool
- func LineBlame(ctx context.Context, repo Repository, revision, file string, line uint) (string, error)
- func NewBatch(ctx context.Context, repo Repository) (catfile.Batch, error)
- func OpenRepository(ctx context.Context, repo Repository) (*git.Repository, error)
- func Push(ctx context.Context, fromRepo, toRepo Repository, opts git.PushOptions) error
- func PushFromLocal(ctx context.Context, fromLocalPath string, toRepo Repository, ...) error
- func PushToExternal(ctx context.Context, repo Repository, opts git.PushOptions) error
- func RemoveRef(ctx context.Context, repo Repository, refName string) error
- func RemoveRepoFileOrDir(ctx context.Context, repo Repository, relativeFileOrDirPath string) error
- func RenameBranch(ctx context.Context, repo Repository, from, to string) error
- func RenameRepository(ctx context.Context, repo, newRepo Repository) error
- func RepoGitURL(repo Repository) string
- func RepositoryFromContextOrOpen(ctx context.Context, repo Repository) (*git.Repository, io.Closer, error)
- func RepositoryFromRequestContextOrOpen(ctx reqctx.RequestContext, repo Repository) (*git.Repository, error)
- func RunCmd(ctx context.Context, repo Repository, cmd *gitcmd.Command) error
- func RunCmdBytes(ctx context.Context, repo Repository, cmd *gitcmd.Command) ([]byte, []byte, error)
- func RunCmdString(ctx context.Context, repo Repository, cmd *gitcmd.Command) (string, error)
- func SetDefaultBranch(ctx context.Context, repo Repository, name string) error
- func UpdateRef(ctx context.Context, repo Repository, refName, newCommitID string) error
- func UpdateServerInfo(ctx context.Context, repo Repository) error
- func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error)
- func WriteCommitGraph(ctx context.Context, repo Repository) error
- type BlamePart
- type BlameReader
- type CommitFileStatus
- type CommitsCountOptions
- type DivergeObject
- type RemoteOption
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllCommitsCount ¶
func AllCommitsCount(ctx context.Context, repo Repository, hidePRRefs bool, files ...string) (int64, error)
AllCommitsCount returns count of all commits in repository
func CalcRepositorySize ¶
func CalcRepositorySize(repo Repository) (int64, error)
CalcRepositorySize returns the disk consumption for a given path
func CheckDelegateHooks ¶
func CheckDelegateHooks(_ context.Context, repo Repository) ([]string, error)
CheckDelegateHooks checks the hooks scripts for the repo
func Clone ¶
func Clone(ctx context.Context, fromRepo, toRepo Repository, opts git.CloneRepoOptions) error
func CloneExternalRepo ¶
func CloneExternalRepo(ctx context.Context, fromRemoteURL string, toRepo Repository, opts git.CloneRepoOptions) error
CloneExternalRepo clones an external repository to the managed repository.
func CloneRepoToLocal ¶
func CloneRepoToLocal(ctx context.Context, fromRepo Repository, toLocalPath string, opts git.CloneRepoOptions) error
CloneRepoToLocal clones a managed repository to a local path.
func CommitsCount ¶
func CommitsCount(ctx context.Context, repo Repository, opts CommitsCountOptions) (int64, error)
CommitsCount returns number of total commits of until given revision.
func CommitsCountBetween ¶
CommitsCountBetween return numbers of commits between two commits
func CommitsCountOfCommit ¶
CommitsCountOfCommit returns number of total commits of until current revision.
func CreateArchive ¶
func CreateArchive(ctx context.Context, repo Repository, format string, target io.Writer, usePrefix bool, commitID string) error
CreateArchive create archive content to the target path
func CreateBranch ¶
func CreateBranch(ctx context.Context, repo Repository, branch, oldbranchOrCommit string) error
CreateBranch create a new branch
func CreateBundle ¶
CreateBundle create bundle content to the target path
func CreateDelegateHooks ¶
func CreateDelegateHooks(_ context.Context, repo Repository) (err error)
CreateDelegateHooks creates all the hooks scripts for the repo
func CreateRepoFile ¶
func CreateRepoFile(ctx context.Context, repo Repository, relativeFilePath string) (io.WriteCloser, error)
func DeleteBranch ¶
DeleteBranch delete a branch by name on repository.
func DeleteRepository ¶
func DeleteRepository(ctx context.Context, repo Repository) error
DeleteRepository deletes the repository directory from the disk, it will return nil if the repository does not exist.
func FileCommitsCount ¶
FileCommitsCount return the number of files at a revision
func Fsck ¶
func Fsck(ctx context.Context, repo Repository, timeout time.Duration, args gitcmd.TrustedCmdArgs) error
Fsck verifies the connectivity and validity of the objects in the database
func GetBranchCommitID ¶
func GetBranchesByPath ¶
func GetBranchesByPath(ctx context.Context, repo Repository, skip, limit int) ([]string, int, error)
GetBranchesByPath returns a branch by its path if limit = 0 it will not limit
func GetDefaultBranch ¶
func GetDefaultBranch(ctx context.Context, repo Repository) (string, error)
GetDefaultBranch gets default branch of repository.
func GetDiffShortStatByCmdArgs ¶
func GetDiffShortStatByCmdArgs(ctx context.Context, repo Repository, trustedArgs gitcmd.TrustedCmdArgs, dynamicArgs ...string) (numFiles, totalAdditions, totalDeletions int, err error)
GetDiffShortStatByCmdArgs counts number of changed files, number of additions and deletions TODO: it can be merged with another "GetDiffShortStat" in the future
func GetFullCommitID ¶
func GetLatestCommitTime ¶
GetLatestCommitTime returns time for latest commit in repository (across all branches)
func GetRepoFS ¶
func GetRepoFS(repo Repository) fs.FS
func GetReverseRawDiff ¶
func GetReverseRawDiff(ctx context.Context, repo Repository, commitID string, writer io.Writer) error
GetReverseRawDiff dumps the reverse diff results of repository in given commit ID to io.Writer.
func GitConfigAdd ¶
func GitConfigAdd(ctx context.Context, repo Repository, key, value string) error
GitConfigAdd add a git configuration key to a specific value for the given repository.
func GitConfigGet ¶
func GitConfigSet ¶
func GitConfigSet(ctx context.Context, repo Repository, key, value string) error
GitConfigSet updates a git configuration key to a specific value for the given repository. If the key does not exist, it will be created. If the key exists, it will be updated to the new value.
func GitRemoteAdd ¶
func GitRemoteAdd(ctx context.Context, repo Repository, remoteName, remoteURL string, options ...RemoteOption) error
func GitRemoteGetURL ¶
func GitRemoteGetURL(ctx context.Context, repo Repository, remoteName string) (*giturl.GitURL, error)
GitRemoteGetURL returns the url of a specific remote of the repository.
func GitRemotePrune ¶
func GitRemotePrune(ctx context.Context, repo Repository, remoteName string, timeout time.Duration, stdout, stderr io.Writer) error
GitRemotePrune prunes the remote branches that no longer exist in the remote repository.
func GitRemoteRemove ¶
func GitRemoteRemove(ctx context.Context, repo Repository, remoteName string) error
func GitRemoteUpdatePrune ¶
func GitRemoteUpdatePrune(ctx context.Context, repo Repository, remoteName string, timeout time.Duration, stdout, stderr io.Writer) error
GitRemoteUpdatePrune updates the remote branches and prunes the ones that no longer exist in the remote repository.
func InitRepository ¶
func InitRepository(ctx context.Context, repo Repository, objectFormatName string) error
func IsBranchExist ¶
func IsBranchExist(ctx context.Context, repo Repository, name string) bool
IsBranchExist returns true if given branch exists in the repository.
func IsReferenceExist ¶
func IsReferenceExist(ctx context.Context, repo Repository, name string) bool
IsReferenceExist returns true if given reference exists in the repository.
func IsRepoDirExist ¶
func IsRepoFileExist ¶
func IsRepositoryExist ¶
func IsRepositoryExist(ctx context.Context, repo Repository) (bool, error)
IsRepositoryExist returns true if the repository directory exists in the disk
func IsTagExist ¶
func IsTagExist(ctx context.Context, repo Repository, name string) bool
IsTagExist returns true if given tag exists in the repository.
func LineBlame ¶
func OpenRepository ¶
func OpenRepository(ctx context.Context, repo Repository) (*git.Repository, error)
OpenRepository opens the repository at the given relative path with the provided context.
func Push ¶
func Push(ctx context.Context, fromRepo, toRepo Repository, opts git.PushOptions) error
Push pushes from one managed repository to another managed repository.
func PushFromLocal ¶
func PushFromLocal(ctx context.Context, fromLocalPath string, toRepo Repository, opts git.PushOptions) error
PushFromLocal pushes from a local path to a managed repository.
func PushToExternal ¶
func PushToExternal(ctx context.Context, repo Repository, opts git.PushOptions) error
PushToExternal pushes a managed repository to an external remote.
func RemoveRepoFileOrDir ¶
func RemoveRepoFileOrDir(ctx context.Context, repo Repository, relativeFileOrDirPath string) error
func RenameBranch ¶
func RenameBranch(ctx context.Context, repo Repository, from, to string) error
RenameBranch rename a branch
func RenameRepository ¶
func RenameRepository(ctx context.Context, repo, newRepo Repository) error
RenameRepository renames a repository's name on disk
func RepoGitURL ¶
func RepoGitURL(repo Repository) string
func RepositoryFromContextOrOpen ¶
func RepositoryFromContextOrOpen(ctx context.Context, repo Repository) (*git.Repository, io.Closer, error)
RepositoryFromContextOrOpen attempts to get the repository from the context or just opens it The caller must call "defer gitRepo.Close()"
func RepositoryFromRequestContextOrOpen ¶
func RepositoryFromRequestContextOrOpen(ctx reqctx.RequestContext, repo Repository) (*git.Repository, error)
RepositoryFromRequestContextOrOpen opens the repository at the given relative path in the provided request context. Caller shouldn't close the git repo manually, the git repo will be automatically closed when the request context is done.
func RunCmdBytes ¶
func RunCmdString ¶
func SetDefaultBranch ¶
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error
SetDefaultBranch sets default branch of repository.
func UpdateRef ¶
func UpdateRef(ctx context.Context, repo Repository, refName, newCommitID string) error
func UpdateServerInfo ¶
func UpdateServerInfo(ctx context.Context, repo Repository) error
func WalkReferences ¶
func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error)
WalkReferences walks all the references from the repository
func WriteCommitGraph ¶
func WriteCommitGraph(ctx context.Context, repo Repository) error
Types ¶
type BlamePart ¶
BlamePart represents block of blame - continuous lines with one sha
type BlameReader ¶
type BlameReader struct {
// contains filtered or unexported fields
}
BlameReader returns part of file blame one by one
func CreateBlameReader ¶
func CreateBlameReader(ctx context.Context, objectFormat git.ObjectFormat, repo Repository, commit *git.Commit, file string, bypassBlameIgnore bool) (rd *BlameReader, err error)
CreateBlameReader creates reader for given repository, commit and file
func (*BlameReader) Close ¶
func (r *BlameReader) Close() error
Close BlameReader - don't run NextPart after invoking that
func (*BlameReader) NextPart ¶
func (r *BlameReader) NextPart() (*BlamePart, error)
NextPart returns next part of blame (sequential code lines with the same commit)
func (*BlameReader) UsesIgnoreRevs ¶
func (r *BlameReader) UsesIgnoreRevs() bool
type CommitFileStatus ¶
CommitFileStatus represents status of files in a commit.
func GetCommitFileStatus ¶
func GetCommitFileStatus(ctx context.Context, repo Repository, commitID string) (*CommitFileStatus, error)
GetCommitFileStatus returns file status of commit in given repository.
func NewCommitFileStatus ¶
func NewCommitFileStatus() *CommitFileStatus
NewCommitFileStatus creates a CommitFileStatus
type CommitsCountOptions ¶
type CommitsCountOptions struct {
Not string
Revision []string
RelPath []string
Since string
Until string
}
CommitsCountOptions the options when counting commits
type DivergeObject ¶
DivergeObject represents commit count diverging commits
func GetDivergingCommits ¶
func GetDivergingCommits(ctx context.Context, repo Repository, baseBranch, targetBranch string) (*DivergeObject, error)
GetDivergingCommits returns the number of commits a targetBranch is ahead or behind a baseBranch
type RemoteOption ¶
type RemoteOption string
const ( RemoteOptionMirrorPush RemoteOption = "--mirror=push" RemoteOptionMirrorFetch RemoteOption = "--mirror=fetch" )
Source Files
¶
- archive.go
- blame.go
- branch.go
- cat_file.go
- clone.go
- command.go
- commit.go
- commit_file.go
- commitgraph.go
- compare.go
- config.go
- diff.go
- fsck.go
- gitrepo.go
- hooks.go
- push.go
- ref.go
- remote.go
- signing.go
- size.go
- tag.go
- url.go
- walk_nogogit.go