models

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAllRepositories

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

AddAllRepositories adds all repositories to the team

func AddRepository

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

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

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

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

func DoctorUserStarNum() (err error)

DoctorUserStarNum recalculate Stars number for all user

func GetYamlFixturesAccess

func GetYamlFixturesAccess() (string, error)

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

func HasRepository

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

HasRepository returns true if given repository belong to team.

func Init

func Init(ctx context.Context) error

Init initialize model

func InsertIssueComments

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

InsertIssueComments inserts many comments of issues.

func InsertIssues

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

InsertIssues insert issues to database

func InsertMilestones

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

InsertMilestones creates milestones of repository.

func InsertPullRequests

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

InsertPullRequests inserted pull requests

func InsertReleases

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

InsertReleases migrates release

func IsErrBranchAlreadyExists

func IsErrBranchAlreadyExists(err error) bool

IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.

func IsErrBranchDoesNotExist

func IsErrBranchDoesNotExist(err error) bool

IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.

func IsErrBranchNameConflict

func IsErrBranchNameConflict(err error) bool

IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.

func IsErrBranchesEqual

func IsErrBranchesEqual(err error) bool

IsErrBranchesEqual checks if an error is an ErrBranchesEqual.

func IsErrCommitIDDoesNotMatch

func IsErrCommitIDDoesNotMatch(err error) bool

IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.

func IsErrDisallowedToMerge

func IsErrDisallowedToMerge(err error) bool

IsErrDisallowedToMerge checks if an error is an ErrDisallowedToMerge.

func IsErrFilePathInvalid

func IsErrFilePathInvalid(err error) bool

IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.

func IsErrFilePathProtected

func IsErrFilePathProtected(err error) bool

IsErrFilePathProtected checks if an error is an ErrFilePathProtected.

func IsErrFilenameInvalid

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

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

func IsErrMergeConflicts(err error) bool

IsErrMergeConflicts checks if an error is a ErrMergeConflicts.

func IsErrMergeUnrelatedHistories

func IsErrMergeUnrelatedHistories(err error) bool

IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.

func IsErrNoPendingTransfer

func IsErrNoPendingTransfer(err error) bool

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

func IsErrProtectedTagName

func IsErrProtectedTagName(err error) bool

IsErrProtectedTagName checks if an error is a ErrProtectedTagName.

func IsErrPullRequestHasMerged

func IsErrPullRequestHasMerged(err error) bool

IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.

func IsErrRebaseConflicts

func IsErrRebaseConflicts(err error) bool

IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.

func IsErrRepoFileAlreadyExists

func IsErrRepoFileAlreadyExists(err error) bool

IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.

func IsErrRepoFileDoesNotExist

func IsErrRepoFileDoesNotExist(err error) bool

IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.

func IsErrRepoTransferInProgress

func IsErrRepoTransferInProgress(err error) bool

IsErrRepoTransferInProgress checks if an error is a ErrRepoTransferInProgress.

func IsErrSHADoesNotMatch

func IsErrSHADoesNotMatch(err error) bool

IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.

func IsErrSHANotFound

func IsErrSHANotFound(err error) bool

IsErrSHANotFound checks if an error is a ErrSHANotFound.

func IsErrSHAOrCommitIDNotProvided

func IsErrSHAOrCommitIDNotProvided(err error) bool

IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.

func IsErrTagAlreadyExists

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

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

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

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

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

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

func TestRepositoryReadyForTransfer

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

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

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

type ErrBranchAlreadyExists struct {
	BranchName string
}

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

func (ErrBranchAlreadyExists) Error

func (err ErrBranchAlreadyExists) Error() string

func (ErrBranchAlreadyExists) Unwrap

func (err ErrBranchAlreadyExists) Unwrap() error

type ErrBranchDoesNotExist

type ErrBranchDoesNotExist struct {
	BranchName string
}

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

func (ErrBranchDoesNotExist) Error

func (err ErrBranchDoesNotExist) Error() string

func (ErrBranchDoesNotExist) Unwrap

func (err ErrBranchDoesNotExist) Unwrap() error

type ErrBranchNameConflict

type ErrBranchNameConflict struct {
	BranchName string
}

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

func (ErrBranchNameConflict) Error

func (err ErrBranchNameConflict) Error() string

func (ErrBranchNameConflict) Unwrap

func (err ErrBranchNameConflict) Unwrap() error

type ErrBranchesEqual

type ErrBranchesEqual struct {
	BaseBranchName string
	HeadBranchName string
}

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

func (ErrBranchesEqual) Error

func (err ErrBranchesEqual) Error() string

func (ErrBranchesEqual) Unwrap

func (err ErrBranchesEqual) Unwrap() error

type ErrCommitIDDoesNotMatch

type ErrCommitIDDoesNotMatch struct {
	GivenCommitID   string
	CurrentCommitID string
}

ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.

func (ErrCommitIDDoesNotMatch) Error

func (err ErrCommitIDDoesNotMatch) Error() string

type ErrDisallowedToMerge

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

func (err ErrDisallowedToMerge) Error() string

func (ErrDisallowedToMerge) Unwrap

func (err ErrDisallowedToMerge) Unwrap() error

type ErrFilePathInvalid

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

ErrFilePathInvalid represents a "FilePathInvalid" kind of error.

