models

package
v1.20.0-rc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 33 Imported by: 1,654

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAllRepositories added in v1.17.0

func AddAllRepositories(t *organization.Team) (err error)

AddAllRepositories adds all repositories to the team

func AddRepository added in v1.17.0

func AddRepository(ctx context.Context, t *organization.Team, repo *repo_model.Repository) (err error)

func AddTeamMember

func AddTeamMember(team *organization.Team, userID int64) error

AddTeamMember adds new membership of given team to given organization, the user will have membership to given organization automatically when needed.

func CancelRepositoryTransfer added in v1.14.0

func CancelRepositoryTransfer(repo *repo_model.Repository) error

CancelRepositoryTransfer marks the repository as ready and remove pending transfer entry, thus cancel the transfer process.

func CheckRepoStats

func CheckRepoStats(ctx context.Context) error

CheckRepoStats checks the repository stats

func CreatePendingRepositoryTransfer added in v1.14.0

func CreatePendingRepositoryTransfer(ctx context.Context, doer, newOwner *user_model.User, repoID int64, teams []*organization.Team) error

CreatePendingRepositoryTransfer transfer a repo from one owner to a new one. it marks the repository transfer as "pending"

func DeleteCollaboration added in v1.16.0

func DeleteCollaboration(repo *repo_model.Repository, uid int64) (err error)

DeleteCollaboration removes collaboration relation between the user and repository.

func DeleteDeployKey

func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error

DeleteDeployKey delete deploy keys

func DeleteRepository

func DeleteRepository(doer *user_model.User, uid, repoID int64) error

DeleteRepository deletes a repository for a user or organization. make sure if you call this func to close open sessions (sqlite will otherwise get a deadlock)

func DeleteTeam

func DeleteTeam(t *organization.Team) error

DeleteTeam deletes given team. It's caller's responsibility to assign organization ID.

func DoctorUserStarNum added in v1.12.2

func DoctorUserStarNum() (err error)

DoctorUserStarNum recalculate Stars number for all user

func GetYamlFixturesAccess added in v1.12.0

func GetYamlFixturesAccess() (string, error)

GetYamlFixturesAccess returns a string containing the contents for the access table, as recalculated using repo.RecalculateAccesses()

func HasRepository added in v1.17.0

func HasRepository(t *organization.Team, repoID int64) bool

HasRepository returns true if given repository belong to team.

func Init added in v1.17.4

func Init(ctx context.Context) error

Init initialize model

func InsertIssueComments added in v1.9.0

func InsertIssueComments(comments []*issues_model.Comment) error

InsertIssueComments inserts many comments of issues.

func InsertIssues added in v1.9.0

func InsertIssues(issues ...*issues_model.Issue) error

InsertIssues insert issues to database

func InsertMilestones added in v1.9.0

func InsertMilestones(ms ...*issues_model.Milestone) (err error)

InsertMilestones creates milestones of repository.

func InsertPullRequests added in v1.9.0

func InsertPullRequests(prs ...*issues_model.PullRequest) error

InsertPullRequests inserted pull requests

func InsertReleases added in v1.9.0

func InsertReleases(rels ...*repo_model.Release) error

InsertReleases migrates release

func IsErrBranchAlreadyExists added in v1.3.0

func IsErrBranchAlreadyExists(err error) bool

IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.

func IsErrBranchDoesNotExist added in v1.13.0

func IsErrBranchDoesNotExist(err error) bool

IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.

func IsErrBranchNameConflict added in v1.3.0

func IsErrBranchNameConflict(err error) bool

IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.

func IsErrBranchesEqual added in v1.11.0

func IsErrBranchesEqual(err error) bool

IsErrBranchesEqual checks if an error is an ErrBranchesEqual.

func IsErrCommitIDDoesNotMatch added in v1.9.0

func IsErrCommitIDDoesNotMatch(err error) bool

IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.

func IsErrDisallowedToMerge added in v1.17.0

func IsErrDisallowedToMerge(err error) bool

IsErrDisallowedToMerge checks if an error is an ErrDisallowedToMerge.

func IsErrFilePathInvalid added in v1.9.0

func IsErrFilePathInvalid(err error) bool

IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.

func IsErrFilePathProtected added in v1.12.0

func IsErrFilePathProtected(err error) bool

IsErrFilePathProtected checks if an error is an ErrFilePathProtected.

func IsErrFilenameInvalid added in v1.9.0

func IsErrFilenameInvalid(err error) bool

IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.

