Documentation ¶
Index ¶
- Variables
- func AddDeletedBranch(repoID int64, branchName, commit 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(repoID int64) (int64, error)
- func CountLFSMetaObjects(repoID int64) (int64, error)
- func DeleteProtectedBranch(repoID, id int64) (err error)
- func DeleteProtectedTag(pt *ProtectedTag) error
- func FindRepoRecentCommitStatusContexts(repoID int64, before time.Duration) ([]string, error)
- func GetNextCommitStatusIndex(repoID int64, sha string) (int64, error)
- func GetRepoLFSSize(ctx context.Context, repoID int64) (int64, error)
- func InsertProtectedTag(pt *ProtectedTag) error
- func IsErrLFSFileLocked(err error) bool
- func IsErrLFSLockAlreadyExist(err error) bool
- func IsErrLFSLockNotExist(err error) bool
- func IsErrLFSUnauthorizedAction(err error) bool
- func IsProtectedBranch(repoID int64, branchName string) (bool, error)
- func IsUserAllowedModifyTag(pt *ProtectedTag, userID int64) (bool, error)
- func IsUserAllowedToControlTag(tags []*ProtectedTag, tagName string, userID int64) (bool, error)
- func IsUserMergeWhitelisted(ctx context.Context, protectBranch *ProtectedBranch, userID int64, ...) bool
- func IsUserOfficialReviewer(protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
- func IsUserOfficialReviewerCtx(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
- func IterateLFS(f func(mo *LFSMetaObject) error) error
- func LFSAutoAssociate(metas []*LFSMetaObject, user *user_model.User, repoID int64) error
- func LFSObjectAccessible(user *user_model.User, oid string) (bool, error)
- func LFSObjectIsAssociated(oid string) (bool, error)
- func NewCommitStatus(opts NewCommitStatusOptions) error
- func RemoveDeletedBranchByID(repoID, id int64) (err error)
- func RemoveDeletedBranchByName(repoID int64, branch string) error
- func RemoveLFSMetaObjectByOid(repoID int64, oid string) (int64, error)
- func RemoveOldDeletedBranches(ctx context.Context, olderThan time.Duration)
- func RenameBranch(repo *repo_model.Repository, from, to string, ...) (err error)
- func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, ...) (err error)
- func UpdateProtectedTag(pt *ProtectedTag) error
- type CommitStatus
- func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus
- func GetCommitStatuses(repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error)
- func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOptions db.ListOptions) ([]*CommitStatus, int64, error)
- type CommitStatusIndex
- type CommitStatusOptions
- type DeletedBranch
- type ErrLFSFileLocked
- type ErrLFSLockAlreadyExist
- type ErrLFSLockNotExist
- type ErrLFSUnauthorizedAction
- type LFSLock
- func CreateLFSLock(repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error)
- func DeleteLFSLockByID(id int64, repo *repo_model.Repository, u *user_model.User, force bool) (*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 GetLFSLockByRepoID(repoID int64, page, pageSize int) ([]*LFSLock, error)
- func GetTreePathLock(repoID int64, treePath string) (*LFSLock, error)
- type LFSMetaObject
- type LFSTokenResponse
- type NewCommitStatusOptions
- type ProtectedBranch
- func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool
- func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob
- func (protectBranch *ProtectedBranch) GetUnprotectedFilePatterns() []glob.Glob
- func (protectBranch *ProtectedBranch) IsProtected() bool
- func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path string) bool
- func (protectBranch *ProtectedBranch) IsUnprotectedFile(patterns []glob.Glob, path string) bool
- func (protectBranch *ProtectedBranch) MergeBlockedByProtectedFiles(changedProtectedFiles []string) bool
- type ProtectedTag
- type RenamedBranch
- type SignCommitWithStatuses
- type WhitelistOptions
Constants ¶
This section is empty.
Variables ¶
var ErrLFSObjectNotExist = errors.New("LFS Meta object does not exist")
ErrLFSObjectNotExist is returned from lfs models functions in order to differentiate between database and missing object errors.
Functions ¶
func AddDeletedBranch ¶
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 DeleteProtectedBranch ¶
DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
func DeleteProtectedTag ¶
func DeleteProtectedTag(pt *ProtectedTag) error
DeleteProtectedTag deletes a protected tag by ID
func FindRepoRecentCommitStatusContexts ¶
FindRepoRecentCommitStatusContexts returns repository's recent commit status contexts
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(pt *ProtectedTag) error
InsertProtectedTag inserts a protected tag to database
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 IsProtectedBranch ¶
IsProtectedBranch checks if branch is protected
func IsUserAllowedModifyTag ¶
func IsUserAllowedModifyTag(pt *ProtectedTag, userID int64) (bool, error)
IsUserAllowedModifyTag returns true if the user is allowed to modify the tag
func IsUserAllowedToControlTag ¶
func IsUserAllowedToControlTag(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(protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
IsUserOfficialReviewer check if user is official reviewer for the branch (counts towards required approvals)
func IsUserOfficialReviewerCtx ¶
func IsUserOfficialReviewerCtx(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User) (bool, error)
IsUserOfficialReviewerCtx check if user is official reviewer for the branch (counts towards required approvals)
func IterateLFS ¶
func IterateLFS(f func(mo *LFSMetaObject) error) error
IterateLFS iterates lfs object
func LFSAutoAssociate ¶
func LFSAutoAssociate(metas []*LFSMetaObject, user *user_model.User, repoID int64) error
LFSAutoAssociate auto associates accessible LFSMetaObjects
func LFSObjectAccessible ¶
func LFSObjectAccessible(user *user_model.User, oid string) (bool, error)
LFSObjectAccessible checks if a provided Oid is accessible to the user
func LFSObjectIsAssociated ¶
LFSObjectIsAssociated checks if a provided Oid is associated
func NewCommitStatus ¶
func NewCommitStatus(opts NewCommitStatusOptions) error
NewCommitStatus save commit statuses into database
func RemoveDeletedBranchByID ¶
RemoveDeletedBranchByID removes a deleted branch from the database
func RemoveDeletedBranchByName ¶
RemoveDeletedBranchByName removes all deleted branches
func RemoveLFSMetaObjectByOid ¶
RemoveLFSMetaObjectByOid removes a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error.
func RemoveOldDeletedBranches ¶
RemoveOldDeletedBranches removes old deleted branches
func RenameBranch ¶
func RenameBranch(repo *repo_model.Repository, from, to string, gitAction func(isDefault bool) error) (err error)
RenameBranch rename a branch
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(pt *ProtectedTag) error
UpdateProtectedTag updates the protected tag
Types ¶
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:"char(40) 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 GetCommitStatuses ¶
func GetCommitStatuses(repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error)
GetCommitStatuses returns all statuses for a given commit.
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 (*CommitStatus) APIURL ¶
func (status *CommitStatus) APIURL() string
APIURL returns the absolute APIURL to this commit-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 State string SortType string }
CommitStatusOptions holds the options for query commit statuses
type DeletedBranch ¶
type DeletedBranch struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` Name string `xorm:"UNIQUE(s) NOT NULL"` Commit string `xorm:"UNIQUE(s) NOT NULL"` DeletedByID int64 `xorm:"INDEX"` DeletedBy *user_model.User `xorm:"-"` DeletedUnix timeutil.TimeStamp `xorm:"INDEX created"` }
DeletedBranch struct
func GetDeletedBranchByID ¶
func GetDeletedBranchByID(repoID, id int64) (*DeletedBranch, error)
GetDeletedBranchByID get a deleted branch by its ID
func GetDeletedBranches ¶
func GetDeletedBranches(repoID int64) ([]*DeletedBranch, error)
GetDeletedBranches returns all the deleted branches
func (*DeletedBranch) LoadUser ¶
func (deletedBranch *DeletedBranch) LoadUser()
LoadUser loads the user that deleted the branch When there's no user found it returns a user_model.NewGhostUser
type ErrLFSFileLocked ¶
ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
func (ErrLFSFileLocked) Error ¶
func (err ErrLFSFileLocked) Error() string
type ErrLFSLockAlreadyExist ¶
ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.
func (ErrLFSLockAlreadyExist) Error ¶
func (err ErrLFSLockAlreadyExist) Error() string
type ErrLFSLockNotExist ¶
ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.
func (ErrLFSLockNotExist) Error ¶
func (err ErrLFSLockNotExist) Error() string
type ErrLFSUnauthorizedAction ¶
type ErrLFSUnauthorizedAction struct {}
ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.
func (ErrLFSUnauthorizedAction) Error ¶
func (err ErrLFSUnauthorizedAction) Error() string
type LFSLock ¶
type LFSLock struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX NOT NULL"` OwnerID int64 `xorm:"INDEX NOT NULL"` Path string `xorm:"TEXT"` Created time.Time `xorm:"created"` }
LFSLock represents a git lfs lock of repository.
func CreateLFSLock ¶
func CreateLFSLock(repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error)
CreateLFSLock creates a new lock.
func DeleteLFSLockByID ¶
func DeleteLFSLockByID(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 GetLFSLockByRepoID ¶
GetLFSLockByRepoID returns a list of locks of repository.
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.
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"` }
LFSMetaObject stores metadata for LFS tracked files.
func GetLFSMetaObjectByOid ¶
func GetLFSMetaObjectByOid(repoID int64, oid string) (*LFSMetaObject, error)
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(repoID int64, page, pageSize int) ([]*LFSMetaObject, error)
GetLFSMetaObjects returns all LFSMetaObjects associated with a repository
func NewLFSMetaObject ¶
func NewLFSMetaObject(m *LFSMetaObject) (*LFSMetaObject, error)
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 string CommitStatus *CommitStatus }
NewCommitStatusOptions holds options for creating a CommitStatus
type ProtectedBranch ¶
type ProtectedBranch struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"UNIQUE(s)"` BranchName string `xorm:"UNIQUE(s)"` 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"` 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"` }
ProtectedBranch struct
func GetProtectedBranchBy ¶
func GetProtectedBranchBy(ctx context.Context, repoID int64, branchName string) (*ProtectedBranch, error)
GetProtectedBranchBy getting protected branch by ID/Name
func GetProtectedBranches ¶
func GetProtectedBranches(repoID int64) ([]*ProtectedBranch, error)
GetProtectedBranches get all protected branches
func (*ProtectedBranch) CanUserPush ¶
func (protectBranch *ProtectedBranch) CanUserPush(userID int64) 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) IsProtected ¶
func (protectBranch *ProtectedBranch) IsProtected() bool
IsProtected returns if the branch is protected
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) MergeBlockedByProtectedFiles ¶
func (protectBranch *ProtectedBranch) MergeBlockedByProtectedFiles(changedProtectedFiles []string) bool
MergeBlockedByProtectedFiles returns true if merge is blocked by protected files change
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(id int64) (*ProtectedTag, error)
GetProtectedTagByID gets the protected tag with the specific id
func GetProtectedTags ¶
func GetProtectedTags(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 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(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(commits []*git.Commit, repo *repo_model.Repository) []*SignCommitWithStatuses
ConvertFromGitCommit converts git commits into SignCommitWithStatuses
func ParseCommitsWithStatus ¶
func ParseCommitsWithStatus(oldCommits []*asymkey_model.SignCommit, repo *repo_model.Repository) []*SignCommitWithStatuses
ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state