func (ErrFilePathInvalid) Error

func (err ErrFilePathInvalid) Error() string

func (ErrFilePathInvalid) Unwrap

func (err ErrFilePathInvalid) Unwrap() error

type ErrFilePathProtected

type ErrFilePathProtected struct {
	Message string
	Path    string
}

ErrFilePathProtected represents a "FilePathProtected" kind of error.

func (ErrFilePathProtected) Error

func (err ErrFilePathProtected) Error() string

func (ErrFilePathProtected) Unwrap

func (err ErrFilePathProtected) Unwrap() error

type ErrFilenameInvalid

type ErrFilenameInvalid struct {
	Path string
}

ErrFilenameInvalid represents a "FilenameInvalid" kind of error.

func (ErrFilenameInvalid) Error

func (err ErrFilenameInvalid) Error() string

func (ErrFilenameInvalid) Unwrap

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

func (err *ErrInvalidCloneAddr) Unwrap() error

type ErrInvalidMergeStyle

type ErrInvalidMergeStyle struct {
	ID    int64
	Style repo_model.MergeStyle
}

ErrInvalidMergeStyle represents an error if merging with disabled merge strategy

func (ErrInvalidMergeStyle) Error

func (err ErrInvalidMergeStyle) Error() string

func (ErrInvalidMergeStyle) Unwrap

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

func (err ErrInvalidTagName) Unwrap() error

type ErrMergeConflicts

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

func (err ErrMergeConflicts) Error() string

type ErrMergeUnrelatedHistories

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

func (err ErrMergeUnrelatedHistories) Error() string

type ErrNoPendingRepoTransfer

type ErrNoPendingRepoTransfer struct {
	RepoID int64
}

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

func (ErrNoPendingRepoTransfer) Error

func (err ErrNoPendingRepoTransfer) Error() string

func (ErrNoPendingRepoTransfer) Unwrap

func (err ErrNoPendingRepoTransfer) Unwrap() error

type ErrProtectedTagName

type ErrProtectedTagName struct {
	TagName string
}

ErrProtectedTagName represents a "ProtectedTagName" kind of error.

func (ErrProtectedTagName) Error

func (err ErrProtectedTagName) Error() string

func (ErrProtectedTagName) Unwrap

func (err ErrProtectedTagName) Unwrap() error

type ErrPullRequestHasMerged

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

ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error

func (ErrPullRequestHasMerged) Error

func (err ErrPullRequestHasMerged) Error() string

Error does pretty-printing :D

type ErrRebaseConflicts

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

func (err ErrRebaseConflicts) Error() string

type ErrRepoFileAlreadyExists

type ErrRepoFileAlreadyExists struct {
	Path string
}

ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.

func (ErrRepoFileAlreadyExists) Error

func (err ErrRepoFileAlreadyExists) Error() string

func (ErrRepoFileAlreadyExists) Unwrap

func (err ErrRepoFileAlreadyExists) Unwrap() error

type ErrRepoFileDoesNotExist

type ErrRepoFileDoesNotExist struct {
	Path string
	Name string
}

ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.

func (ErrRepoFileDoesNotExist) Error

func (err ErrRepoFileDoesNotExist) Error() string

func (ErrRepoFileDoesNotExist) Unwrap

func (err ErrRepoFileDoesNotExist) Unwrap() error

type ErrRepoTransferInProgress

type ErrRepoTransferInProgress struct {
	Uname string
	Name  string
}

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

func (ErrRepoTransferInProgress) Error

func (err ErrRepoTransferInProgress) Error() string

func (ErrRepoTransferInProgress) Unwrap

func (err ErrRepoTransferInProgress) Unwrap() error

type ErrSHADoesNotMatch

type ErrSHADoesNotMatch struct {
	Path       string
	GivenSHA   string
	CurrentSHA string
}

ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.

func (ErrSHADoesNotMatch) Error

func (err ErrSHADoesNotMatch) Error() string

type ErrSHANotFound

type ErrSHANotFound struct {
	SHA string
}

ErrSHANotFound represents a "SHADoesNotMatch" kind of error.

func (ErrSHANotFound) Error

func (err ErrSHANotFound) Error() string

func (ErrSHANotFound) Unwrap

func (err ErrSHANotFound) Unwrap() error

type ErrSHAOrCommitIDNotProvided

type ErrSHAOrCommitIDNotProvided struct{}

ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.

func (ErrSHAOrCommitIDNotProvided) Error

func (err ErrSHAOrCommitIDNotProvided) Error() string

type ErrTagAlreadyExists

type ErrTagAlreadyExists struct {
	TagName string
}

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

func (ErrTagAlreadyExists) Error

func (err ErrTagAlreadyExists) Error() string

func (ErrTagAlreadyExists) Unwrap

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

func (err ErrUpdateTaskNotExist) Unwrap() error

type ErrUserCannotCommit

type ErrUserCannotCommit struct {
	UserName string
}

ErrUserCannotCommit represents "UserCannotCommit" kind of error.

func (ErrUserCannotCommit) Error

func (err ErrUserCannotCommit) Error() string

func (ErrUserCannotCommit) Unwrap

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

type ErrUserOwnPackages struct {
	UID int64
}

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

func (ErrUserOwnPackages) Error

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

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

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

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

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