func IsErrInvalidCloneAddr

func IsErrInvalidCloneAddr(err error) bool

IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.

func IsErrInvalidMergeStyle added in v1.4.0

func IsErrInvalidMergeStyle(err error) bool

IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.

func IsErrInvalidTagName

func IsErrInvalidTagName(err error) bool

IsErrInvalidTagName checks if an error is a ErrInvalidTagName.

func IsErrMergeConflicts added in v1.11.0

func IsErrMergeConflicts(err error) bool

IsErrMergeConflicts checks if an error is a ErrMergeConflicts.

func IsErrMergeUnrelatedHistories added in v1.11.0

func IsErrMergeUnrelatedHistories(err error) bool

IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.

func IsErrNoPendingTransfer added in v1.14.0

func IsErrNoPendingTransfer(err error) bool

IsErrNoPendingTransfer is an error type when a repository has no pending transfers

func IsErrProtectedTagName added in v1.15.0

func IsErrProtectedTagName(err error) bool

IsErrProtectedTagName checks if an error is a ErrProtectedTagName.

func IsErrPullRequestHasMerged added in v1.11.0

func IsErrPullRequestHasMerged(err error) bool

IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.

func IsErrRebaseConflicts added in v1.11.0

func IsErrRebaseConflicts(err error) bool

IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.

func IsErrRepoFileAlreadyExists added in v1.9.0

func IsErrRepoFileAlreadyExists(err error) bool

IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.

func IsErrRepoFileDoesNotExist added in v1.9.0

func IsErrRepoFileDoesNotExist(err error) bool

IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.

func IsErrRepoTransferInProgress added in v1.14.0

func IsErrRepoTransferInProgress(err error) bool

IsErrRepoTransferInProgress checks if an error is a ErrRepoTransferInProgress.

func IsErrSHADoesNotMatch added in v1.9.0

func IsErrSHADoesNotMatch(err error) bool

IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.

func IsErrSHANotFound added in v1.9.0

func IsErrSHANotFound(err error) bool

IsErrSHANotFound checks if an error is a ErrSHANotFound.

func IsErrSHAOrCommitIDNotProvided added in v1.9.0

func IsErrSHAOrCommitIDNotProvided(err error) bool

IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.

func IsErrTagAlreadyExists added in v1.3.0

func IsErrTagAlreadyExists(err error) bool

IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.

func IsErrUpdateTaskNotExist

func IsErrUpdateTaskNotExist(err error) bool

IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.

func IsErrUserCannotCommit added in v1.9.0

func IsErrUserCannotCommit(err error) bool

IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.

func IsErrUserHasOrgs

func IsErrUserHasOrgs(err error) bool

IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.

func IsErrUserOwnPackages added in v1.17.0

func IsErrUserOwnPackages(err error) bool

IsErrUserOwnPackages checks if an error is an ErrUserOwnPackages.

func IsErrUserOwnRepos

func IsErrUserOwnRepos(err error) bool

IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.

func NewTeam

func NewTeam(t *organization.Team) (err error)

NewTeam creates a record of new team. It's caller's responsibility to assign organization ID.

func RemoveAllRepositories added in v1.17.0

func RemoveAllRepositories(t *organization.Team) (err error)

RemoveAllRepositories removes all repositories from team and recalculates access

func RemoveOrgUser

func RemoveOrgUser(orgID, userID int64) error

RemoveOrgUser removes user from given organization.

func RemoveRepository added in v1.17.0

func RemoveRepository(t *organization.Team, repoID int64) error

RemoveRepository removes repository from team of organization. If the team shall include all repositories the request is ignored.

func RemoveTeamMember

func RemoveTeamMember(team *organization.Team, userID int64) error

RemoveTeamMember removes member from given team of given organization.

func StatsCorrectSQL added in v1.16.0

func StatsCorrectSQL(ctx context.Context, sql string, id int64) error

func TestRepositoryReadyForTransfer added in v1.14.0

func TestRepositoryReadyForTransfer(status repo_model.RepositoryStatus) error

TestRepositoryReadyForTransfer make sure repo is ready to transfer

func TransferOwnership

func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_model.Repository) (err error)

TransferOwnership transfers all corresponding repository items from old user to new one.

func UpdateMigrationsByType added in v1.10.0

func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error

UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID

func UpdateRepoStats added in v1.16.0

func UpdateRepoStats(ctx context.Context, id int64) error

func UpdateTeam

func UpdateTeam(t *organization.Team, authChanged, includeAllChanged bool) (err error)

