Documentation
¶
Index ¶
- func CheckDelegateHooks(_ context.Context, repo Repository) ([]string, error)
- func CreateDelegateHooks(_ context.Context, repo Repository) (err error)
- func DeleteRepository(ctx context.Context, repo Repository) 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 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 IsRepositoryExist(ctx context.Context, repo Repository) (bool, error)
- func IsTagExist(ctx context.Context, repo Repository, name string) bool
- func OpenRepository(ctx context.Context, repo Repository) (*git.Repository, error)
- func RemoveRef(ctx context.Context, repo Repository, refName 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 SetDefaultBranch(ctx context.Context, repo Repository, name string) error
- func UpdateRef(ctx context.Context, repo Repository, refName, newCommitID string) error
- func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error)
- type RemoteOption
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDelegateHooks ¶ added in v1.24.0
func CheckDelegateHooks(_ context.Context, repo Repository) ([]string, error)
CheckDelegateHooks checks the hooks scripts for the repo
func CreateDelegateHooks ¶ added in v1.24.0
func CreateDelegateHooks(_ context.Context, repo Repository) (err error)
CreateDelegateHooks creates all the hooks scripts for the repo
func DeleteRepository ¶ added in v1.24.0
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 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 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 ¶ added in v1.24.0
func IsBranchExist(ctx context.Context, repo Repository, name string) bool
IsBranchExist returns true if given branch exists in the repository.
func IsReferenceExist ¶ added in v1.24.0
func IsReferenceExist(ctx context.Context, repo Repository, name string) bool
IsReferenceExist returns true if given reference exists in the repository.
func IsRepositoryExist ¶ added in v1.24.0
func IsRepositoryExist(ctx context.Context, repo Repository) (bool, error)
IsRepositoryExist returns true if the repository directory exists in the disk
func IsTagExist ¶ added in v1.24.0
func IsTagExist(ctx context.Context, repo Repository, name string) bool
IsTagExist returns true if given tag exists in the repository.
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 RenameRepository ¶ added in v1.24.0
func RenameRepository(ctx context.Context, repo, newRepo Repository) error
RenameRepository renames a repository's name on disk
func RepoGitURL ¶ added in v1.23.0
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 ¶ added in v1.24.0
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 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 WalkReferences ¶
func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error)
WalkReferences walks all the references from the repository
Types ¶
type RemoteOption ¶
type RemoteOption string
const ( RemoteOptionMirrorPush RemoteOption = "--mirror=push" RemoteOptionMirrorFetch RemoteOption = "--mirror=fetch" )
type Repository ¶
type Repository interface {
RelativePath() string // We don't assume how the directory structure of the repository is, so we only need the relative path
}
Repository represents a git repository which stored in a disk