Documentation ¶
Index ¶
- Variables
- func AddBranches(ctx context.Context, branches []*Branch) error
- func AddDeletedBranch(ctx context.Context, repoID int64, branchName string, deletedByID int64) error
- func CheckLFSAccessForRepo(ctx context.Context, ownerID int64, repo *repo_model.Repository, ...) error
- func CopyLFS(ctx context.Context, newRepo, oldRepo *repo_model.Repository) error
- func CountLFSLockByRepoID(ctx context.Context, repoID int64) (int64, error)
- func CountLFSMetaObjects(ctx context.Context, repoID int64) (int64, error)
- func DeleteBranches(ctx context.Context, repoID, doerID int64, branchIDs []int64) error
- func DeleteProtectedBranch(ctx context.Context, repo *repo_model.Repository, id int64) (err error)
- func DeleteProtectedTag(ctx context.Context, pt *ProtectedTag) error
- func ExistsLFSObject(ctx context.Context, oid string) (bool, error)
- func FindAllMatchedBranches(ctx context.Context, repoID int64, ruleName string) ([]string, error)
- func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, error)
- func FindBranchesByRepoAndBranchName(ctx context.Context, repoBranches map[int64]string) (map[int64]string, error)
- func FindRepoRecentCommitStatusContexts(ctx context.Context, repoID int64, before time.Duration) ([]string, error)
- func GetLatestCommitStatusForPairs(ctx context.Context, repoSHAs []RepoSHA) (map[int64][]*CommitStatus, error)
- func GetLatestCommitStatusForRepoCommitIDs(ctx context.Context, repoID int64, commitIDs []string) (map[string][]*CommitStatus, error)
- func GetNextCommitStatusIndex(ctx context.Context, repoID int64, sha string) (int64, error)
- func GetRepoLFSSize(ctx context.Context, repoID int64) (int64, error)
- func InsertProtectedTag(ctx context.Context, pt *ProtectedTag) error
- func IsBranchProtected(ctx context.Context, repoID int64, branchName string) (bool, error)
- func IsErrBranchAlreadyExists(err error) bool
- func IsErrBranchNameConflict(err error) bool
- func IsErrBranchNotExist(err error) bool
- func IsErrBranchesEqual(err error) bool
- func IsErrLFSFileLocked(err error) bool
- func IsErrLFSLockAlreadyExist(err error) bool
- func IsErrLFSLockNotExist(err error) bool
- func IsErrLFSUnauthorizedAction(err error) bool
- func IsRuleNameSpecial(ruleName string) bool
- func IsUserAllowedModifyTag(ctx context.Context, pt *ProtectedTag, userID int64) (bool, error)
- func IsUserAllowedToControlTag(ctx context.Context, tags []*ProtectedTag, tagName string, userID int64) (bool, error)
- func IsUserMergeWhitelisted(ctx context.Context, protectBranch *ProtectedBranch, userID int64, ...) bool
- func IsUserOfficialReviewer(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
- func IterateLFSMetaObjectsForRepo(ctx context.Context, repoID int64, ...) error
- func IterateRepositoryIDsWithLFSMetaObjects(ctx context.Context, f func(ctx context.Context, repoID, count int64) error) error
- func LFSAutoAssociate(ctx context.Context, metas []*LFSMetaObject, user *user_model.User, ...) error
- func LFSObjectAccessible(ctx context.Context, user *user_model.User, oid string) (bool, error)
- func MarkLFSMetaObject(ctx context.Context, id int64) error
- func NewCommitStatus(ctx context.Context, opts NewCommitStatusOptions) error
- func RemoveDeletedBranchByID(ctx context.Context, repoID, branchID int64) error
- func RemoveLFSMetaObjectByOid(ctx context.Context, repoID int64, oid string) (int64, error)
- func RemoveLFSMetaObjectByOidFn(ctx context.Context, repoID int64, oid string, fn func(count int64) error) (int64, error)
- func RemoveOldDeletedBranches(ctx context.Context, olderThan time.Duration)
- func RemoveTeamIDFromProtectedBranch(ctx context.Context, p *ProtectedBranch, teamID int64) error
- func RemoveUserIDFromProtectedBranch(ctx context.Context, p *ProtectedBranch, userID int64) error
- func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to string, ...) (err error)
- func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, ...) (int64, error)
- func UpdateCommitStatusSummary(ctx context.Context, repoID int64, sha string) error
- func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, ...) (err error)
- func UpdateProtectedTag(ctx context.Context, pt *ProtectedTag) error
- type Branch
- type BranchList
- type CommitStatus
- func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus
- func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOptions db.ListOptions) ([]*CommitStatus, int64, error)
- func GetLatestCommitStatusForRepoAndSHAs(ctx context.Context, repoSHAs []RepoSHA) ([]*CommitStatus, error)
- type CommitStatusIndex
- type CommitStatusOptions
- type CommitStatusSummary
- type ErrBranchAlreadyExists
- type ErrBranchNameConflict
- type ErrBranchNotExist
- type ErrBranchesEqual
- type ErrLFSFileLocked
- type ErrLFSLockAlreadyExist
- type ErrLFSLockNotExist
- type ErrLFSUnauthorizedAction
- type FindBranchOptions
- type FindRecentlyPushedNewBranchesOptions
- type IterateLFSMetaObjectsForRepoOptions
- type LFSLock
- func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error)
- func DeleteLFSLockByID(ctx context.Context, id int64, repo *repo_model.Repository, u *user_model.User, ...) (*LFSLock, error)
- func GetLFSLock(ctx context.Context, repo *repo_model.Repository, path string) (*LFSLock, error)
- func GetLFSLockByID(ctx context.Context, id int64) (*LFSLock, error)
- func GetTreePathLock(ctx context.Context, repoID int64, treePath string) (*LFSLock, error)
- type LFSLockList
- type LFSMetaObject
- type LFSTokenResponse
- type NewCommitStatusOptions
- type ProtectedBranch
- func GetFirstMatchProtectedBranchRule(ctx context.Context, repoID int64, branchName string) (*ProtectedBranch, error)
- func GetProtectedBranchRuleByID(ctx context.Context, repoID, ruleID int64) (*ProtectedBranch, error)
- func GetProtectedBranchRuleByName(ctx context.Context, repoID int64, ruleName string) (*ProtectedBranch, error)
- func (protectBranch *ProtectedBranch) CanUserPush(ctx context.Context, user *user_model.User) bool
- func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob
- func (protectBranch *ProtectedBranch) GetUnprotectedFilePatterns() []glob.Glob
- func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path string) bool
- func (protectBranch *ProtectedBranch) IsUnprotectedFile(patterns []glob.Glob, path string) bool
- func (protectBranch *ProtectedBranch) LoadRepo(ctx context.Context) (err error)
- func (protectBranch *ProtectedBranch) Match(branchName string) bool
- func (protectBranch *ProtectedBranch) MergeBlockedByProtectedFiles(changedProtectedFiles []string) bool
- type ProtectedBranchRules
- type ProtectedTag
- type RecentlyPushedNewBranch
- type RenamedBranch
- type RepoSHA
- type SignCommitWithStatuses
- type WhitelistOptions
Constants ¶
This section is empty.
Variables ¶
var ErrBranchIsProtected = errors.New("branch is protected")
var ErrLFSObjectNotExist = db.ErrNotExist{Resource: "LFS Meta object"}
ErrLFSObjectNotExist is returned from lfs models functions in order to differentiate between database and missing object errors.
Functions ¶
func AddDeletedBranch ¶
func AddDeletedBranch(ctx context.Context, repoID int64, branchName string, deletedByID int64) error
AddDeletedBranch adds a deleted branch to the database
func CheckLFSAccessForRepo ¶
func CheckLFSAccessForRepo(ctx context.Context, ownerID int64, repo *repo_model.Repository, mode perm.AccessMode) error
CheckLFSAccessForRepo check needed access mode base on action
func CopyLFS ¶
func CopyLFS(ctx context.Context, newRepo, oldRepo *repo_model.Repository) error
CopyLFS copies LFS data from one repo to another
func CountLFSLockByRepoID ¶
CountLFSLockByRepoID returns a count of all LFSLocks associated with a repository.
func CountLFSMetaObjects ¶
CountLFSMetaObjects returns a count of all LFSMetaObjects associated with a repository
func DeleteBranches ¶ added in v1.21.0
func DeleteProtectedBranch ¶
func DeleteProtectedBranch(ctx context.Context, repo *repo_model.Repository, id int64) (err error)
DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
func DeleteProtectedTag ¶
func DeleteProtectedTag(ctx context.Context, pt *ProtectedTag) error
DeleteProtectedTag deletes a protected tag by ID
func ExistsLFSObject ¶ added in v1.17.4
ExistsLFSObject checks if a provided Oid exists within the DB
func FindAllMatchedBranches ¶ added in v1.19.0
FindAllMatchedBranches find all matched branches
func FindBranchNames ¶ added in v1.21.0
func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, error)
func FindBranchesByRepoAndBranchName ¶ added in v1.21.0
func FindRepoRecentCommitStatusContexts ¶
func FindRepoRecentCommitStatusContexts(ctx context.Context, repoID int64, before time.Duration) ([]string, error)
FindRepoRecentCommitStatusContexts returns repository's recent commit status contexts
func GetLatestCommitStatusForPairs ¶ added in v1.20.0
func GetLatestCommitStatusForPairs(ctx context.Context, repoSHAs []RepoSHA) (map[int64][]*CommitStatus, error)
GetLatestCommitStatusForPairs returns all statuses with a unique context for a given list of repo-sha pairs
func GetLatestCommitStatusForRepoCommitIDs ¶ added in v1.21.0
func GetLatestCommitStatusForRepoCommitIDs(ctx context.Context, repoID int64, commitIDs []string) (map[string][]*CommitStatus, error)
GetLatestCommitStatusForRepoCommitIDs returns all statuses with a unique context for a given list of repo-sha pairs
func GetNextCommitStatusIndex ¶
GetNextCommitStatusIndex retried 3 times to generate a resource index
func GetRepoLFSSize ¶
GetRepoLFSSize return a repository's lfs files size
func InsertProtectedTag ¶
func InsertProtectedTag(ctx context.Context, pt *ProtectedTag) error
InsertProtectedTag inserts a protected tag to database
func IsBranchProtected ¶ added in v1.19.0
IsBranchProtected checks if branch is protected
func IsErrBranchAlreadyExists ¶ added in v1.21.0
IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
func IsErrBranchNameConflict ¶ added in v1.21.0
IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
func IsErrBranchNotExist ¶ added in v1.21.0
IsErrBranchNotExist checks if an error is an ErrBranchDoesNotExist.
func IsErrBranchesEqual ¶ added in v1.21.0
IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
func IsErrLFSFileLocked ¶
IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.
func IsErrLFSLockAlreadyExist ¶
IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.
func IsErrLFSLockNotExist ¶
IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.
func IsErrLFSUnauthorizedAction ¶
IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.
func IsRuleNameSpecial ¶ added in v1.19.0
IsRuleNameSpecial return true if it contains special character
func IsUserAllowedModifyTag ¶
IsUserAllowedModifyTag returns true if the user is allowed to modify the tag
func IsUserAllowedToControlTag ¶
func IsUserAllowedToControlTag(ctx context.Context, tags []*ProtectedTag, tagName string, userID int64) (bool, error)
IsUserAllowedToControlTag checks if a user can control the specific tag. It returns true if the tag name is not protected or the user is allowed to control it.
func IsUserMergeWhitelisted ¶
func IsUserMergeWhitelisted(ctx context.Context, protectBranch *ProtectedBranch, userID int64, permissionInRepo access_model.Permission) bool
IsUserMergeWhitelisted checks if some user is whitelisted to merge to this branch
func IsUserOfficialReviewer ¶
func IsUserOfficialReviewer(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
IsUserOfficialReviewer check if user is official reviewer for the branch (counts towards required approvals)
func IterateLFSMetaObjectsForRepo ¶ added in v1.17.4
func IterateLFSMetaObjectsForRepo(ctx context.Context, repoID int64, f func(context.Context, *LFSMetaObject, int64) error, opts *IterateLFSMetaObjectsForRepoOptions) error
IterateLFSMetaObjectsForRepo provides a iterator for LFSMetaObjects per Repo
func IterateRepositoryIDsWithLFSMetaObjects ¶ added in v1.19.0
func IterateRepositoryIDsWithLFSMetaObjects(ctx context.Context, f func(ctx context.Context, repoID, count int64) error) error
IterateRepositoryIDsWithLFSMetaObjects iterates across the repositories that have LFSMetaObjects
func LFSAutoAssociate ¶
func LFSAutoAssociate(ctx context.Context, metas []*LFSMetaObject, user *user_model.User, repoID int64) error
LFSAutoAssociate auto associates accessible LFSMetaObjects
func LFSObjectAccessible ¶
LFSObjectAccessible checks if a provided Oid is accessible to the user
func MarkLFSMetaObject ¶ added in v1.19.0
MarkLFSMetaObject updates the updated time for the provided LFSMetaObject
func NewCommitStatus ¶
func NewCommitStatus(ctx context.Context, opts NewCommitStatusOptions) error
NewCommitStatus save commit statuses into database
func RemoveDeletedBranchByID ¶
func RemoveLFSMetaObjectByOid ¶
RemoveLFSMetaObjectByOid removes a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error.
func RemoveLFSMetaObjectByOidFn ¶ added in v1.17.4
func RemoveLFSMetaObjectByOidFn(ctx context.Context, repoID int64, oid string, fn func(count int64) error) (int64, error)
RemoveLFSMetaObjectByOidFn removes a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error. It will run Fn with the current count within the transaction
func RemoveOldDeletedBranches ¶
RemoveOldDeletedBranches removes old deleted branches
func RemoveTeamIDFromProtectedBranch ¶ added in v1.19.0
func RemoveTeamIDFromProtectedBranch(ctx context.Context, p *ProtectedBranch, teamID int64) error
RemoveTeamIDFromProtectedBranch remove all team ids from protected branch options
func RemoveUserIDFromProtectedBranch ¶ added in v1.19.0
func RemoveUserIDFromProtectedBranch(ctx context.Context, p *ProtectedBranch, userID int64) error
RemoveUserIDFromProtectedBranch remove all user ids from protected branch options
func RenameBranch ¶
func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to string, gitAction func(ctx context.Context, isDefault bool) error) (err error)
RenameBranch rename a branch
func UpdateBranch ¶ added in v1.21.0
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) (int64, error)
UpdateBranch updates the branch information in the database.
func UpdateCommitStatusSummary ¶ added in v1.22.0
func UpdateProtectBranch ¶
func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, protectBranch *ProtectedBranch, opts WhitelistOptions) (err error)
UpdateProtectBranch saves branch protection options of repository. If ID is 0, it creates a new record. Otherwise, updates existing record. This function also performs check if whitelist user and team's IDs have been changed to avoid unnecessary whitelist delete and regenerate.
func UpdateProtectedTag ¶
func UpdateProtectedTag(ctx context.Context, pt *ProtectedTag) error
UpdateProtectedTag updates the protected tag
Types ¶
type Branch ¶ added in v1.21.0
type Branch struct { ID int64 RepoID int64 `xorm:"UNIQUE(s)"` Repo *repo_model.Repository `xorm:"-"` Name string `xorm:"UNIQUE(s) NOT NULL"` // git's ref-name is case-sensitive internally, however, in some databases (mssql, mysql, by default), it's case-insensitive at the moment CommitID string CommitMessage string `xorm:"TEXT"` // it only stores the message summary (the first line) PusherID int64 Pusher *user_model.User `xorm:"-"` IsDeleted bool `xorm:"index"` DeletedByID int64 DeletedBy *user_model.User `xorm:"-"` DeletedUnix timeutil.TimeStamp `xorm:"index"` CommitTime timeutil.TimeStamp // The commit CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` }
Branch represents a branch of a repository For those repository who have many branches, stored into database is a good choice for pagination, keyword search and filtering
func GetBranches ¶ added in v1.22.0
func GetDeletedBranchByID ¶
func (*Branch) LoadDeletedBy ¶ added in v1.21.0
func (*Branch) LoadPusher ¶ added in v1.21.0
type BranchList ¶ added in v1.21.0
type BranchList []*Branch
func (BranchList) LoadDeletedBy ¶ added in v1.21.0
func (branches BranchList) LoadDeletedBy(ctx context.Context) error
func (BranchList) LoadPusher ¶ added in v1.21.0
func (branches BranchList) LoadPusher(ctx context.Context) error
type CommitStatus ¶
type CommitStatus struct { ID int64 `xorm:"pk autoincr"` Index int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` RepoID int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` Repo *repo_model.Repository `xorm:"-"` State api.CommitStatusState `xorm:"VARCHAR(7) NOT NULL"` SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"` TargetURL string `xorm:"TEXT"` Description string `xorm:"TEXT"` ContextHash string `xorm:"VARCHAR(64) index"` Context string `xorm:"TEXT"` Creator *user_model.User `xorm:"-"` CreatorID int64 CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` }
CommitStatus holds a single Status of a single Commit
func CalcCommitStatus ¶
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus
CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
func GetLatestCommitStatus ¶
func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOptions db.ListOptions) ([]*CommitStatus, int64, error)
GetLatestCommitStatus returns all statuses with a unique context for a given commit.
func GetLatestCommitStatusForRepoAndSHAs ¶ added in v1.22.0
func GetLatestCommitStatusForRepoAndSHAs(ctx context.Context, repoSHAs []RepoSHA) ([]*CommitStatus, error)
func (*CommitStatus) APIURL ¶
func (status *CommitStatus) APIURL(ctx context.Context) string
APIURL returns the absolute APIURL to this commit-status.
func (*CommitStatus) LocaleString ¶ added in v1.21.0
func (status *CommitStatus) LocaleString(lang translation.Locale) string
LocaleString returns the locale string name of the Status
type CommitStatusIndex ¶
type CommitStatusIndex struct { ID int64 RepoID int64 `xorm:"unique(repo_sha)"` SHA string `xorm:"unique(repo_sha)"` MaxIndex int64 `xorm:"index"` }
CommitStatusIndex represents a table for commit status index
type CommitStatusOptions ¶
type CommitStatusOptions struct { db.ListOptions RepoID int64 SHA string State string SortType string }
CommitStatusOptions holds the options for query commit statuses
func (*CommitStatusOptions) ToConds ¶ added in v1.21.4
func (opts *CommitStatusOptions) ToConds() builder.Cond
func (*CommitStatusOptions) ToOrders ¶ added in v1.21.4
func (opts *CommitStatusOptions) ToOrders() string
type CommitStatusSummary ¶ added in v1.22.0
type CommitStatusSummary struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX UNIQUE(repo_id_sha)"` SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_id_sha)"` State api.CommitStatusState `xorm:"VARCHAR(7) NOT NULL"` TargetURL string `xorm:"TEXT"` }
CommitStatusSummary holds the latest commit Status of a single Commit
type ErrBranchAlreadyExists ¶ added in v1.21.0
type ErrBranchAlreadyExists struct {
BranchName string
}
ErrBranchAlreadyExists represents an error that branch with such name already exists.
func (ErrBranchAlreadyExists) Error ¶ added in v1.21.0
func (err ErrBranchAlreadyExists) Error() string
func (ErrBranchAlreadyExists) Unwrap ¶ added in v1.21.0
func (err ErrBranchAlreadyExists) Unwrap() error
type ErrBranchNameConflict ¶ added in v1.21.0
type ErrBranchNameConflict struct {
BranchName string
}
ErrBranchNameConflict represents an error that branch name conflicts with other branch.
func (ErrBranchNameConflict) Error ¶ added in v1.21.0
func (err ErrBranchNameConflict) Error() string
func (ErrBranchNameConflict) Unwrap ¶ added in v1.21.0
func (err ErrBranchNameConflict) Unwrap() error
type ErrBranchNotExist ¶ added in v1.21.0
ErrBranchNotExist represents an error that branch with such name does not exist.
func (ErrBranchNotExist) Error ¶ added in v1.21.0
func (err ErrBranchNotExist) Error() string
func (ErrBranchNotExist) Unwrap ¶ added in v1.21.0
func (err ErrBranchNotExist) Unwrap() error
type ErrBranchesEqual ¶ added in v1.21.0
ErrBranchesEqual represents an error that base branch is equal to the head branch.
func (ErrBranchesEqual) Error ¶ added in v1.21.0
func (err ErrBranchesEqual) Error() string
func (ErrBranchesEqual) Unwrap ¶ added in v1.21.0
func (err ErrBranchesEqual) Unwrap() error
type ErrLFSFileLocked ¶
ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
func (ErrLFSFileLocked) Error ¶
func (err ErrLFSFileLocked) Error() string
func (ErrLFSFileLocked) Unwrap ¶ added in v1.17.4
func (err ErrLFSFileLocked) Unwrap() error
type ErrLFSLockAlreadyExist ¶
ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
func (ErrLFSLockAlreadyExist) Error ¶
func (err ErrLFSLockAlreadyExist) Error() string
func (ErrLFSLockAlreadyExist) Unwrap ¶ added in v1.17.4
func (err ErrLFSLockAlreadyExist) Unwrap() error
type ErrLFSLockNotExist ¶
ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
func (ErrLFSLockNotExist) Error ¶
func (err ErrLFSLockNotExist) Error() string
func (ErrLFSLockNotExist) Unwrap ¶ added in v1.17.4
func (err ErrLFSLockNotExist) Unwrap() error
type ErrLFSUnauthorizedAction ¶
type ErrLFSUnauthorizedAction struct {}
ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
func (ErrLFSUnauthorizedAction) Error ¶
func (err ErrLFSUnauthorizedAction) Error() string
func (ErrLFSUnauthorizedAction) Unwrap ¶ added in v1.17.4
func (err ErrLFSUnauthorizedAction) Unwrap() error
type FindBranchOptions ¶ added in v1.21.0
type FindBranchOptions struct { db.ListOptions RepoID int64 ExcludeBranchNames []string IsDeletedBranch optional.Option[bool] OrderBy string Keyword string }
func (FindBranchOptions) ToConds ¶ added in v1.21.2
func (opts FindBranchOptions) ToConds() builder.Cond
func (FindBranchOptions) ToOrders ¶ added in v1.22.0
func (opts FindBranchOptions) ToOrders() string
type FindRecentlyPushedNewBranchesOptions ¶ added in v1.22.0
type FindRecentlyPushedNewBranchesOptions struct { Repo *repo_model.Repository BaseRepo *repo_model.Repository CommitAfterUnix int64 MaxCount int }
type IterateLFSMetaObjectsForRepoOptions ¶ added in v1.17.4
type IterateLFSMetaObjectsForRepoOptions struct { OlderThan timeutil.TimeStamp UpdatedLessRecentlyThan timeutil.TimeStamp OrderByUpdated bool LoopFunctionAlwaysUpdates bool }
IterateLFSMetaObjectsForRepoOptions provides options for IterateLFSMetaObjectsForRepo
type LFSLock ¶
type LFSLock struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX NOT NULL"` OwnerID int64 `xorm:"INDEX NOT NULL"` Owner *user_model.User `xorm:"-"` Path string `xorm:"TEXT"` Created time.Time `xorm:"created"` }
LFSLock represents a git lfs lock of repository.
func CreateLFSLock ¶
func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error)
CreateLFSLock creates a new lock.
func DeleteLFSLockByID ¶
func DeleteLFSLockByID(ctx context.Context, id int64, repo *repo_model.Repository, u *user_model.User, force bool) (*LFSLock, error)
DeleteLFSLockByID deletes a lock by given ID.
func GetLFSLock ¶
func GetLFSLock(ctx context.Context, repo *repo_model.Repository, path string) (*LFSLock, error)
GetLFSLock returns release by given path.
func GetLFSLockByID ¶
GetLFSLockByID returns release by given id.
func GetTreePathLock ¶
GetTreePathLock returns LSF lock for the treePath
func (*LFSLock) BeforeInsert ¶
func (l *LFSLock) BeforeInsert()
BeforeInsert is invoked from XORM before inserting an object of this type.
func (*LFSLock) LoadAttributes ¶ added in v1.22.2
LoadAttributes loads attributes of the lock.
type LFSLockList ¶ added in v1.22.2
type LFSLockList []*LFSLock
LFSLockList is a list of LFSLock
func GetLFSLockByRepoID ¶
GetLFSLockByRepoID returns a list of locks of repository.
func (LFSLockList) LoadAttributes ¶ added in v1.22.2
func (locks LFSLockList) LoadAttributes(ctx context.Context) error
LoadAttributes loads the attributes for the given locks
type LFSMetaObject ¶
type LFSMetaObject struct { ID int64 `xorm:"pk autoincr"` lfs.Pointer `xorm:"extends"` RepositoryID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` Existing bool `xorm:"-"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` }
LFSMetaObject stores metadata for LFS tracked files.
func GetLFSMetaObjectByOid ¶
GetLFSMetaObjectByOid selects a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error. If the error is nil, the returned pointer is a valid LFSMetaObject.
func GetLFSMetaObjects ¶
func GetLFSMetaObjects(ctx context.Context, repoID int64, page, pageSize int) ([]*LFSMetaObject, error)
GetLFSMetaObjects returns all LFSMetaObjects associated with a repository
func NewLFSMetaObject ¶
NewLFSMetaObject stores a given populated LFSMetaObject structure in the database if it is not already present.
type LFSTokenResponse ¶
LFSTokenResponse defines the JSON structure in which the JWT token is stored. This structure is fetched via SSH and passed by the Git LFS client to the server endpoint for authorization.
type NewCommitStatusOptions ¶
type NewCommitStatusOptions struct { Repo *repo_model.Repository Creator *user_model.User SHA git.ObjectID CommitStatus *CommitStatus }
NewCommitStatusOptions holds options for creating a CommitStatus
type ProtectedBranch ¶
type ProtectedBranch struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"UNIQUE(s)"` Repo *repo_model.Repository `xorm:"-"` RuleName string `xorm:"'branch_name' UNIQUE(s)"` // a branch name or a glob match to branch name CanPush bool `xorm:"NOT NULL DEFAULT false"` EnableWhitelist bool WhitelistUserIDs []int64 `xorm:"JSON TEXT"` WhitelistTeamIDs []int64 `xorm:"JSON TEXT"` EnableMergeWhitelist bool `xorm:"NOT NULL DEFAULT false"` WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"` MergeWhitelistUserIDs []int64 `xorm:"JSON TEXT"` MergeWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` EnableStatusCheck bool `xorm:"NOT NULL DEFAULT false"` StatusCheckContexts []string `xorm:"JSON TEXT"` EnableApprovalsWhitelist bool `xorm:"NOT NULL DEFAULT false"` ApprovalsWhitelistUserIDs []int64 `xorm:"JSON TEXT"` ApprovalsWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` RequiredApprovals int64 `xorm:"NOT NULL DEFAULT 0"` BlockOnRejectedReviews bool `xorm:"NOT NULL DEFAULT false"` BlockOnOfficialReviewRequests bool `xorm:"NOT NULL DEFAULT false"` BlockOnOutdatedBranch bool `xorm:"NOT NULL DEFAULT false"` DismissStaleApprovals bool `xorm:"NOT NULL DEFAULT false"` IgnoreStaleApprovals bool `xorm:"NOT NULL DEFAULT false"` RequireSignedCommits bool `xorm:"NOT NULL DEFAULT false"` ProtectedFilePatterns string `xorm:"TEXT"` UnprotectedFilePatterns string `xorm:"TEXT"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` // contains filtered or unexported fields }
ProtectedBranch struct
func GetFirstMatchProtectedBranchRule ¶ added in v1.19.0
func GetFirstMatchProtectedBranchRule(ctx context.Context, repoID int64, branchName string) (*ProtectedBranch, error)
GetFirstMatchProtectedBranchRule returns the first matched rules
func GetProtectedBranchRuleByID ¶ added in v1.19.0
func GetProtectedBranchRuleByID(ctx context.Context, repoID, ruleID int64) (*ProtectedBranch, error)
GetProtectedBranchRuleByID getting protected branch rule by rule ID
func GetProtectedBranchRuleByName ¶ added in v1.19.0
func GetProtectedBranchRuleByName(ctx context.Context, repoID int64, ruleName string) (*ProtectedBranch, error)
GetProtectedBranchRuleByName getting protected branch rule by name
func (*ProtectedBranch) CanUserPush ¶
func (protectBranch *ProtectedBranch) CanUserPush(ctx context.Context, user *user_model.User) bool
CanUserPush returns if some user could push to this protected branch
func (*ProtectedBranch) GetProtectedFilePatterns ¶
func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob
GetProtectedFilePatterns parses a semicolon separated list of protected file patterns and returns a glob.Glob slice
func (*ProtectedBranch) GetUnprotectedFilePatterns ¶
func (protectBranch *ProtectedBranch) GetUnprotectedFilePatterns() []glob.Glob
GetUnprotectedFilePatterns parses a semicolon separated list of unprotected file patterns and returns a glob.Glob slice
func (*ProtectedBranch) IsProtectedFile ¶
func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path string) bool
IsProtectedFile return if path is protected
func (*ProtectedBranch) IsUnprotectedFile ¶
func (protectBranch *ProtectedBranch) IsUnprotectedFile(patterns []glob.Glob, path string) bool
IsUnprotectedFile return if path is unprotected
func (*ProtectedBranch) LoadRepo ¶ added in v1.19.0
func (protectBranch *ProtectedBranch) LoadRepo(ctx context.Context) (err error)
func (*ProtectedBranch) Match ¶ added in v1.19.0
func (protectBranch *ProtectedBranch) Match(branchName string) bool
Match tests if branchName matches the rule
func (*ProtectedBranch) MergeBlockedByProtectedFiles ¶
func (protectBranch *ProtectedBranch) MergeBlockedByProtectedFiles(changedProtectedFiles []string) bool
MergeBlockedByProtectedFiles returns true if merge is blocked by protected files change
type ProtectedBranchRules ¶ added in v1.19.0
type ProtectedBranchRules []*ProtectedBranch
func FindRepoProtectedBranchRules ¶ added in v1.19.0
func FindRepoProtectedBranchRules(ctx context.Context, repoID int64) (ProtectedBranchRules, error)
FindRepoProtectedBranchRules load all repository's protected rules
func (ProtectedBranchRules) GetFirstMatched ¶ added in v1.19.0
func (rules ProtectedBranchRules) GetFirstMatched(branchName string) *ProtectedBranch
type ProtectedTag ¶
type ProtectedTag struct { ID int64 `xorm:"pk autoincr"` RepoID int64 NamePattern string RegexPattern *regexp.Regexp `xorm:"-"` GlobPattern glob.Glob `xorm:"-"` AllowlistUserIDs []int64 `xorm:"JSON TEXT"` AllowlistTeamIDs []int64 `xorm:"JSON TEXT"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` }
ProtectedTag struct
func GetProtectedTagByID ¶
func GetProtectedTagByID(ctx context.Context, id int64) (*ProtectedTag, error)
GetProtectedTagByID gets the protected tag with the specific id
func GetProtectedTags ¶
func GetProtectedTags(ctx context.Context, repoID int64) ([]*ProtectedTag, error)
GetProtectedTags gets all protected tags of the repository
func (*ProtectedTag) EnsureCompiledPattern ¶
func (pt *ProtectedTag) EnsureCompiledPattern() error
EnsureCompiledPattern ensures the glob pattern is compiled
type RecentlyPushedNewBranch ¶ added in v1.22.0
type RecentlyPushedNewBranch struct { BranchDisplayName string BranchLink string BranchCompareURL string CommitTime timeutil.TimeStamp }
func FindRecentlyPushedNewBranches ¶ added in v1.21.0
func FindRecentlyPushedNewBranches(ctx context.Context, doer *user_model.User, opts *FindRecentlyPushedNewBranchesOptions) ([]*RecentlyPushedNewBranch, error)
FindRecentlyPushedNewBranches return at most 2 new branches pushed by the user in 2 hours which has no opened PRs created if opts.CommitAfterUnix is 0, we will find the branches that were committed to in the last 2 hours if opts.ListOptions is not set, we will only display top 2 latest branch
type RenamedBranch ¶
type RenamedBranch struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX NOT NULL"` From string To string CreatedUnix timeutil.TimeStamp `xorm:"created"` }
RenamedBranch provide renamed branch log will check it when a branch can't be found
func FindRenamedBranch ¶
func FindRenamedBranch(ctx context.Context, repoID int64, from string) (branch *RenamedBranch, exist bool, err error)
FindRenamedBranch check if a branch was renamed
type SignCommitWithStatuses ¶
type SignCommitWithStatuses struct { Status *CommitStatus Statuses []*CommitStatus *asymkey_model.SignCommit }
SignCommitWithStatuses represents a commit with validation of signature and status state.
func ConvertFromGitCommit ¶
func ConvertFromGitCommit(ctx context.Context, commits []*git.Commit, repo *repo_model.Repository) []*SignCommitWithStatuses
ConvertFromGitCommit converts git commits into SignCommitWithStatuses
func ParseCommitsWithStatus ¶
func ParseCommitsWithStatus(ctx context.Context, oldCommits []*asymkey_model.SignCommit, repo *repo_model.Repository) []*SignCommitWithStatuses
ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state