UpdateTeam updates information of team.

Types

type ErrBranchAlreadyExists added in v1.3.0

type ErrBranchAlreadyExists struct {
	BranchName string
}

ErrBranchAlreadyExists represents an error that branch with such name already exists.

func (ErrBranchAlreadyExists) Error added in v1.3.0

func (err ErrBranchAlreadyExists) Error() string

func (ErrBranchAlreadyExists) Unwrap added in v1.17.4

func (err ErrBranchAlreadyExists) Unwrap() error

type ErrBranchDoesNotExist added in v1.13.0

type ErrBranchDoesNotExist struct {
	BranchName string
}

ErrBranchDoesNotExist represents an error that branch with such name does not exist.

func (ErrBranchDoesNotExist) Error added in v1.13.0

func (err ErrBranchDoesNotExist) Error() string

func (ErrBranchDoesNotExist) Unwrap added in v1.17.4

func (err ErrBranchDoesNotExist) Unwrap() error

type ErrBranchNameConflict added in v1.3.0

type ErrBranchNameConflict struct {
	BranchName string
}

ErrBranchNameConflict represents an error that branch name conflicts with other branch.

func (ErrBranchNameConflict) Error added in v1.3.0

func (err ErrBranchNameConflict) Error() string

func (ErrBranchNameConflict) Unwrap added in v1.17.4

func (err ErrBranchNameConflict) Unwrap() error

type ErrBranchesEqual added in v1.11.0

type ErrBranchesEqual struct {
	BaseBranchName string
	HeadBranchName string
}

ErrBranchesEqual represents an error that branch name conflicts with other branch.

func (ErrBranchesEqual) Error added in v1.11.0

func (err ErrBranchesEqual) Error() string

func (ErrBranchesEqual) Unwrap added in v1.17.4

func (err ErrBranchesEqual) Unwrap() error

type ErrCommitIDDoesNotMatch added in v1.9.0

type ErrCommitIDDoesNotMatch struct {
	GivenCommitID   string
	CurrentCommitID string
}

ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.

func (ErrCommitIDDoesNotMatch) Error added in v1.9.0

func (err ErrCommitIDDoesNotMatch) Error() string

type ErrDisallowedToMerge added in v1.17.0

type ErrDisallowedToMerge struct {
	Reason string
}

ErrDisallowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.

func (ErrDisallowedToMerge) Error added in v1.17.0

func (err ErrDisallowedToMerge) Error() string

func (ErrDisallowedToMerge) Unwrap added in v1.17.4

func (err ErrDisallowedToMerge) Unwrap() error

type ErrFilePathInvalid added in v1.9.0

type ErrFilePathInvalid struct {
	Message string
	Path    string
	Name    string
	Type    git.EntryMode
}

ErrFilePathInvalid represents a "FilePathInvalid" kind of error.

func (ErrFilePathInvalid) Error added in v1.9.0

func (err ErrFilePathInvalid) Error() string

func (ErrFilePathInvalid) Unwrap added in v1.17.4

func (err ErrFilePathInvalid) Unwrap() error

type ErrFilePathProtected added in v1.12.0

type ErrFilePathProtected struct {
	Message string
	Path    string
}

ErrFilePathProtected represents a "FilePathProtected" kind of error.

func (ErrFilePathProtected) Error added in v1.12.0

func (err ErrFilePathProtected) Error() string

func (ErrFilePathProtected) Unwrap added in v1.17.4

func (err ErrFilePathProtected) Unwrap() error

type ErrFilenameInvalid added in v1.9.0

type ErrFilenameInvalid struct {
	Path string
}

ErrFilenameInvalid represents a "FilenameInvalid" kind of error.

func (ErrFilenameInvalid) Error added in v1.9.0

func (err ErrFilenameInvalid) Error() string

func (ErrFilenameInvalid) Unwrap added in v1.17.4

func (err ErrFilenameInvalid) Unwrap() error

type ErrInvalidCloneAddr

type ErrInvalidCloneAddr struct {
	Host               string
	IsURLError         bool
	IsInvalidPath      bool
	IsProtocolInvalid  bool
	IsPermissionDenied bool
	LocalPath          bool
}

ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.

func (*ErrInvalidCloneAddr) Error

func (err *ErrInvalidCloneAddr) Error() string

func (*ErrInvalidCloneAddr) Unwrap added in v1.17.4

func (err *ErrInvalidCloneAddr) Unwrap() error

type ErrInvalidMergeStyle added in v1.4.0

type ErrInvalidMergeStyle struct {
	ID    int64
	Style repo_model.MergeStyle
}

ErrInvalidMergeStyle represents an error if merging with disabled merge strategy

func (ErrInvalidMergeStyle) Error added in v1.4.0

func (err ErrInvalidMergeStyle) Error() string

func (ErrInvalidMergeStyle) Unwrap added in v1.17.4

func (err ErrInvalidMergeStyle) Unwrap() error

type ErrInvalidTagName

type ErrInvalidTagName struct {
	TagName string
}

ErrInvalidTagName represents a "InvalidTagName" kind of error.

func (ErrInvalidTagName) Error

func (err ErrInvalidTagName) Error() string

func (ErrInvalidTagName) Unwrap added in v1.17.4

func (err ErrInvalidTagName) Unwrap() error

type ErrMergeConflicts added in v1.11.0

type ErrMergeConflicts struct {
	Style  repo_model.MergeStyle
	StdOut string
	StdErr string
	Err    error
}

ErrMergeConflicts represents an error if merging fails with a conflict

func (ErrMergeConflicts) Error added in v1.11.0

func (err ErrMergeConflicts) Error() string

type ErrMergeUnrelatedHistories added in v1.11.0

type ErrMergeUnrelatedHistories struct {
	Style  repo_model.MergeStyle
	StdOut string
	StdErr string
	Err    error
}

ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories

func (ErrMergeUnrelatedHistories) Error added in v1.11.0

func (err ErrMergeUnrelatedHistories) Error() string

type ErrNoPendingRepoTransfer added in v1.14.0

type ErrNoPendingRepoTransfer struct {
	RepoID int64
}

ErrNoPendingRepoTransfer is an error type for repositories without a pending transfer request

func (ErrNoPendingRepoTransfer) Error added in v1.14.0

func (err ErrNoPendingRepoTransfer) Error() string

func (ErrNoPendingRepoTransfer) Unwrap added in v1.17.4

func (err ErrNoPendingRepoTransfer) Unwrap() error

type ErrProtectedTagName added in v1.15.0

type ErrProtectedTagName struct {
	TagName string
}

ErrProtectedTagName represents a "ProtectedTagName" kind of error.

func (ErrProtectedTagName) Error added in v1.15.0

func (err ErrProtectedTagName) Error() string

func (ErrProtectedTagName) Unwrap added in v1.17.4

func (err ErrProtectedTagName) Unwrap() error

type ErrPullRequestHasMerged added in v1.11.0

type ErrPullRequestHasMerged struct {
	ID         int64
	IssueID    int64
	HeadRepoID int64
	BaseRepoID int64
	HeadBranch string
	BaseBranch string
}

ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error

func (ErrPullRequestHasMerged) Error added in v1.11.0

func (err ErrPullRequestHasMerged) Error() string

Error does pretty-printing :D

type ErrRebaseConflicts added in v1.11.0

type ErrRebaseConflicts struct {
	Style     repo_model.MergeStyle
	CommitSHA string
	StdOut    string
	StdErr    string
	Err       error
}

ErrRebaseConflicts represents an error if rebase fails with a conflict

func (ErrRebaseConflicts) Error added in v1.11.0

func (err ErrRebaseConflicts) Error() string

type ErrRepoFileAlreadyExists added in v1.9.0

type ErrRepoFileAlreadyExists struct {
	Path string
}

ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.

func (ErrRepoFileAlreadyExists) Error added in v1.9.0

func (err ErrRepoFileAlreadyExists) Error() string

func (ErrRepoFileAlreadyExists) Unwrap added in v1.17.4

func (err ErrRepoFileAlreadyExists) Unwrap() error

type ErrRepoFileDoesNotExist added in v1.9.0

type ErrRepoFileDoesNotExist struct {
	Path string
	Name string
}

ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.

func (ErrRepoFileDoesNotExist) Error added in v1.9.0

func (err ErrRepoFileDoesNotExist) Error() string

func (ErrRepoFileDoesNotExist) Unwrap added in v1.17.4

func (err ErrRepoFileDoesNotExist) Unwrap() error

type ErrRepoTransferInProgress added in v1.14.0

type ErrRepoTransferInProgress struct {
	Uname string
	Name  string
}

ErrRepoTransferInProgress represents the state of a repository that has an ongoing transfer

func (ErrRepoTransferInProgress) Error added in v1.14.0

func (err ErrRepoTransferInProgress) Error() string

func (ErrRepoTransferInProgress) Unwrap added in v1.17.4

func (err ErrRepoTransferInProgress) Unwrap() error

type ErrSHADoesNotMatch added in v1.9.0

type ErrSHADoesNotMatch struct {
	Path       string
	GivenSHA   string
	CurrentSHA string
}

ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.

func (ErrSHADoesNotMatch) Error added in v1.9.0

func (err ErrSHADoesNotMatch) Error() string

type ErrSHANotFound added in v1.9.0

type ErrSHANotFound struct {
	SHA string
}

ErrSHANotFound represents a "SHADoesNotMatch" kind of error.

func (ErrSHANotFound) Error added in v1.9.0

func (err ErrSHANotFound) Error() string

func (ErrSHANotFound) Unwrap added in v1.17.4

func (err ErrSHANotFound) Unwrap() error

type ErrSHAOrCommitIDNotProvided added in v1.9.0

type ErrSHAOrCommitIDNotProvided struct{}

ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.

func (ErrSHAOrCommitIDNotProvided) Error added in v1.9.0

func (err ErrSHAOrCommitIDNotProvided) Error() string

type ErrTagAlreadyExists added in v1.3.0

type ErrTagAlreadyExists struct {
	TagName string
}

ErrTagAlreadyExists represents an error that tag with such name already exists.

func (ErrTagAlreadyExists) Error added in v1.3.0

func (err ErrTagAlreadyExists) Error() string

func (ErrTagAlreadyExists) Unwrap added in v1.17.4

func (err ErrTagAlreadyExists) Unwrap() error

type ErrUpdateTaskNotExist

type ErrUpdateTaskNotExist struct {
	UUID string
}

ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.

func (ErrUpdateTaskNotExist) Error

func (err ErrUpdateTaskNotExist) Error() string

func (ErrUpdateTaskNotExist) Unwrap added in v1.17.4

func (err ErrUpdateTaskNotExist) Unwrap() error

type ErrUserCannotCommit added in v1.9.0

type ErrUserCannotCommit struct {
	UserName string
}

ErrUserCannotCommit represents "UserCannotCommit" kind of error.

func (ErrUserCannotCommit) Error added in v1.9.0

func (err ErrUserCannotCommit) Error() string

func (ErrUserCannotCommit) Unwrap added in v1.17.4

func (err ErrUserCannotCommit) Unwrap() error

type ErrUserHasOrgs

type ErrUserHasOrgs struct {
	UID int64
}

ErrUserHasOrgs represents a "UserHasOrgs" kind of error.

func (ErrUserHasOrgs) Error

func (err ErrUserHasOrgs) Error() string

type ErrUserOwnPackages added in v1.17.0

type ErrUserOwnPackages struct {
	UID int64
}

ErrUserOwnPackages notifies that the user (still) owns the packages.

func (ErrUserOwnPackages) Error added in v1.17.0

func (err ErrUserOwnPackages) Error() string

type ErrUserOwnRepos

type ErrUserOwnRepos struct {
	UID int64
}

ErrUserOwnRepos represents a "UserOwnRepos" kind of error.

func (ErrUserOwnRepos) Error

func (err ErrUserOwnRepos) Error() string

type RepoTransfer added in v1.14.0

type RepoTransfer struct {
	ID          int64 `xorm:"pk autoincr"`
	DoerID      int64
	Doer        *user_model.User `xorm:"-"`
	RecipientID int64
	Recipient   *user_model.User `xorm:"-"`
	RepoID      int64
	TeamIDs     []int64
	Teams       []*organization.Team `xorm:"-"`

	CreatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL updated"`
}

RepoTransfer is used to manage repository transfers

func GetPendingRepositoryTransfer added in v1.14.0

func GetPendingRepositoryTransfer(ctx context.Context, repo *repo_model.Repository) (*RepoTransfer, error)

GetPendingRepositoryTransfer fetches the most recent and ongoing transfer process for the repository

func (*RepoTransfer) CanUserAcceptTransfer added in v1.14.0

func (r *RepoTransfer) CanUserAcceptTransfer(u *user_model.User) bool

CanUserAcceptTransfer checks if the user has the rights to accept/decline a repo transfer. For user, it checks if it's himself For organizations, it checks if the user is able to create repos

func (*RepoTransfer) LoadAttributes added in v1.14.0

func (r *RepoTransfer) LoadAttributes(ctx context.Context) error

LoadAttributes fetches the transfer recipient from the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL