Documentation ¶
Index ¶
- Constants
- Variables
- func AddEmailAddress(email *EmailAddress) error
- func AddEmailAddresses(emails []*EmailAddress) error
- func AddOrgUser(orgID, uid int64) error
- func AddTeamMember(orgID, teamID, userID int64) error
- func AddTeamRepo(orgID, teamID, repoID int64) error
- func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool)
- func AttachmentLocalPath(uuid string) string
- func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err error)
- func ChangeMilestoneIssueStats(issue *Issue) (err error)
- func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error)
- func ChangeOrgUserStatus(orgID, uid int64, public bool) error
- func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
- func CheckPublicKeyString(content string) (_ string, err error)
- func CheckRepoStats()
- func CommentHashTag(id int64) string
- func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string
- func CountNotices() int64
- func CountOrganizations() int64
- func CountRepoClosedMilestones(repoID int64) int64
- func CountRepoMilestones(repoID int64) int64
- func CountRepositories(private bool) int64
- func CountUserRepositories(userID int64, private bool) int64
- func CreateNotice(tp NoticeType, desc string) error
- func CreateOrganization(org, owner *User) (err error)
- func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commitSHA string) error
- func CreateRepositoryNotice(desc string) error
- func CreateWebhook(w *Webhook) error
- func DeleteAttachment(a *Attachment, remove bool) error
- func DeleteAttachments(attachments []*Attachment, remove bool) (int, error)
- func DeleteAttachmentsByComment(commentId int64, remove bool) (int, error)
- func DeleteAttachmentsByIssue(issueId int64, remove bool) (int, error)
- func DeleteCollaboration(repo *Repository, userID int64) (err error)
- func DeleteCommentByID(doer *User, id int64) error
- func DeleteDeployKey(doer *User, id int64) error
- func DeleteEmailAddress(email *EmailAddress) (err error)
- func DeleteEmailAddresses(emails []*EmailAddress) (err error)
- func DeleteIssueLabel(issue *Issue, label *Label) (err error)
- func DeleteLabel(repoID, labelID int64) error
- func DeleteMilestoneOfRepoByID(repoID, id int64) error
- func DeleteMirrorByRepoID(repoID int64) error
- func DeleteMissingRepositories() error
- func DeleteNotice(id int64) error
- func DeleteNotices(start, end int64) error
- func DeleteNoticesByIDs(ids []int64) error
- func DeleteOldRepositoryArchives()
- func DeleteOrganization(org *User) error
- func DeletePublicKey(doer *User, id int64) (err error)
- func DeleteReleaseOfRepoByID(repoID, id int64) error
- func DeleteRepository(ownerID, repoID int64) error
- func DeleteRepositoryArchives() error
- func DeleteTeam(t *Team) error
- func DeleteTwoFactor(userID int64) (err error)
- func DeleteUpload(u *Upload) error
- func DeleteUploadByUUID(uuid string) error
- func DeleteUploads(uploads ...*Upload) (err error)
- func DeleteWebhookOfOrgByID(orgID, id int64) error
- func DeleteWebhookOfRepoByID(repoID, id int64) error
- func DeliverHooks()
- func DiscordLinkFormatter(url, text string) string
- func DiscordSHALinkFormatter(url, text string) string
- func DiscordTextFormatter(s string) string
- func DumpDatabase(ctx context.Context, db *gorm.DB, dirPath string, verbose bool) error
- func FilterRepositoryWithIssues(repoIDs []int64) ([]int64, error)
- func GetLabelTemplateFile(name string) ([][2]string, error)
- func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) (numOpen, numClosed int64)
- func GitFsck()
- func GitGcRepos() error
- func HandleMirrorCredentials(url string, mosaics bool) string
- func HasDeployKey(keyID, repoID int64) bool
- func HasIssueLabel(issueID, labelID int64) bool
- func HasTeamRepo(orgID, teamID, repoID int64) bool
- func ImportDatabase(ctx context.Context, db *gorm.DB, dirPath string, verbose bool) error
- func Init(w logger.Writer) (*gorm.DB, error)
- func InitDeliverHooks()
- func InitSyncMirrors()
- func InitTestPullRequests()
- func IsBranchOfRepoRequirePullRequest(repoID int64, name string) bool
- func IsCollaborator(repoID, userID int64) bool
- func IsEmailUsed(email string) (bool, error)
- func IsErrAccessTokenAlreadyExist(err error) bool
- func IsErrAccessTokenNotExist(err error) bool
- func IsErrAttachmentNotExist(err error) bool
- func IsErrBranchNotExist(err error) bool
- func IsErrCommentNotExist(err error) bool
- func IsErrDeployKeyAlreadyExist(err error) bool
- func IsErrDeployKeyNameAlreadyUsed(err error) bool
- func IsErrDeployKeyNotExist(err error) bool
- func IsErrEmailAddressNotExist(err error) bool
- func IsErrEmailAlreadyUsed(err error) bool
- func IsErrInvalidCloneAddr(err error) bool
- func IsErrInvalidTagName(err error) bool
- func IsErrIssueNotExist(err error) bool
- func IsErrKeyAccessDenied(err error) bool
- func IsErrKeyAlreadyExist(err error) bool
- func IsErrKeyNameAlreadyUsed(err error) bool
- func IsErrKeyNotExist(err error) bool
- func IsErrKeyUnableVerify(err error) bool
- func IsErrLFSObjectNotExist(err error) bool
- func IsErrLabelNotExist(err error) bool
- func IsErrLastOrgOwner(err error) bool
- func IsErrLoginSourceAlreadyExist(err error) bool
- func IsErrLoginSourceInUse(err error) bool
- func IsErrLoginSourceMismatch(err error) bool
- func IsErrLoginSourceNotExist(err error) bool
- func IsErrMilestoneNotExist(err error) bool
- func IsErrNameNotAllowed(err error) bool
- func IsErrPullRequestNotExist(err error) bool
- func IsErrReachLimitOfRepo(err error) bool
- func IsErrReleaseAlreadyExist(err error) bool
- func IsErrReleaseNotExist(err error) bool
- func IsErrRepoAlreadyExist(err error) bool
- func IsErrRepoFileAlreadyExist(err error) bool
- func IsErrRepoNotExist(err error) bool
- func IsErrTeamAlreadyExist(err error) bool
- func IsErrTeamNotExist(err error) bool
- func IsErrTwoFactorNotFound(err error) bool
- func IsErrUpdateTaskNotExist(err error) bool
- func IsErrUploadNotExist(err error) bool
- func IsErrUserAlreadyExist(err error) bool
- func IsErrUserHasOrgs(err error) bool
- func IsErrUserNotExist(err error) bool
- func IsErrUserOwnRepos(err error) bool
- func IsErrWebhookNotExist(err error) bool
- func IsErrWikiAlreadyExist(err error) bool
- func IsHookTaskNotExist(err error) bool
- func IsOrganizationMember(orgId, uid int64) bool
- func IsOrganizationOwner(orgID, userID int64) bool
- func IsPublicMembership(orgId, uid int64) bool
- func IsReleaseExist(repoID int64, tagName string) (bool, error)
- func IsRepositoryExist(u *User, repoName string) (bool, error)
- func IsStaring(userID, repoID int64) bool
- func IsTeamMember(orgID, teamID, uid int64) bool
- func IsTwoFactorRecoveryCodeNotFound(err error) bool
- func IsUsableTeamName(name string) error
- func IsUserInProtectBranchWhitelist(repoID, userID int64, branch string) bool
- func IsValidHookContentType(name string) bool
- func IsValidHookTaskType(name string) bool
- func IsWatching(userID, repoID int64) bool
- func IssuesCount(opts *IssuesOptions) (int64, error)
- func LoadRepoConfig()
- func MakeEmailPrimary(userID int64, email *EmailAddress) error
- func MarkdownLinkFormatter(link, text string) string
- func MilestoneStats(repoID int64) (open, closed int64)
- func MirrorUpdate()
- func NewEngine() (err error)
- func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error)
- func NewIssueLabel(issue *Issue, label *Label) (err error)
- func NewIssueLabels(issue *Issue, labels []*Label) (err error)
- func NewIssueUsers(repo *Repository, issue *Issue) (err error)
- func NewLabels(labels ...*Label) error
- func NewMailerIssue(issue *Issue) email.Issue
- func NewMailerRepo(repo *Repository) email.Repository
- func NewMailerUser(u *User) email.User
- func NewMilestone(m *Milestone) (err error)
- func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []string, ...) (err error)
- func NewRelease(gitRepo *git.Repository, r *Release, uuids []string) error
- func NewRepoContext()
- func NewTeam(t *Team) error
- func NewTestEngine() error
- func NotifyWatchers(act *Action) errordeprecated
- func PairsContains(ius []*IssueUser, issueId, uid int64) int
- func Ping() error
- func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) error
- func PushUpdate(opts PushUpdateOptions) (err error)
- func RegenerateRecoveryCodes(userID int64) error
- func ReinitMissingRepositories() error
- func RemoveAllWithNotice(title, path string)
- func RemoveOrgRepo(orgID, repoID int64) error
- func RemoveOrgUser(orgID, userID int64) error
- func RemoveTeamMember(orgID, teamID, uid int64) error
- func RemoveTeamRepo(teamID, repoID int64) error
- func RepoPath(userName, repoName string) stringdeprecated
- func RewriteAuthorizedKeys() errordeprecated
- func SSHKeyGenParsePublicKey(key string) (string, int, error)
- func SSHNativeParsePublicKey(keyLine string) (string, int, error)
- func SetEngine() (*gorm.DB, error)
- func SetMockAccessTokensStore(t *testing.T, mock AccessTokensStore)
- func SetMockLFSStore(t *testing.T, mock LFSStore)
- func SetMockPermsStore(t *testing.T, mock PermsStore)
- func SetMockReposStore(t *testing.T, mock ReposStore)
- func SetMockTwoFactorsStore(t *testing.T, mock TwoFactorsStore)
- func SetMockUsersStore(t *testing.T, mock UsersStore)
- func SlackLinkFormatter(url, text string) string
- func SlackShortTextFormatter(s string) string
- func SlackTextFormatter(s string) string
- func SortReleases(rels []*Release)
- func StarRepo(userID, repoID int64, star bool) (err error)deprecated
- func SyncMirrors()
- func SyncRepositoryHooks() error
- func TestPullRequests()
- func TestWebhook(repo *Repository, event HookEventType, p api.Payloader, webhookID int64) error
- func ToWikiPageName(urlString string) string
- func ToWikiPageURL(name string) string
- func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
- func UpdateComment(doer *User, c *Comment, oldContent string) (err error)
- func UpdateDeployKey(key *DeployKey) error
- func UpdateHookTask(t *HookTask) error
- func UpdateIssue(issue *Issue) error
- func UpdateIssueCols(issue *Issue, cols ...string) error
- func UpdateIssueUserByAssignee(issue *Issue) (err error)
- func UpdateIssueUserByRead(uid, issueID int64) error
- func UpdateIssueUsersByStatus(issueID int64, isClosed bool) error
- func UpdateLabel(l *Label) error
- func UpdateLocalCopyBranch(repoPath, localPath, branch string, isWiki bool) (err error)
- func UpdateMilestone(m *Milestone) error
- func UpdateMirror(m *Mirror) error
- func UpdateOrgProtectBranch(repo *Repository, protectBranch *ProtectBranch, ...) (err error)
- func UpdateProtectBranch(protectBranch *ProtectBranch) (err error)
- func UpdatePublicKey(key *PublicKey) error
- func UpdateRelease(doer *User, gitRepo *git.Repository, r *Release, isPublish bool, ...) (err error)
- func UpdateRepository(repo *Repository, visibilityChanged bool) (err error)
- func UpdateTeam(t *Team, authChanged bool) (err error)
- func UpdateWebhook(w *Webhook) error
- func UploadLocalPath(uuid string) string
- func UseRecoveryCode(_ int64, code string) error
- func WatchRepo(userID, repoID int64, watch bool) (err error)deprecated
- func WikiPath(userName, repoName string) string
- type Access
- type AccessMode
- type AccessModeOptions
- type AccessToken
- type AccessTokensStore
- type Action
- func (a *Action) AfterFind(_ *gorm.DB) error
- func (a *Action) BeforeCreate(tx *gorm.DB) error
- func (a *Action) GetActUserName() string
- func (a *Action) GetBranch() string
- func (a *Action) GetContent() string
- func (a *Action) GetCreate() time.Time
- func (a *Action) GetIssueContent() string
- func (a *Action) GetIssueInfos() []string
- func (a *Action) GetIssueTitle() string
- func (a *Action) GetOpType() int
- func (a *Action) GetRepoLink() string
- func (a *Action) GetRepoName() string
- func (a *Action) GetRepoPath() string
- func (a *Action) GetRepoUserName() string
- func (a *Action) ShortActUserName() string
- func (a *Action) ShortRepoName() string
- func (a *Action) ShortRepoPath() string
- func (a *Action) ShortRepoUserName() string
- type ActionType
- type ActionsStore
- type Attachment
- func GetAttachmentByUUID(uuid string) (*Attachment, error)
- func GetAttachmentsByCommentID(commentID int64) ([]*Attachment, error)
- func GetAttachmentsByIssueID(issueID int64) ([]*Attachment, error)
- func GetAttachmentsByReleaseID(releaseID int64) ([]*Attachment, error)
- func NewAttachment(name string, buf []byte, file multipart.File) (_ *Attachment, err error)
- type Branch
- type Collaboration
- type Collaborator
- type Comment
- func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error)
- func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, ...) (*Comment, error)
- func GetCommentByID(id int64) (*Comment, error)
- func GetCommentsByIssueID(issueID int64) ([]*Comment, error)
- func GetCommentsByIssueIDSince(issueID, since int64) ([]*Comment, error)
- func GetCommentsByRepoIDSince(repoID, since int64) ([]*Comment, error)
- func (c *Comment) APIFormat() *api.Comment
- func (c *Comment) AfterSet(colName string, _ xorm.Cell)
- func (c *Comment) BeforeInsert()
- func (c *Comment) BeforeUpdate()
- func (c *Comment) EventTag() string
- func (c *Comment) HTMLURL() string
- func (c *Comment) HashTag() string
- func (c *Comment) LoadAttributes() error
- type CommentTag
- type CommentType
- type CommitRepoOptions
- type ComposeHookEnvsOptions
- type CreateCommentOptions
- type CreateLoginSourceOptions
- type CreateRepoOptions
- type CreateRepoOptionsLegacy
- type CreateUserOptions
- type DeleteRepoFileOptions
- type DeployKey
- type DingtalkActionCard
- type DingtalkAtObject
- type DingtalkPayload
- type DiscordEmbedAuthorObject
- type DiscordEmbedFieldObject
- type DiscordEmbedFooterObject
- type DiscordEmbedObject
- type DiscordPayload
- type EmailAddress
- type EmailAddressesStore
- type Engine
- type ErrAccessTokenAlreadyExist
- type ErrAccessTokenNotExist
- type ErrAttachmentNotExist
- type ErrBranchNotExist
- type ErrCommentNotExist
- type ErrDeployKeyAlreadyExist
- type ErrDeployKeyNameAlreadyUsed
- type ErrDeployKeyNotExist
- type ErrEmailAlreadyUsed
- type ErrEmailNotExist
- type ErrHookTaskNotExist
- type ErrInvalidCloneAddr
- type ErrInvalidTagName
- type ErrIssueNotExist
- type ErrKeyAccessDenied
- type ErrKeyAlreadyExist
- type ErrKeyNameAlreadyUsed
- type ErrKeyNotExist
- type ErrKeyUnableVerify
- type ErrLFSObjectNotExist
- type ErrLabelNotExist
- type ErrLastOrgOwner
- type ErrLoginSourceAlreadyExist
- type ErrLoginSourceInUse
- type ErrLoginSourceMismatch
- type ErrLoginSourceNotExist
- type ErrMilestoneNotExist
- type ErrNameNotAllowed
- type ErrPullRequestNotExist
- type ErrReachLimitOfRepo
- type ErrReleaseAlreadyExist
- type ErrReleaseNotExist
- type ErrRepoAlreadyExist
- type ErrRepoFileAlreadyExist
- type ErrRepoNotExist
- type ErrTeamAlreadyExist
- type ErrTeamNotExist
- type ErrTwoFactorNotFound
- type ErrTwoFactorRecoveryCodeNotFound
- type ErrUpdateTaskNotExist
- type ErrUploadNotExist
- type ErrUserAlreadyExist
- type ErrUserHasOrgs
- type ErrUserNotExist
- type ErrUserOwnRepos
- type ErrWebhookNotExist
- type ErrWikiAlreadyExist
- type FilterMode
- type Follow
- type HookContentType
- type HookEvent
- type HookEventType
- type HookEvents
- type HookRequest
- type HookResponse
- type HookStatus
- type HookTask
- type HookTaskType
- type Issue
- func (issue *Issue) APIFormat() *api.Issue
- func (issue *Issue) AddLabel(doer *User, label *Label) error
- func (issue *Issue) AddLabels(doer *User, labels []*Label) error
- func (issue *Issue) AfterSet(colName string, _ xorm.Cell)
- func (issue *Issue) BeforeInsert()
- func (issue *Issue) BeforeUpdate()
- func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error)
- func (issue *Issue) ChangeContent(doer *User, content string) (err error)
- func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (err error)
- func (issue *Issue) ChangeTitle(doer *User, title string) (err error)
- func (issue *Issue) ClearLabels(doer *User) (err error)
- func (issue *Issue) GetAssignee() (err error)
- func (issue *Issue) HTMLURL() string
- func (issue *Issue) HasLabel(labelID int64) bool
- func (issue *Issue) HashTag() string
- func (issue *Issue) IsPoster(uid int64) bool
- func (issue *Issue) LoadAttributes() error
- func (issue *Issue) MailParticipants() (err error)
- func (issue *Issue) MailSubject() string
- func (issue *Issue) ReadBy(uid int64) error
- func (issue *Issue) RemoveLabel(doer *User, label *Label) error
- func (issue *Issue) ReplaceLabels(labels []*Label) (err error)
- func (issue *Issue) State() api.StateType
- type IssueLabel
- type IssueStats
- type IssueStatsOptions
- type IssueUser
- type IssuesOptions
- type KeyType
- type LFSObject
- type LFSStore
- type Label
- func GetLabelByID(id int64) (*Label, error)
- func GetLabelOfRepoByID(repoID, labelID int64) (*Label, error)
- func GetLabelOfRepoByName(repoID int64, labelName string) (*Label, error)
- func GetLabelsByIssueID(issueID int64) ([]*Label, error)
- func GetLabelsByRepoID(repoID int64) ([]*Label, error)
- func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error)
- type ListLoginSourceOptions
- type ListOrgsOptions
- type LoginSource
- func (s *LoginSource) AfterFind(_ *gorm.DB) error
- func (s *LoginSource) BeforeCreate(tx *gorm.DB) error
- func (s *LoginSource) BeforeSave(_ *gorm.DB) (err error)
- func (s *LoginSource) BeforeUpdate(tx *gorm.DB) error
- func (s *LoginSource) GitHub() *github.Config
- func (s *LoginSource) IsDLDAP() bool
- func (s *LoginSource) IsGitHub() bool
- func (s *LoginSource) IsLDAP() bool
- func (s *LoginSource) IsPAM() bool
- func (s *LoginSource) IsSMTP() bool
- func (s *LoginSource) LDAP() *ldap.Config
- func (s *LoginSource) PAM() *pam.Config
- func (s *LoginSource) SMTP() *smtp.Config
- func (s *LoginSource) TypeName() string
- type LoginSourcesStore
- type MergeStyle
- type MigrateRepoOptions
- type Milestone
- func (m *Milestone) APIFormat() *api.Milestone
- func (m *Milestone) AfterSet(colName string, _ xorm.Cell)
- func (m *Milestone) BeforeInsert()
- func (m *Milestone) BeforeUpdate()
- func (m *Milestone) ChangeStatus(isClosed bool) error
- func (m *Milestone) CountIssues(isClosed, includePulls bool) int64
- func (m *Milestone) State() api.StateType
- type Mirror
- func (m *Mirror) Address() string
- func (m *Mirror) AfterSet(colName string, _ xorm.Cell)
- func (m *Mirror) BeforeInsert()
- func (m *Mirror) BeforeUpdate()
- func (m *Mirror) MosaicsAddress() string
- func (m *Mirror) RawAddress() string
- func (m *Mirror) SaveAddress(addr string) error
- func (m *Mirror) ScheduleNextSync()
- type MirrorRepositoryList
- type MirrorSyncPushOptions
- type NewIssueOptions
- type Notice
- type NoticeType
- type OrgUser
- type Organization
- type OrgsStore
- type PermsStore
- type ProtectBranch
- type ProtectBranchWhitelist
- type PublicKey
- type PublicKeysStore
- type PullRequest
- func GetPullRequestByID(id int64) (*PullRequest, error)
- func GetPullRequestByIssueID(issueID int64) (*PullRequest, error)
- func GetUnmergedPullRequest(headRepoID, baseRepoID int64, headBranch, baseBranch string) (*PullRequest, error)
- func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequest, error)
- func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequest, error)
- func (pr *PullRequest) APIFormat() *api.PullRequest
- func (pr *PullRequest) AddToTaskQueue()
- func (pr *PullRequest) AfterSet(colName string, _ xorm.Cell)
- func (pr *PullRequest) BeforeUpdate()
- func (pr *PullRequest) CanAutoMerge() bool
- func (pr *PullRequest) IsChecking() bool
- func (pr *PullRequest) LoadAttributes() error
- func (pr *PullRequest) LoadIssue() (err error)
- func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle, ...) (err error)
- func (pr *PullRequest) PushToBaseRepo() (err error)
- func (pr *PullRequest) Update() error
- func (pr *PullRequest) UpdateCols(cols ...string) error
- func (pr *PullRequest) UpdatePatch() (err error)
- type PullRequestList
- type PullRequestStatus
- type PullRequestType
- type PushCommit
- type PushCommits
- type PushTagOptions
- type PushUpdateOptions
- type Release
- func GetDraftReleasesByRepoID(repoID int64) ([]*Release, error)
- func GetPublishedReleasesByRepoID(repoID int64, matches ...string) ([]*Release, error)
- func GetRelease(repoID int64, tagName string) (*Release, error)
- func GetReleaseByID(id int64) (*Release, error)
- func GetReleasesByRepoID(repoID int64) ([]*Release, error)
- type ReleaseSorter
- type ReposStore
- type Repository
- func CleanUpMigrateInfo(repo *Repository) (*Repository, error)
- func CreateRepository(doer, owner *User, opts CreateRepoOptionsLegacy) (_ *Repository, err error)
- func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string) (_ *Repository, err error)
- func GetNonMirrorRepositories() ([]*Repository, error)
- func GetRecentUpdatedRepositories(page, pageSize int) (repos []*Repository, err error)
- func GetRepositoriesByForkID(forkID int64) ([]*Repository, error)
- func GetRepositoryByID(id int64) (*Repository, error)
- func GetRepositoryByName(ownerID int64, name string) (*Repository, error)
- func GetRepositoryByRef(ref string) (*Repository, error)
- func GetUserAndCollaborativeRepositories(userID int64) ([]*Repository, error)
- func GetUserMirrorRepositories(userID int64) ([]*Repository, error)
- func GetUserRepositories(opts *UserRepoOptions) ([]*Repository, error)
- func HasForkedRepo(ownerID, repoID int64) (*Repository, bool, error)
- func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository, error)
- func Repositories(page, pageSize int) (_ []*Repository, err error)
- func RepositoriesWithUsers(page, pageSize int) (_ []*Repository, err error)
- func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, count int64, err error)
- func (r *Repository) APIFormat(owner *User, opts ...RepositoryAPIFormatOptions) *api.Repository
- func (repo *Repository) APIFormatLegacy(permission *api.Permission, user ...*User) *api.Repositorydeprecated
- func (repo *Repository) AddCollaborator(u *User) error
- func (repo *Repository) AddWikiPage(doer *User, title, content, message string) error
- func (r *Repository) AfterFind(_ *gorm.DB) error
- func (repo *Repository) AfterSet(colName string, _ xorm.Cell)
- func (repo *Repository) AllowsPulls() bool
- func (repo *Repository) AvatarLink() string
- func (r *Repository) BeforeCreate(tx *gorm.DB) error
- func (repo *Repository) BeforeInsert()
- func (r *Repository) BeforeUpdate(tx *gorm.DB) error
- func (repo *Repository) CanBeForked() bool
- func (repo *Repository) CanEnableEditor() bool
- func (repo *Repository) CanEnablePulls() bool
- func (repo *Repository) CanGuestViewIssues() bool
- func (repo *Repository) CanGuestViewWiki() bool
- func (repo *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessMode) error
- func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error
- func (repo *Repository) CloneLink() (cl *repoutil.CloneLink)deprecated
- func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) stringdeprecated
- func (repo *Repository) ComposeMetas() map[string]string
- func (repo *Repository) CreateNewBranch(oldBranch, newBranch string) (err error)
- func (repo *Repository) CustomAvatarPath() string
- func (repo *Repository) DeleteAvatar() error
- func (repo *Repository) DeleteCollaboration(userID int64) error
- func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error)
- func (repo *Repository) DeleteWiki()
- func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error)
- func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error
- func (repo *Repository) EditWikiPage(doer *User, oldTitle, title, content, message string) error
- func (repo *Repository) FullName() string
- func (repo *Repository) GetAssigneeByID(userID int64) (*User, error)
- func (repo *Repository) GetAssignees() (_ []*User, err error)
- func (repo *Repository) GetBranch(name string) (*Branch, error)
- func (repo *Repository) GetBranches() ([]*Branch, error)
- func (repo *Repository) GetCollaborators() ([]*Collaborator, error)
- func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *gitutil.Diff, err error)
- func (repo *Repository) GetForks() ([]*Repository, error)
- func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error)
- func (repo *Repository) GetMirror() (err error)
- func (repo *Repository) GetOwner() error
- func (repo *Repository) GetStargazers(page int) ([]*User, error)
- func (repo *Repository) GetTags() ([]*Tag, error)
- func (repo *Repository) GetWatchers(page int) ([]*User, error)
- func (repo *Repository) GetWriters() (_ []*User, err error)
- func (repo *Repository) GitConfigPath() string
- func (repo *Repository) HTMLURL() stringdeprecated
- func (repo *Repository) HasAccess(userID int64) bool
- func (repo *Repository) HasWiki() bool
- func (repo *Repository) InitWiki() error
- func (repo *Repository) IsBranchRequirePullRequest(name string) bool
- func (repo *Repository) IsCollaborator(userID int64) bool
- func (repo *Repository) IsOwnedBy(userID int64) bool
- func (repo *Repository) IsPartialPublic() bool
- func (repo *Repository) IssueStats(userID int64, filterMode FilterMode, isPull bool) (int64, int64)
- func (repo *Repository) Link() string
- func (repo *Repository) LoadAttributes() error
- func (repo *Repository) LocalCopyPath() string
- func (repo *Repository) LocalWikiPath() string
- func (repo *Repository) MustOwner() *User
- func (repo *Repository) NextIssueIndex() int64
- func (repo *Repository) PatchPath(index int64) (string, error)
- func (repo *Repository) RecalculateAccesses() error
- func (repo *Repository) RelAvatarLink() string
- func (repo *Repository) RelLink() string
- func (repo *Repository) RepoPath() stringdeprecated
- func (repo *Repository) SavePatch(index int64, patch []byte) error
- func (repo *Repository) UpdateLocalCopyBranch(branch string) error
- func (repo *Repository) UpdateLocalWiki() error
- func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error)
- func (repo *Repository) UpdateSize() error
- func (repo *Repository) UploadAvatar(data []byte) error
- func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) error
- func (repo *Repository) WikiCloneLink() (cl *repoutil.CloneLink)deprecated
- func (repo *Repository) WikiPath() string
- type RepositoryAPIFormatOptions
- type RepositoryList
- type SearchRepoOptions
- type SlackAttachment
- type SlackMeta
- type SlackPayload
- type Star
- type Statistic
- type Tag
- type Team
- func GetTeamByID(teamID int64) (*Team, error)
- func GetTeamOfOrgByName(orgID int64, name string) (*Team, error)
- func GetTeamsByOrgID(orgID int64) ([]*Team, error)
- func GetTeamsHaveAccessToRepo(orgID, repoID int64, mode AccessMode) ([]*Team, error)
- func GetUserTeams(orgID, userID int64) ([]*Team, error)
- func (t *Team) AddMember(uid int64) error
- func (t *Team) AddRepository(repo *Repository) (err error)
- func (t *Team) AfterSet(colName string, _ xorm.Cell)
- func (t *Team) GetMembers() (err error)
- func (t *Team) GetRepositories() error
- func (t *Team) HasRepository(repoID int64) bool
- func (t *Team) HasWriteAccess() bool
- func (t *Team) IsMember(userID int64) bool
- func (t *Team) IsOwnerTeam() bool
- func (t *Team) RemoveMember(uid int64) error
- func (t *Team) RemoveRepository(repoID int64) error
- type TeamRepo
- type TeamUser
- type TwoFactor
- type TwoFactorRecoveryCode
- type TwoFactorsStore
- type UpdateRepoFileOptions
- type UpdateUserOptions
- type Upload
- type UploadRepoFileOptions
- type User
- func GetOrgByName(name string) (*User, error)
- func GetOrgsByUserID(userID int64, showAll bool) ([]*User, error)
- func GetOwnedOrgsByUserID(userID int64) ([]*User, error)
- func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error)
- func GetParticipantsByIssueID(issueID int64) ([]*User, error)
- func GetTeamMembers(teamID int64) ([]*User, error)
- func NewGhostUser() *User
- func Organizations(page, pageSize int) ([]*User, error)
- func (u *User) APIFormat() *api.User
- func (org *User) AddMember(uid int64) error
- func (u *User) AfterFind(_ *gorm.DB) error
- func (u *User) AvatarURL() string
- func (u *User) AvatarURLPath() string
- func (u *User) BeforeCreate(tx *gorm.DB) error
- func (u *User) CanCreateOrganization() bool
- func (u *User) CanEditGitHook() bool
- func (u *User) CanImportLocal() bool
- func (u *User) DisplayName() string
- func (org *User) GetMembers(limit int) error
- func (u *User) GetOrganizationCount() (int64, error)
- func (org *User) GetOwnerTeam() (*Team, error)
- func (org *User) GetTeam(name string) (*Team, error)
- func (org *User) GetTeams() error
- func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)
- func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repository, int64, error)
- func (org *User) GetUserTeamIDs(userID int64) ([]int64, error)
- func (org *User) GetUserTeams(userID int64) ([]*Team, error)
- func (u *User) HTMLURL() string
- func (u *User) HomeURLPath() string
- func (u *User) IsFollowing(followID int64) bool
- func (u *User) IsLocal() bool
- func (org *User) IsOrgMember(uid int64) bool
- func (u *User) IsOrganization() bool
- func (org *User) IsOwnedBy(userID int64) bool
- func (u *User) IsPublicMember(orgId int64) bool
- func (u *User) IsUserOrgOwner(orgId int64) bool
- func (org *User) RemoveMember(uid int64) error
- func (org *User) RemoveOrgRepo(repoID int64) error
- func (u *User) ShortName(length int) string
- func (org *User) TeamsHaveAccessToRepo(repoID int64, mode AccessMode) ([]*Team, error)
- type UserRepoOptions
- type UserType
- type UsersStore
- type Version
- type Watch
- type Webhook
- func (w *Webhook) AfterSet(colName string, _ xorm.Cell)
- func (w *Webhook) BeforeInsert()
- func (w *Webhook) BeforeUpdate()
- func (w *Webhook) EventsArray() []string
- func (w *Webhook) HasCreateEvent() bool
- func (w *Webhook) HasDeleteEvent() bool
- func (w *Webhook) HasForkEvent() bool
- func (w *Webhook) HasIssueCommentEvent() bool
- func (w *Webhook) HasIssuesEvent() bool
- func (w *Webhook) HasPullRequestEvent() bool
- func (w *Webhook) HasPushEvent() bool
- func (w *Webhook) HasReleaseEvent() bool
- func (w *Webhook) History(page int) ([]*HookTask, error)
- func (w *Webhook) SlackMeta() *SlackMeta
- func (w *Webhook) UpdateEvent() error
Constants ¶
const ( ENV_AUTH_USER_ID = "GOGS_AUTH_USER_ID" ENV_AUTH_USER_NAME = "GOGS_AUTH_USER_NAME" ENV_AUTH_USER_EMAIL = "GOGS_AUTH_USER_EMAIL" ENV_REPO_OWNER_NAME = "GOGS_REPO_OWNER_NAME" ENV_REPO_OWNER_SALT_MD5 = "GOGS_REPO_OWNER_SALT_MD5" ENV_REPO_ID = "GOGS_REPO_ID" ENV_REPO_NAME = "GOGS_REPO_NAME" ENV_REPO_CUSTOM_HOOKS_PATH = "GOGS_REPO_CUSTOM_HOOKS_PATH" )
const ( KEY_TYPE_USER = iota + 1 KEY_TYPE_DEPLOY )
const ( HOOK_STATUS_NONE = iota HOOK_STATUS_SUCCEED HOOK_STATUS_FAILED )
const (
DingtalkNotificationTitle = "Gogs Notification"
)
const OWNER_TEAM = "Owners"
const REPO_AVATAR_URL_PREFIX = "repo-avatars"
REPO_AVATAR_URL_PREFIX is used to identify a URL is to access repository avatar.
Variables ¶
var (
Gitignores, Licenses, Readmes, LabelTemplates []string
// Maximum items per page in forks, watchers and stars of a repo
ItemsPerPage = 40
)
var ErrMissingIssueNumber = errors.New("No issue number specified")
var ErrOrgNotExist = errors.New("Organization does not exist")
var (
HasEngine bool
)
var HookQueue = sync.NewUniqueQueue(1000)
var MirrorQueue = sync.NewUniqueQueue(1000)
var PullRequestQueue = sync.NewUniqueQueue(1000)
var Tables = []any{ new(Access), new(AccessToken), new(Action), new(Follow), new(LFSObject), new(LoginSource), }
Tables is the list of struct-to-table mappings.
NOTE: Lines are sorted in alphabetical order, each letter in its own line.
Functions ¶
func AddEmailAddress ¶
func AddEmailAddress(email *EmailAddress) error
func AddEmailAddresses ¶
func AddEmailAddresses(emails []*EmailAddress) error
func AddOrgUser ¶
AddOrgUser adds new user to given organization.
func AddTeamMember ¶
AddTeamMember adds new membership of given team to given organization, the user will have membership to given organization automatically when needed.
func AddTeamRepo ¶
AddTeamRepo adds new repository relation to team.
func AddTestPullRequestTask ¶
AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch, and generate new patch for testing as needed.
func AttachmentLocalPath ¶
AttachmentLocalPath returns where attachment is stored in local file system based on given UUID.
func ChangeMilestoneAssign ¶
ChangeMilestoneAssign changes assignment of milestone for issue.
func ChangeMilestoneIssueStats ¶
ChangeMilestoneIssueStats updates the open/closed issues counter and progress for the milestone associated with the given issue.
func ChangeMilestoneStatus ¶
ChangeMilestoneStatus changes the milestone open/closed status. If milestone passes with changed values, those values will be updated to database as well.
func ChangeOrgUserStatus ¶
ChangeOrgUserStatus changes public or private membership status.
func ChangeRepositoryName ¶
ChangeRepositoryName changes all corresponding setting from old repository name to new one.
func CheckPublicKeyString ¶
CheckPublicKeyString checks if the given public key string is recognized by SSH. It returns the actual public key line on success.
func CheckRepoStats ¶
func CheckRepoStats()
func CommentHashTag ¶
func ComposeHookEnvs ¶
func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string
func CountOrganizations ¶
func CountOrganizations() int64
CountOrganizations returns number of organizations.
func CountRepoClosedMilestones ¶
CountRepoClosedMilestones returns number of closed milestones in given repository.
func CountRepoMilestones ¶
CountRepoMilestones returns number of milestones in given repository.
func CountRepositories ¶
CountRepositories returns number of repositories. Argument private only takes effect when it is false, set it true to count all repositories.
func CountUserRepositories ¶
CountUserRepositories returns number of repositories user owns. Argument private only takes effect when it is false, set it true to count all repositories.
func CreateNotice ¶
func CreateNotice(tp NoticeType, desc string) error
CreateNotice creates new system notice.
func CreateOrganization ¶
CreateOrganization creates record of a new organization.
func CreateRefComment ¶
func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commitSHA string) error
CreateRefComment creates a commit reference comment to issue.
func CreateRepositoryNotice ¶
CreateRepositoryNotice creates new system notice with type NOTICE_REPOSITORY.
func DeleteAttachment ¶
func DeleteAttachment(a *Attachment, remove bool) error
DeleteAttachment deletes the given attachment and optionally the associated file.
func DeleteAttachments ¶
func DeleteAttachments(attachments []*Attachment, remove bool) (int, error)
DeleteAttachments deletes the given attachments and optionally the associated files.
func DeleteAttachmentsByComment ¶
DeleteAttachmentsByComment deletes all attachments associated with the given comment.
func DeleteAttachmentsByIssue ¶
DeleteAttachmentsByIssue deletes all attachments associated with the given issue.
func DeleteCollaboration ¶
func DeleteCollaboration(repo *Repository, userID int64) (err error)
DeleteCollaboration removes collaboration relation between the user and repository.
func DeleteCommentByID ¶
DeleteCommentByID deletes the comment by given ID.
func DeleteDeployKey ¶
DeleteDeployKey deletes deploy key from its repository authorized_keys file if needed.
func DeleteEmailAddress ¶
func DeleteEmailAddress(email *EmailAddress) (err error)
func DeleteEmailAddresses ¶
func DeleteEmailAddresses(emails []*EmailAddress) (err error)
func DeleteIssueLabel ¶
DeleteIssueLabel deletes issue-label relation.
func DeleteLabel ¶
DeleteLabel delete a label of given repository.
func DeleteMilestoneOfRepoByID ¶
DeleteMilestoneOfRepoByID deletes a milestone from a repository.
func DeleteMirrorByRepoID ¶
func DeleteMissingRepositories ¶
func DeleteMissingRepositories() error
DeleteMissingRepositories deletes all repository records that lost Git files.
func DeleteNotice ¶
DeleteNotice deletes a system notice by given ID.
func DeleteNotices ¶
DeleteNotices deletes all notices with ID from start to end (inclusive).
func DeleteNoticesByIDs ¶
DeleteNoticesByIDs deletes notices by given IDs.
func DeleteOldRepositoryArchives ¶
func DeleteOldRepositoryArchives()
func DeleteOrganization ¶
DeleteOrganization completely and permanently deletes everything of organization.
func DeletePublicKey ¶
DeletePublicKey deletes SSH key information both in database and authorized_keys file.
func DeleteReleaseOfRepoByID ¶
DeleteReleaseOfRepoByID deletes a release and corresponding Git tag by given ID.
func DeleteRepository ¶
DeleteRepository deletes a repository for a user or organization.
func DeleteRepositoryArchives ¶
func DeleteRepositoryArchives() error
DeleteRepositoryArchives deletes all repositories' archives.
func DeleteTeam ¶
DeleteTeam deletes given team. It's caller's responsibility to assign organization ID.
func DeleteTwoFactor ¶
DeleteTwoFactor removes two-factor authentication token and recovery codes of given user.
func DeleteUpload ¶
func DeleteUploadByUUID ¶
func DeleteUploads ¶
func DeleteWebhookOfOrgByID ¶
DeleteWebhookOfOrgByID deletes webhook of organization by given ID.
func DeleteWebhookOfRepoByID ¶
DeleteWebhookOfRepoByID deletes webhook of repository by given ID.
func DeliverHooks ¶
func DeliverHooks()
DeliverHooks checks and delivers undelivered hooks. TODO: shoot more hooks at same time.
func DiscordLinkFormatter ¶
func DiscordSHALinkFormatter ¶
func DiscordTextFormatter ¶
func DumpDatabase ¶
DumpDatabase dumps all data from database to file system in JSON Lines format.
func FilterRepositoryWithIssues ¶
FilterRepositoryWithIssues selects repositories that are using internal issue tracker and has disabled external tracker from given set. It returns nil if result set is empty.
func GetLabelTemplateFile ¶
GetLabelTemplateFile loads the label template file by given name, then parses and returns a list of name-color pairs.
func GetRepoIssueStats ¶
func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) (numOpen, numClosed int64)
GetRepoIssueStats returns number of open and closed repository issues by given filter mode.
func GitGcRepos ¶
func GitGcRepos() error
func HandleMirrorCredentials ¶
HandleMirrorCredentials replaces user credentials from HTTP/HTTPS URL with placeholder <credentials>. It returns original string if protocol is not HTTP/HTTPS. TODO(unknwon): Use url.Parse.
func HasDeployKey ¶
HasDeployKey returns true if public key is a deploy key of given repository.
func HasIssueLabel ¶
HasIssueLabel returns true if issue has been labeled.
func HasTeamRepo ¶
HasTeamRepo returns true if given team has access to the repository of the organization.
func ImportDatabase ¶
ImportDatabase imports data from backup archive in JSON Lines format.
func InitDeliverHooks ¶
func InitDeliverHooks()
func InitSyncMirrors ¶
func InitSyncMirrors()
func InitTestPullRequests ¶
func InitTestPullRequests()
func IsBranchOfRepoRequirePullRequest ¶
IsBranchOfRepoRequirePullRequest returns true if branch requires pull request in given repository.
func IsCollaborator ¶
IsCollaborator returns true if the user is a collaborator of the repository.
func IsEmailUsed ¶
IsEmailUsed returns true if the email has been used.
func IsErrAccessTokenNotExist ¶
IsErrAccessTokenNotExist returns true if the underlying error has the type ErrAccessTokenNotExist.
func IsErrAttachmentNotExist ¶
func IsErrBranchNotExist ¶
func IsErrCommentNotExist ¶
func IsErrDeployKeyNotExist ¶
func IsErrEmailAddressNotExist ¶ added in v0.13.0
IsErrEmailAddressNotExist returns true if the underlying error has the type ErrEmailNotExist.
func IsErrEmailAlreadyUsed ¶
IsErrEmailAlreadyUsed returns true if the underlying error has the type ErrEmailAlreadyUsed.
func IsErrInvalidCloneAddr ¶
func IsErrInvalidTagName ¶
func IsErrIssueNotExist ¶
func IsErrKeyAccessDenied ¶
func IsErrKeyAlreadyExist ¶
func IsErrKeyNameAlreadyUsed ¶
func IsErrKeyNotExist ¶
func IsErrKeyUnableVerify ¶
func IsErrLFSObjectNotExist ¶
func IsErrLabelNotExist ¶
func IsErrLastOrgOwner ¶
func IsErrLoginSourceInUse ¶
func IsErrLoginSourceMismatch ¶ added in v0.13.0
IsErrLoginSourceMismatch returns true if the underlying error has the type ErrLoginSourceMismatch.
func IsErrMilestoneNotExist ¶
func IsErrNameNotAllowed ¶
IsErrNameNotAllowed returns true if the underlying error has the type ErrNameNotAllowed.
func IsErrReachLimitOfRepo ¶
func IsErrReleaseNotExist ¶
func IsErrRepoAlreadyExist ¶
func IsErrRepoNotExist ¶
func IsErrTeamAlreadyExist ¶
func IsErrTeamNotExist ¶
func IsErrTwoFactorNotFound ¶
func IsErrUpdateTaskNotExist ¶
func IsErrUploadNotExist ¶
func IsErrUserAlreadyExist ¶
IsErrUserAlreadyExist returns true if the underlying error has the type ErrUserAlreadyExist.
func IsErrUserHasOrgs ¶
IsErrUserHasOrgs returns true if the underlying error has the type ErrUserHasOrgs.
func IsErrUserNotExist ¶
IsErrUserNotExist returns true if the underlying error has the type ErrUserNotExist.
func IsErrUserOwnRepos ¶
IsErrUserOwnRepos returns true if the underlying error has the type ErrUserOwnRepos.
func IsErrWebhookNotExist ¶
func IsErrWikiAlreadyExist ¶
func IsHookTaskNotExist ¶
func IsOrganizationMember ¶
IsOrganizationMember returns true if given user is member of organization.
func IsOrganizationOwner ¶
IsOrganizationOwner returns true if given user is in the owner team.
func IsPublicMembership ¶
IsPublicMembership returns true if given user public his/her membership.
func IsReleaseExist ¶
IsReleaseExist returns true if release with given tag name already exists.
func IsRepositoryExist ¶
IsRepositoryExist returns true if the repository with given name under user has already existed.
func IsTeamMember ¶
IsTeamMember returns true if given user is a member of team.
func IsUsableTeamName ¶
IsUsableTeamName return an error if given name is a reserved name or pattern.
func IsUserInProtectBranchWhitelist ¶
IsUserInProtectBranchWhitelist returns true if given user is in the whitelist of a branch in a repository.
func IsValidHookContentType ¶
IsValidHookContentType returns true if given name is a valid hook content type.
func IsValidHookTaskType ¶
IsValidHookTaskType returns true if given name is a valid hook task type.
func IsWatching ¶
IsWatching checks if user has watched given repository.
func IssuesCount ¶
func IssuesCount(opts *IssuesOptions) (int64, error)
IssuesCount returns the number of issues by given conditions.
func LoadRepoConfig ¶
func LoadRepoConfig()
func MakeEmailPrimary ¶
func MakeEmailPrimary(userID int64, email *EmailAddress) error
func MarkdownLinkFormatter ¶
MarkdownLinkFormatter formats link address and title into Markdown style.
func MilestoneStats ¶
MilestoneStats returns number of open and closed milestones of given repository.
func NewIssue ¶
func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error)
NewIssue creates new issue with labels and attachments for repository.
func NewIssueLabel ¶
NewIssueLabel creates a new issue-label relation.
func NewIssueLabels ¶
NewIssueLabels creates a list of issue-label relations.
func NewIssueUsers ¶
func NewIssueUsers(repo *Repository, issue *Issue) (err error)
NewIssueUsers adds new issue-user relations for new issue of repository.
func NewMailerIssue ¶
func NewMailerRepo ¶
func NewMailerRepo(repo *Repository) email.Repository
func NewMailerUser ¶
func NewMilestone ¶
NewMilestone creates new milestone of repository.
func NewPullRequest ¶
func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []string, pr *PullRequest, patch []byte) (err error)
NewPullRequest creates new pull request with labels for repository.
func NewRelease ¶
NewRelease creates a new release with attachments for repository.
func NewRepoContext ¶
func NewRepoContext()
func NewTeam ¶
NewTeam creates a record of new team. It's caller's responsibility to assign organization ID.
func NewTestEngine ¶
func NewTestEngine() error
func NotifyWatchers
deprecated
func PairsContains ¶
PairsContains returns true when pairs list contains given issue.
func PrepareWebhooks ¶
func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) error
PrepareWebhooks adds all active webhooks to task queue.
func PushUpdate ¶
func PushUpdate(opts PushUpdateOptions) (err error)
PushUpdate must be called for any push actions in order to generates necessary push action history feeds.
func RegenerateRecoveryCodes ¶
RegenerateRecoveryCodes regenerates new set of recovery codes for given user.
func ReinitMissingRepositories ¶
func ReinitMissingRepositories() error
ReinitMissingRepositories reinitializes all repository records that lost Git files.
func RemoveAllWithNotice ¶
func RemoveAllWithNotice(title, path string)
RemoveAllWithNotice removes all directories in given path and creates a system notice when error occurs.
func RemoveOrgRepo ¶
RemoveOrgRepo removes all team-repository relations of given organization.
func RemoveOrgUser ¶
RemoveOrgUser removes user from given organization.
func RemoveTeamMember ¶
RemoveTeamMember removes member from given team of given organization.
func RemoveTeamRepo ¶
RemoveTeamRepo deletes repository relation to team.
func RewriteAuthorizedKeys
deprecated
func RewriteAuthorizedKeys() error
RewriteAuthorizedKeys removes any authorized key and rewrite all keys from database again. Note: x.Iterate does not get latest data after insert/delete, so we have to call this function outside any session scope independently.
Deprecated: Use PublicKeys.RewriteAuthorizedKeys instead.
func SSHKeyGenParsePublicKey ¶
SSHKeyGenParsePublicKey extracts key type and length using ssh-keygen.
func SSHNativeParsePublicKey ¶
SSHNativeParsePublicKey extracts the key type and length using the golang SSH library.
func SetMockAccessTokensStore ¶
func SetMockAccessTokensStore(t *testing.T, mock AccessTokensStore)
func SetMockLFSStore ¶
func SetMockPermsStore ¶
func SetMockPermsStore(t *testing.T, mock PermsStore)
func SetMockReposStore ¶
func SetMockReposStore(t *testing.T, mock ReposStore)
func SetMockTwoFactorsStore ¶
func SetMockTwoFactorsStore(t *testing.T, mock TwoFactorsStore)
func SetMockUsersStore ¶
func SetMockUsersStore(t *testing.T, mock UsersStore)
func SlackLinkFormatter ¶
func SlackShortTextFormatter ¶
func SlackTextFormatter ¶
func SortReleases ¶
func SortReleases(rels []*Release)
SortReleases sorts releases by number of commits and created time.
func SyncMirrors ¶
func SyncMirrors()
SyncMirrors checks and syncs mirrors. TODO: sync more mirrors at same time.
func SyncRepositoryHooks ¶
func SyncRepositoryHooks() error
SyncRepositoryHooks rewrites all repositories' pre-receive, update and post-receive hooks to make sure the binary and custom conf path are up-to-date.
func TestPullRequests ¶
func TestPullRequests()
TestPullRequests checks and tests untested patches of pull requests. TODO: test more pull requests at same time.
func TestWebhook ¶
func TestWebhook(repo *Repository, event HookEventType, p api.Payloader, webhookID int64) error
TestWebhook adds the test webhook matches the ID to task queue.
func ToWikiPageName ¶
ToWikiPageName formats a URL back to corresponding wiki page name, and removes leading characters './' to prevent changing files that are not belong to wiki repository.
func ToWikiPageURL ¶
ToWikiPageURL formats a string to corresponding wiki URL name.
func TransferOwnership ¶
func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
TransferOwnership transfers all corresponding setting from old user to new one.
func UpdateComment ¶
UpdateComment updates information of comment.
func UpdateDeployKey ¶
UpdateDeployKey updates deploy key information.
func UpdateHookTask ¶
UpdateHookTask updates information of hook task.
func UpdateIssue ¶
UpdateIssue updates all fields of given issue.
func UpdateIssueCols ¶
UpdateIssueCols only updates values of specific columns for given issue.
func UpdateIssueUserByAssignee ¶
UpdateIssueUserByAssignee updates issue-user relation for assignee.
func UpdateIssueUserByRead ¶
UpdateIssueUserByRead updates issue-user relation for reading.
func UpdateIssueUsersByStatus ¶
UpdateIssueUsersByStatus updates issue-user relations by issue status.
func UpdateLocalCopyBranch ¶
UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath. It creates a new clone if local copy does not exist, but does not checks out to a specific branch if the local copy belongs to a wiki. For existing local copy, it checks out to target branch by default, and safe to assume subsequent operations are against target branch when caller has confidence about no race condition.
func UpdateMilestone ¶
UpdateMilestone updates information of given milestone.
func UpdateMirror ¶
func UpdateOrgProtectBranch ¶
func UpdateOrgProtectBranch(repo *Repository, protectBranch *ProtectBranch, whitelistUserIDs, whitelistTeamIDs string) (err error)
UpdateOrgProtectBranch saves branch protection options of organizational 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 UpdateProtectBranch ¶
func UpdateProtectBranch(protectBranch *ProtectBranch) (err error)
UpdateProtectBranch saves branch protection options. If ID is 0, it creates a new record. Otherwise, updates existing record.
func UpdatePublicKey ¶
UpdatePublicKey updates given public key.
func UpdateRelease ¶
func UpdateRelease(doer *User, gitRepo *git.Repository, r *Release, isPublish bool, uuids []string) (err error)
UpdateRelease updates information of a release.
func UpdateRepository ¶
func UpdateRepository(repo *Repository, visibilityChanged bool) (err error)
func UpdateTeam ¶
UpdateTeam updates information of team.
func UpdateWebhook ¶
UpdateWebhook updates information of webhook.
func UploadLocalPath ¶
UploadLocalPath returns where uploads is stored in local file system based on given UUID.
func UseRecoveryCode ¶
UseRecoveryCode validates recovery code of given user and marks it is used if valid.
Types ¶
type Access ¶
type Access struct { ID int64 `gorm:"primaryKey"` UserID int64 `xorm:"UNIQUE(s)" gorm:"uniqueIndex:access_user_repo_unique;not null"` RepoID int64 `xorm:"UNIQUE(s)" gorm:"uniqueIndex:access_user_repo_unique;not null"` Mode AccessMode `gorm:"not null"` }
Access represents the highest access level of a user has to a repository. The only access type that is not in this table is the real owner of a repository. In case of an organization repository, the members of the owners team are in this table.
type AccessMode ¶
type AccessMode int
AccessMode is the access mode of a user has to a repository.
const ( AccessModeNone AccessMode = iota // 0 AccessModeRead // 1 AccessModeWrite // 2 AccessModeAdmin // 3 AccessModeOwner // 4 )
func ParseAccessMode ¶
func ParseAccessMode(permission string) AccessMode
ParseAccessMode returns corresponding access mode to given permission string.
func (AccessMode) String ¶
func (mode AccessMode) String() string
type AccessModeOptions ¶ added in v0.12.4
type AccessToken ¶
type AccessToken struct { ID int64 `gorm:"primarykey"` UserID int64 `xorm:"uid" gorm:"column:uid;index"` Name string Sha1 string `gorm:"type:VARCHAR(40);unique"` SHA256 string `gorm:"type:VARCHAR(64);unique;not null"` Created time.Time `gorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `gorm:"-" json:"-"` UpdatedUnix int64 HasRecentActivity bool `gorm:"-" json:"-"` HasUsed bool `gorm:"-" json:"-"` }
AccessToken is a personal access token.
func (*AccessToken) AfterFind ¶
func (t *AccessToken) AfterFind(tx *gorm.DB) error
AfterFind implements the GORM query hook.
func (*AccessToken) BeforeCreate ¶
func (t *AccessToken) BeforeCreate(tx *gorm.DB) error
BeforeCreate implements the GORM create hook.
type AccessTokensStore ¶
type AccessTokensStore interface { // Create creates a new access token and persist to database. It returns // ErrAccessTokenAlreadyExist when an access token with same name already exists // for the user. Create(ctx context.Context, userID int64, name string) (*AccessToken, error) // DeleteByID deletes the access token by given ID. // // 🚨 SECURITY: The "userID" is required to prevent attacker deletes arbitrary // access token that belongs to another user. DeleteByID(ctx context.Context, userID, id int64) error // GetBySHA1 returns the access token with given SHA1. It returns // ErrAccessTokenNotExist when not found. GetBySHA1(ctx context.Context, sha1 string) (*AccessToken, error) // List returns all access tokens belongs to given user. List(ctx context.Context, userID int64) ([]*AccessToken, error) // Touch updates the updated time of the given access token to the current time. Touch(ctx context.Context, id int64) error }
AccessTokensStore is the persistent interface for access tokens.
var AccessTokens AccessTokensStore
type Action ¶
type Action struct { ID int64 `gorm:"primaryKey"` UserID int64 `gorm:"index"` // Receiver user ID OpType ActionType ActUserID int64 // Doer user ID ActUserName string // Doer user name ActAvatar string `xorm:"-" gorm:"-" json:"-"` RepoID int64 `xorm:"INDEX" gorm:"index"` RepoUserName string RepoName string RefName string IsPrivate bool `xorm:"NOT NULL DEFAULT false" gorm:"not null;default:FALSE"` Content string `xorm:"TEXT"` Created time.Time `xorm:"-" gorm:"-" json:"-"` CreatedUnix int64 }
Action is a user operation to a repository. It implements template.Actioner interface to be able to use it in template rendering.
func (*Action) BeforeCreate ¶ added in v0.13.0
BeforeCreate implements the GORM create hook.
func (*Action) GetActUserName ¶
func (*Action) GetContent ¶
func (*Action) GetIssueContent ¶
func (*Action) GetIssueInfos ¶
func (*Action) GetIssueTitle ¶
func (*Action) GetRepoLink ¶
func (*Action) GetRepoName ¶
func (*Action) GetRepoPath ¶
func (*Action) GetRepoUserName ¶
func (*Action) ShortActUserName ¶
func (*Action) ShortRepoName ¶
func (*Action) ShortRepoPath ¶
func (*Action) ShortRepoUserName ¶
type ActionType ¶
type ActionType int
ActionType is the type of an action.
const ( ActionCreateRepo ActionType = iota + 1 // 1 ActionRenameRepo // 2 ActionStarRepo // 3 ActionWatchRepo // 4 ActionCommitRepo // 5 ActionCreateIssue // 6 ActionCreatePullRequest // 7 ActionTransferRepo // 8 ActionPushTag // 9 ActionCommentIssue // 10 ActionMergePullRequest // 11 ActionCloseIssue // 12 ActionReopenIssue // 13 ActionClosePullRequest // 14 ActionReopenPullRequest // 15 ActionCreateBranch // 16 ActionDeleteBranch // 17 ActionDeleteTag // 18 ActionForkRepo // 19 ActionMirrorSyncPush // 20 ActionMirrorSyncCreate // 21 ActionMirrorSyncDelete // 22 )
⚠️ WARNING: Only append to the end of list to maintain backward compatibility.
type ActionsStore ¶ added in v0.13.0
type ActionsStore interface { // CommitRepo creates actions for pushing commits to the repository. An action // with the type ActionDeleteBranch is created if the push deletes a branch; an // action with the type ActionCommitRepo is created for a regular push. If the // regular push also creates a new branch, then another action with type // ActionCreateBranch is created. CommitRepo(ctx context.Context, opts CommitRepoOptions) error // ListByOrganization returns actions of the organization viewable by the actor. // Results are paginated if `afterID` is given. ListByOrganization(ctx context.Context, orgID, actorID, afterID int64) ([]*Action, error) // ListByUser returns actions of the user viewable by the actor. Results are // paginated if `afterID` is given. The `isProfile` indicates whether repository // permissions should be considered. ListByUser(ctx context.Context, userID, actorID, afterID int64, isProfile bool) ([]*Action, error) // MergePullRequest creates an action for merging a pull request. MergePullRequest(ctx context.Context, doer, owner *User, repo *Repository, pull *Issue) error // MirrorSyncCreate creates an action for mirror synchronization of a new // reference. MirrorSyncCreate(ctx context.Context, owner *User, repo *Repository, refName string) error // MirrorSyncDelete creates an action for mirror synchronization of a reference // deletion. MirrorSyncDelete(ctx context.Context, owner *User, repo *Repository, refName string) error // MirrorSyncPush creates an action for mirror synchronization of pushed // commits. MirrorSyncPush(ctx context.Context, opts MirrorSyncPushOptions) error // NewRepo creates an action for creating a new repository. The action type // could be ActionCreateRepo or ActionForkRepo based on whether the repository // is a fork. NewRepo(ctx context.Context, doer, owner *User, repo *Repository) error // PushTag creates an action for pushing tags to the repository. An action with // the type ActionDeleteTag is created if the push deletes a tag. Otherwise, an // action with the type ActionPushTag is created for a regular push. PushTag(ctx context.Context, opts PushTagOptions) error // RenameRepo creates an action for renaming a repository. RenameRepo(ctx context.Context, doer, owner *User, oldRepoName string, repo *Repository) error // TransferRepo creates an action for transferring a repository to a new owner. TransferRepo(ctx context.Context, doer, oldOwner, newOwner *User, repo *Repository) error }
ActionsStore is the persistent interface for actions.
var Actions ActionsStore
func NewActionsStore ¶ added in v0.13.0
func NewActionsStore(db *gorm.DB) ActionsStore
NewActionsStore returns a persistent interface for actions with given database connection.
type Attachment ¶
type Attachment struct { ID int64 UUID string `xorm:"uuid UNIQUE"` IssueID int64 `xorm:"INDEX"` CommentID int64 ReleaseID int64 `xorm:"INDEX"` Name string Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 }
Attachment represent a attachment of issue/comment/release.
func GetAttachmentByUUID ¶
func GetAttachmentByUUID(uuid string) (*Attachment, error)
GetAttachmentByUUID returns attachment by given UUID.
func GetAttachmentsByCommentID ¶
func GetAttachmentsByCommentID(commentID int64) ([]*Attachment, error)
GetAttachmentsByCommentID returns all attachments of a comment.
func GetAttachmentsByIssueID ¶
func GetAttachmentsByIssueID(issueID int64) ([]*Attachment, error)
GetAttachmentsByIssueID returns all attachments of an issue.
func GetAttachmentsByReleaseID ¶
func GetAttachmentsByReleaseID(releaseID int64) ([]*Attachment, error)
GetAttachmentsByReleaseID returns all attachments of a release.
func NewAttachment ¶
NewAttachment creates a new attachment object.
func (*Attachment) BeforeInsert ¶
func (a *Attachment) BeforeInsert()
func (*Attachment) LocalPath ¶
func (attach *Attachment) LocalPath() string
LocalPath returns where attachment is stored in local file system.
type Branch ¶
func GetBranchesByPath ¶
type Collaboration ¶
type Collaboration struct { ID int64 `gorm:"primary_key"` UserID int64 `xorm:"UNIQUE(s) INDEX NOT NULL" gorm:"uniqueIndex:collaboration_user_repo_unique;index;not null"` RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL" gorm:"uniqueIndex:collaboration_user_repo_unique;index;not null"` Mode AccessMode `xorm:"DEFAULT 2 NOT NULL" gorm:"not null;default:2"` }
Collaboration represent the relation between an individual and a repository.
func (*Collaboration) ModeI18nKey ¶
func (c *Collaboration) ModeI18nKey() string
type Collaborator ¶
type Collaborator struct { *User Collaboration *Collaboration }
Collaborator represents a user with collaboration details.
func (*Collaborator) APIFormat ¶
func (c *Collaborator) APIFormat() *api.Collaborator
type Comment ¶
type Comment struct { ID int64 Type CommentType PosterID int64 Poster *User `xorm:"-" json:"-"` IssueID int64 `xorm:"INDEX"` Issue *Issue `xorm:"-" json:"-"` CommitID int64 Line int64 Content string `xorm:"TEXT"` RenderedContent string `xorm:"-" json:"-"` Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" json:"-"` UpdatedUnix int64 // Reference issue in commit message CommitSHA string `xorm:"VARCHAR(40)"` Attachments []*Attachment `xorm:"-" json:"-"` // For view issue page. ShowTag CommentTag `xorm:"-" json:"-"` }
Comment represents a comment in commit and issue page.
func CreateComment ¶
func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error)
CreateComment creates comment of issue or commit.
func CreateIssueComment ¶
func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error)
CreateIssueComment creates a plain issue comment.
func GetCommentByID ¶
GetCommentByID returns the comment by given ID.
func GetCommentsByIssueID ¶
GetCommentsByIssueID returns all comments of an issue.
func GetCommentsByIssueIDSince ¶
GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.
func GetCommentsByRepoIDSince ¶
GetCommentsByRepoIDSince returns a list of comments for all issues in a repo since a given time point.
func (*Comment) APIFormat ¶
This method assumes following fields have been assigned with valid values: Required - Poster, Issue
func (*Comment) BeforeInsert ¶
func (c *Comment) BeforeInsert()
func (*Comment) BeforeUpdate ¶
func (c *Comment) BeforeUpdate()
func (*Comment) LoadAttributes ¶
type CommentTag ¶
type CommentTag int
const ( COMMENT_TAG_NONE CommentTag = iota COMMENT_TAG_POSTER COMMENT_TAG_WRITER COMMENT_TAG_OWNER )
type CommentType ¶
type CommentType int
CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.
const ( // Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0) COMMENT_TYPE_COMMENT CommentType = iota COMMENT_TYPE_REOPEN COMMENT_TYPE_CLOSE // References. COMMENT_TYPE_ISSUE_REF // Reference from a commit (not part of a pull request) COMMENT_TYPE_COMMIT_REF // Reference from a comment COMMENT_TYPE_COMMENT_REF // Reference from a pull request COMMENT_TYPE_PULL_REF )
type CommitRepoOptions ¶ added in v0.13.0
type CommitRepoOptions struct { Owner *User Repo *Repository PusherName string RefFullName string OldCommitID string NewCommitID string Commits *PushCommits }
type ComposeHookEnvsOptions ¶
type CreateCommentOptions ¶
type CreateCommentOptions struct { Type CommentType Doer *User Repo *Repository Issue *Issue CommitID int64 CommitSHA string LineNum int64 Content string Attachments []string // UUIDs of attachments }
type CreateLoginSourceOptions ¶ added in v0.13.0
type CreateRepoOptions ¶
type CreateRepoOptionsLegacy ¶ added in v0.13.0
type CreateUserOptions ¶ added in v0.13.0
type DeleteRepoFileOptions ¶
type DeployKey ¶
type DeployKey struct { ID int64 KeyID int64 `xorm:"UNIQUE(s) INDEX"` RepoID int64 `xorm:"UNIQUE(s) INDEX"` Name string Fingerprint string Content string `xorm:"-" json:"-"` Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet. UpdatedUnix int64 HasRecentActivity bool `xorm:"-" json:"-"` HasUsed bool `xorm:"-" json:"-"` }
DeployKey represents deploy key information and its relation with repository.
func AddDeployKey ¶
AddDeployKey add new deploy key to database and authorized_keys file.
func GetDeployKeyByID ¶
GetDeployKeyByID returns deploy key by given ID.
func GetDeployKeyByRepo ¶
GetDeployKeyByRepo returns deploy key by given public key ID and repository ID.
func ListDeployKeys ¶
ListDeployKeys returns all deploy keys by given repository ID.
func (*DeployKey) BeforeInsert ¶
func (k *DeployKey) BeforeInsert()
func (*DeployKey) BeforeUpdate ¶
func (k *DeployKey) BeforeUpdate()
func (*DeployKey) GetContent ¶
GetContent gets associated public key content.
type DingtalkActionCard ¶
type DingtalkActionCard struct { Title string `json:"title"` Text string `json:"text"` HideAvatar string `json:"hideAvatar"` BtnOrientation string `json:"btnOrientation"` SingleTitle string `json:"singleTitle"` SingleURL string `json:"singleURL"` }
Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
func NewDingtalkActionCard ¶
func NewDingtalkActionCard(singleTitle, singleURL string) DingtalkActionCard
type DingtalkAtObject ¶
type DingtalkAtObject struct { AtMobiles []string `json:"atMobiles"` IsAtAll bool `json:"isAtAll"` }
Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
type DingtalkPayload ¶
type DingtalkPayload struct { MsgType string `json:"msgtype"` At DingtalkAtObject `json:"at"` ActionCard DingtalkActionCard `json:"actionCard"` }
Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1
func GetDingtalkPayload ¶
func GetDingtalkPayload(p api.Payloader, event HookEventType) (payload *DingtalkPayload, err error)
TODO: add content
func (*DingtalkPayload) JSONPayload ¶
func (p *DingtalkPayload) JSONPayload() ([]byte, error)
type DiscordEmbedFieldObject ¶
type DiscordEmbedFooterObject ¶
type DiscordEmbedFooterObject struct {
}type DiscordEmbedObject ¶
type DiscordEmbedObject struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` Color int `json:"color"` Author *DiscordEmbedAuthorObject `json:"author"` Fields []*DiscordEmbedFieldObject `json:"fields"` }
type DiscordPayload ¶
type DiscordPayload struct { Content string `json:"content"` Username string `json:"username"` AvatarURL string `json:"avatar_url"` Embeds []*DiscordEmbedObject `json:"embeds"` }
func GetDiscordPayload ¶
func GetDiscordPayload(p api.Payloader, event HookEventType, meta string) (payload *DiscordPayload, err error)
func (*DiscordPayload) JSONPayload ¶
func (p *DiscordPayload) JSONPayload() ([]byte, error)
type EmailAddress ¶
type EmailAddress struct { ID int64 `gorm:"primaryKey"` UserID int64 `xorm:"uid INDEX NOT NULL" gorm:"column:uid;index;not null"` Email string `xorm:"UNIQUE NOT NULL" gorm:"unique;not null"` IsActivated bool `gorm:"not null;default:FALSE"` IsPrimary bool `xorm:"-" gorm:"-" json:"-"` }
EmailAddresses is the list of all email addresses of a user. Can contain the primary email address, but is not obligatory.
func GetEmailAddresses ¶
func GetEmailAddresses(uid int64) ([]*EmailAddress, error)
GetEmailAddresses returns all email addresses belongs to given user.
func (*EmailAddress) Activate ¶
func (email *EmailAddress) Activate() error
type EmailAddressesStore ¶ added in v0.13.0
type EmailAddressesStore interface { // GetByEmail returns the email address with given email. If `needsActivated` is // true, only activated email will be returned, otherwise, it may return // inactivated email addresses. It returns ErrEmailNotExist when no qualified // email is not found. GetByEmail(ctx context.Context, email string, needsActivated bool) (*EmailAddress, error) }
EmailAddressesStore is the persistent interface for email addresses.
var EmailAddresses EmailAddressesStore
func NewEmailAddressesStore ¶ added in v0.13.0
func NewEmailAddressesStore(db *gorm.DB) EmailAddressesStore
NewEmailAddressesStore returns a persistent interface for email addresses with given database connection.
type Engine ¶
type Engine interface { Delete(any) (int64, error) Exec(...any) (sql.Result, error) Find(any, ...any) error Get(any) (bool, error) ID(any) *xorm.Session In(string, ...any) *xorm.Session Insert(...any) (int64, error) InsertOne(any) (int64, error) Iterate(any, xorm.IterFunc) error Sql(string, ...any) *xorm.Session Table(any) *xorm.Session Where(any, ...any) *xorm.Session }
Engine represents a XORM engine or session.
type ErrAccessTokenAlreadyExist ¶
type ErrAccessTokenAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrAccessTokenAlreadyExist) Error ¶
func (err ErrAccessTokenAlreadyExist) Error() string
type ErrAccessTokenNotExist ¶
type ErrAccessTokenNotExist struct {
// contains filtered or unexported fields
}
func (ErrAccessTokenNotExist) Error ¶
func (err ErrAccessTokenNotExist) Error() string
func (ErrAccessTokenNotExist) NotFound ¶
func (ErrAccessTokenNotExist) NotFound() bool
type ErrAttachmentNotExist ¶
type ErrAttachmentNotExist struct {
// contains filtered or unexported fields
}
func (ErrAttachmentNotExist) Error ¶
func (err ErrAttachmentNotExist) Error() string
func (ErrAttachmentNotExist) NotFound ¶
func (ErrAttachmentNotExist) NotFound() bool
type ErrBranchNotExist ¶
type ErrBranchNotExist struct {
// contains filtered or unexported fields
}
func (ErrBranchNotExist) Error ¶
func (err ErrBranchNotExist) Error() string
func (ErrBranchNotExist) NotFound ¶
func (ErrBranchNotExist) NotFound() bool
type ErrCommentNotExist ¶
type ErrCommentNotExist struct {
// contains filtered or unexported fields
}
func (ErrCommentNotExist) Error ¶
func (err ErrCommentNotExist) Error() string
func (ErrCommentNotExist) NotFound ¶
func (ErrCommentNotExist) NotFound() bool
type ErrDeployKeyAlreadyExist ¶
func (ErrDeployKeyAlreadyExist) Error ¶
func (err ErrDeployKeyAlreadyExist) Error() string
type ErrDeployKeyNameAlreadyUsed ¶
func (ErrDeployKeyNameAlreadyUsed) Error ¶
func (err ErrDeployKeyNameAlreadyUsed) Error() string
type ErrDeployKeyNotExist ¶
type ErrDeployKeyNotExist struct {
// contains filtered or unexported fields
}
func (ErrDeployKeyNotExist) Error ¶
func (err ErrDeployKeyNotExist) Error() string
func (ErrDeployKeyNotExist) NotFound ¶
func (ErrDeployKeyNotExist) NotFound() bool
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
// contains filtered or unexported fields
}
func (ErrEmailAlreadyUsed) Email ¶
func (err ErrEmailAlreadyUsed) Email() string
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
type ErrEmailNotExist ¶ added in v0.13.0
type ErrEmailNotExist struct {
// contains filtered or unexported fields
}
func (ErrEmailNotExist) Error ¶ added in v0.13.0
func (err ErrEmailNotExist) Error() string
func (ErrEmailNotExist) NotFound ¶ added in v0.13.0
func (ErrEmailNotExist) NotFound() bool
type ErrHookTaskNotExist ¶
type ErrHookTaskNotExist struct {
// contains filtered or unexported fields
}
func (ErrHookTaskNotExist) Error ¶
func (err ErrHookTaskNotExist) Error() string
func (ErrHookTaskNotExist) NotFound ¶
func (ErrHookTaskNotExist) NotFound() bool
type ErrInvalidCloneAddr ¶
type ErrInvalidCloneAddr struct { IsURLError bool IsInvalidPath bool IsPermissionDenied bool IsBlockedLocalAddress bool }
func (ErrInvalidCloneAddr) Error ¶
func (err ErrInvalidCloneAddr) Error() string
type ErrInvalidTagName ¶
type ErrInvalidTagName struct {
TagName string
}
func (ErrInvalidTagName) Error ¶
func (err ErrInvalidTagName) Error() string
type ErrIssueNotExist ¶
type ErrIssueNotExist struct {
// contains filtered or unexported fields
}
func (ErrIssueNotExist) Error ¶
func (err ErrIssueNotExist) Error() string
func (ErrIssueNotExist) NotFound ¶
func (ErrIssueNotExist) NotFound() bool
type ErrKeyAccessDenied ¶
func (ErrKeyAccessDenied) Error ¶
func (err ErrKeyAccessDenied) Error() string
type ErrKeyAlreadyExist ¶
func (ErrKeyAlreadyExist) Error ¶
func (err ErrKeyAlreadyExist) Error() string
type ErrKeyNameAlreadyUsed ¶
func (ErrKeyNameAlreadyUsed) Error ¶
func (err ErrKeyNameAlreadyUsed) Error() string
type ErrKeyNotExist ¶
type ErrKeyNotExist struct {
ID int64
}
func (ErrKeyNotExist) Error ¶
func (err ErrKeyNotExist) Error() string
type ErrKeyUnableVerify ¶
type ErrKeyUnableVerify struct {
Result string
}
func (ErrKeyUnableVerify) Error ¶
func (err ErrKeyUnableVerify) Error() string
type ErrLFSObjectNotExist ¶
type ErrLFSObjectNotExist struct {
// contains filtered or unexported fields
}
func (ErrLFSObjectNotExist) Error ¶
func (err ErrLFSObjectNotExist) Error() string
func (ErrLFSObjectNotExist) NotFound ¶
func (ErrLFSObjectNotExist) NotFound() bool
type ErrLabelNotExist ¶
type ErrLabelNotExist struct {
// contains filtered or unexported fields
}
func (ErrLabelNotExist) Error ¶
func (err ErrLabelNotExist) Error() string
func (ErrLabelNotExist) NotFound ¶
func (ErrLabelNotExist) NotFound() bool
type ErrLastOrgOwner ¶
type ErrLastOrgOwner struct {
UID int64
}
func (ErrLastOrgOwner) Error ¶
func (err ErrLastOrgOwner) Error() string
type ErrLoginSourceAlreadyExist ¶
type ErrLoginSourceAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrLoginSourceAlreadyExist) Error ¶
func (err ErrLoginSourceAlreadyExist) Error() string
type ErrLoginSourceInUse ¶
type ErrLoginSourceInUse struct {
// contains filtered or unexported fields
}
func (ErrLoginSourceInUse) Error ¶
func (err ErrLoginSourceInUse) Error() string
type ErrLoginSourceMismatch ¶
type ErrLoginSourceMismatch struct {
// contains filtered or unexported fields
}
func (ErrLoginSourceMismatch) Error ¶
func (err ErrLoginSourceMismatch) Error() string
type ErrLoginSourceNotExist ¶
type ErrLoginSourceNotExist struct {
// contains filtered or unexported fields
}
func (ErrLoginSourceNotExist) Error ¶
func (err ErrLoginSourceNotExist) Error() string
func (ErrLoginSourceNotExist) NotFound ¶
func (ErrLoginSourceNotExist) NotFound() bool
type ErrMilestoneNotExist ¶
type ErrMilestoneNotExist struct {
// contains filtered or unexported fields
}
func (ErrMilestoneNotExist) Error ¶
func (err ErrMilestoneNotExist) Error() string
func (ErrMilestoneNotExist) NotFound ¶
func (ErrMilestoneNotExist) NotFound() bool
type ErrNameNotAllowed ¶
type ErrNameNotAllowed struct {
// contains filtered or unexported fields
}
func (ErrNameNotAllowed) Error ¶
func (err ErrNameNotAllowed) Error() string
func (ErrNameNotAllowed) Value ¶
func (err ErrNameNotAllowed) Value() string
type ErrPullRequestNotExist ¶
type ErrPullRequestNotExist struct {
// contains filtered or unexported fields
}
func (ErrPullRequestNotExist) Error ¶
func (err ErrPullRequestNotExist) Error() string
func (ErrPullRequestNotExist) NotFound ¶
func (ErrPullRequestNotExist) NotFound() bool
type ErrReachLimitOfRepo ¶
type ErrReachLimitOfRepo struct {
Limit int
}
func (ErrReachLimitOfRepo) Error ¶
func (err ErrReachLimitOfRepo) Error() string
type ErrReleaseAlreadyExist ¶
type ErrReleaseAlreadyExist struct {
TagName string
}
func (ErrReleaseAlreadyExist) Error ¶
func (err ErrReleaseAlreadyExist) Error() string
type ErrReleaseNotExist ¶
type ErrReleaseNotExist struct {
// contains filtered or unexported fields
}
func (ErrReleaseNotExist) Error ¶
func (err ErrReleaseNotExist) Error() string
func (ErrReleaseNotExist) NotFound ¶
func (ErrReleaseNotExist) NotFound() bool
type ErrRepoAlreadyExist ¶
type ErrRepoAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrRepoAlreadyExist) Error ¶
func (err ErrRepoAlreadyExist) Error() string
type ErrRepoFileAlreadyExist ¶
type ErrRepoFileAlreadyExist struct {
FileName string
}
func (ErrRepoFileAlreadyExist) Error ¶
func (err ErrRepoFileAlreadyExist) Error() string
type ErrRepoNotExist ¶
type ErrRepoNotExist struct {
// contains filtered or unexported fields
}
func (ErrRepoNotExist) Error ¶
func (err ErrRepoNotExist) Error() string
func (ErrRepoNotExist) NotFound ¶
func (ErrRepoNotExist) NotFound() bool
type ErrTeamAlreadyExist ¶
func (ErrTeamAlreadyExist) Error ¶
func (err ErrTeamAlreadyExist) Error() string
type ErrTeamNotExist ¶
type ErrTeamNotExist struct {
// contains filtered or unexported fields
}
func (ErrTeamNotExist) Error ¶
func (err ErrTeamNotExist) Error() string
func (ErrTeamNotExist) NotFound ¶
func (ErrTeamNotExist) NotFound() bool
type ErrTwoFactorNotFound ¶
type ErrTwoFactorNotFound struct {
// contains filtered or unexported fields
}
func (ErrTwoFactorNotFound) Error ¶
func (err ErrTwoFactorNotFound) Error() string
func (ErrTwoFactorNotFound) NotFound ¶
func (ErrTwoFactorNotFound) NotFound() bool
type ErrTwoFactorRecoveryCodeNotFound ¶
type ErrTwoFactorRecoveryCodeNotFound struct {
Code string
}
func (ErrTwoFactorRecoveryCodeNotFound) Error ¶
func (err ErrTwoFactorRecoveryCodeNotFound) Error() string
type ErrUpdateTaskNotExist ¶
type ErrUpdateTaskNotExist struct {
UUID string
}
func (ErrUpdateTaskNotExist) Error ¶
func (err ErrUpdateTaskNotExist) Error() string
type ErrUploadNotExist ¶
func (ErrUploadNotExist) Error ¶
func (err ErrUploadNotExist) Error() string
type ErrUserAlreadyExist ¶
type ErrUserAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrUserAlreadyExist) Error ¶
func (err ErrUserAlreadyExist) Error() string
type ErrUserHasOrgs ¶
type ErrUserHasOrgs struct {
// contains filtered or unexported fields
}
func (ErrUserHasOrgs) Error ¶
func (err ErrUserHasOrgs) Error() string
type ErrUserNotExist ¶
type ErrUserNotExist struct {
// contains filtered or unexported fields
}
func (ErrUserNotExist) Error ¶
func (err ErrUserNotExist) Error() string
func (ErrUserNotExist) NotFound ¶
func (ErrUserNotExist) NotFound() bool
type ErrUserOwnRepos ¶
type ErrUserOwnRepos struct {
// contains filtered or unexported fields
}
func (ErrUserOwnRepos) Error ¶
func (err ErrUserOwnRepos) Error() string
type ErrWebhookNotExist ¶
type ErrWebhookNotExist struct {
// contains filtered or unexported fields
}
func (ErrWebhookNotExist) Error ¶
func (err ErrWebhookNotExist) Error() string
func (ErrWebhookNotExist) NotFound ¶
func (ErrWebhookNotExist) NotFound() bool
type ErrWikiAlreadyExist ¶
type ErrWikiAlreadyExist struct {
Title string
}
func (ErrWikiAlreadyExist) Error ¶
func (err ErrWikiAlreadyExist) Error() string
type FilterMode ¶
type FilterMode string
const ( FILTER_MODE_YOUR_REPOS FilterMode = "your_repositories" FILTER_MODE_ASSIGN FilterMode = "assigned" FILTER_MODE_CREATE FilterMode = "created_by" FILTER_MODE_MENTION FilterMode = "mentioned" )
type Follow ¶
type Follow struct { ID int64 `gorm:"primaryKey"` UserID int64 `xorm:"UNIQUE(follow)" gorm:"uniqueIndex:follow_user_follow_unique;not null"` FollowID int64 `xorm:"UNIQUE(follow)" gorm:"uniqueIndex:follow_user_follow_unique;not null"` }
Follow represents relations of users and their followers.
type HookContentType ¶
type HookContentType int
const ( JSON HookContentType = iota + 1 FORM )
func ToHookContentType ¶
func ToHookContentType(name string) HookContentType
ToHookContentType returns HookContentType by given name.
func (HookContentType) Name ¶
func (t HookContentType) Name() string
type HookEvent ¶
type HookEvent struct { PushOnly bool `json:"push_only"` SendEverything bool `json:"send_everything"` ChooseEvents bool `json:"choose_events"` HookEvents `json:"events"` }
HookEvent represents events that will delivery hook.
type HookEventType ¶
type HookEventType string
const ( HOOK_EVENT_CREATE HookEventType = "create" HOOK_EVENT_DELETE HookEventType = "delete" HOOK_EVENT_FORK HookEventType = "fork" HOOK_EVENT_PUSH HookEventType = "push" HOOK_EVENT_ISSUES HookEventType = "issues" HOOK_EVENT_PULL_REQUEST HookEventType = "pull_request" HOOK_EVENT_ISSUE_COMMENT HookEventType = "issue_comment" HOOK_EVENT_RELEASE HookEventType = "release" )
type HookEvents ¶
type HookRequest ¶
HookRequest represents hook task request information.
type HookResponse ¶
type HookResponse struct { Status int `json:"status"` Headers map[string]string `json:"headers"` Body string `json:"body"` }
HookResponse represents hook task response information.
type HookStatus ¶
type HookStatus int
type HookTask ¶
type HookTask struct { ID int64 RepoID int64 `xorm:"INDEX"` HookID int64 UUID string Type HookTaskType URL string `xorm:"TEXT"` Signature string `xorm:"TEXT"` api.Payloader `xorm:"-" json:"-"` PayloadContent string `xorm:"TEXT"` ContentType HookContentType EventType HookEventType IsSSL bool IsDelivered bool Delivered int64 DeliveredString string `xorm:"-" json:"-"` // History info. IsSucceed bool RequestContent string `xorm:"TEXT"` RequestInfo *HookRequest `xorm:"-" json:"-"` ResponseContent string `xorm:"TEXT"` ResponseInfo *HookResponse `xorm:"-" json:"-"` }
HookTask represents a hook task.
func GetHookTaskOfWebhookByUUID ¶
GetHookTaskOfWebhookByUUID returns hook task of given webhook by UUID.
func (*HookTask) BeforeUpdate ¶
func (t *HookTask) BeforeUpdate()
type HookTaskType ¶
type HookTaskType int
const ( GOGS HookTaskType = iota + 1 SLACK DISCORD DINGTALK )
func ToHookTaskType ¶
func ToHookTaskType(name string) HookTaskType
ToHookTaskType returns HookTaskType by given name.
func (HookTaskType) Name ¶
func (t HookTaskType) Name() string
type Issue ¶
type Issue struct { ID int64 `gorm:"primaryKey"` RepoID int64 `xorm:"INDEX UNIQUE(repo_index)" gorm:"index;uniqueIndex:issue_repo_index_unique;not null"` Repo *Repository `xorm:"-" json:"-" gorm:"-"` Index int64 `xorm:"UNIQUE(repo_index)" gorm:"uniqueIndex:issue_repo_index_unique;not null"` // Index in one repository. PosterID int64 `gorm:"index"` Poster *User `xorm:"-" json:"-" gorm:"-"` Title string `xorm:"name" gorm:"name"` Content string `xorm:"TEXT" gorm:"type:TEXT"` RenderedContent string `xorm:"-" json:"-" gorm:"-"` Labels []*Label `xorm:"-" json:"-" gorm:"-"` MilestoneID int64 `gorm:"index"` Milestone *Milestone `xorm:"-" json:"-" gorm:"-"` Priority int AssigneeID int64 `gorm:"index"` Assignee *User `xorm:"-" json:"-" gorm:"-"` IsClosed bool IsRead bool `xorm:"-" json:"-" gorm:"-"` IsPull bool // Indicates whether is a pull request or not. PullRequest *PullRequest `xorm:"-" json:"-" gorm:"-"` NumComments int Deadline time.Time `xorm:"-" json:"-" gorm:"-"` DeadlineUnix int64 Created time.Time `xorm:"-" json:"-" gorm:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" json:"-" gorm:"-"` UpdatedUnix int64 Attachments []*Attachment `xorm:"-" json:"-" gorm:"-"` Comments []*Comment `xorm:"-" json:"-" gorm:"-"` }
Issue represents an issue or pull request of repository.
func GetIssueByID ¶
GetIssueByID returns an issue by given ID.
func GetIssueByIndex ¶
GetIssueByIndex returns issue by index in a repository.
func GetIssueByRef ¶
GetIssueByRef returns an Issue specified by a GFM reference, e.g. owner/repo#123.
func GetRawIssueByIndex ¶
GetRawIssueByIndex returns raw issue without loading attributes by index in a repository.
func Issues ¶
func Issues(opts *IssuesOptions) ([]*Issue, error)
Issues returns a list of issues by given conditions.
func (*Issue) APIFormat ¶
This method assumes some fields assigned with values: Required - Poster, Labels, Optional - Milestone, Assignee, PullRequest
func (*Issue) BeforeInsert ¶
func (issue *Issue) BeforeInsert()
func (*Issue) BeforeUpdate ¶
func (issue *Issue) BeforeUpdate()
func (*Issue) ChangeAssignee ¶
func (*Issue) ChangeContent ¶
func (*Issue) ChangeStatus ¶
func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (err error)
ChangeStatus changes issue status to open or closed.
func (*Issue) ClearLabels ¶
func (*Issue) GetAssignee ¶
func (*Issue) LoadAttributes ¶
func (*Issue) MailParticipants ¶
MailParticipants sends new issue thread created emails to repository watchers and mentioned people.
func (*Issue) MailSubject ¶
func (*Issue) RemoveLabel ¶
RemoveLabel removes a label from issue by given ID.
func (*Issue) ReplaceLabels ¶
ReplaceLabels removes all current labels and add new labels to the issue.
type IssueLabel ¶
type IssueLabel struct { ID int64 IssueID int64 `xorm:"UNIQUE(s)"` LabelID int64 `xorm:"UNIQUE(s)"` }
IssueLabel represents an issue-lable relation.
func GetIssueLabels ¶
func GetIssueLabels(issueID int64) ([]*IssueLabel, error)
GetIssueLabels returns all issue-label relations of given issue by ID.
type IssueStats ¶
type IssueStats struct {
OpenCount, ClosedCount int64
YourReposCount int64
AssignCount int64
CreateCount int64
MentionCount int64
}
IssueStats represents issue statistic information.
func GetIssueStats ¶
func GetIssueStats(opts *IssueStatsOptions) *IssueStats
GetIssueStats returns issue statistic information by given conditions.
func GetUserIssueStats ¶
func GetUserIssueStats(repoID, userID int64, repoIDs []int64, filterMode FilterMode, isPull bool) *IssueStats
GetUserIssueStats returns issue statistic information for dashboard by given conditions.
type IssueStatsOptions ¶
type IssueUser ¶
type IssueUser struct { ID int64 `gorm:"primary_key"` UserID int64 `xorm:"uid INDEX" gorm:"column:uid;index"` IssueID int64 RepoID int64 `xorm:"INDEX" gorm:"index"` MilestoneID int64 IsRead bool IsAssigned bool IsMentioned bool IsPoster bool IsClosed bool }
IssueUser represents an issue-user relation.
func GetIssueUserPairsByMode ¶
func GetIssueUserPairsByMode(userID, repoID int64, filterMode FilterMode, isClosed bool, page int) ([]*IssueUser, error)
GetIssueUserPairsByMode returns issue-user pairs by given repository and user.
func GetIssueUserPairsByRepoIds ¶
GetIssueUserPairsByRepoIds returns issue-user pairs by given repository IDs.
type IssuesOptions ¶
type LFSObject ¶
type LFSObject struct { RepoID int64 `gorm:"primaryKey;auto_increment:false"` OID lfsutil.OID `gorm:"primaryKey;column:oid"` Size int64 `gorm:"not null"` Storage lfsutil.Storage `gorm:"not null"` CreatedAt time.Time `gorm:"not null"` }
LFSObject is the relation between an LFS object and a repository.
type LFSStore ¶
type LFSStore interface { // CreateObject creates a LFS object record in database. CreateObject(ctx context.Context, repoID int64, oid lfsutil.OID, size int64, storage lfsutil.Storage) error // GetObjectByOID returns the LFS object with given OID. It returns // ErrLFSObjectNotExist when not found. GetObjectByOID(ctx context.Context, repoID int64, oid lfsutil.OID) (*LFSObject, error) // GetObjectsByOIDs returns LFS objects found within "oids". The returned list // could have less elements if some oids were not found. GetObjectsByOIDs(ctx context.Context, repoID int64, oids ...lfsutil.OID) ([]*LFSObject, error) }
LFSStore is the persistent interface for LFS objects.
var LFS LFSStore
type Label ¶
type Label struct { ID int64 RepoID int64 `xorm:"INDEX"` Name string Color string `xorm:"VARCHAR(7)"` NumIssues int NumClosedIssues int NumOpenIssues int `xorm:"-" json:"-"` IsChecked bool `xorm:"-" json:"-"` }
Label represents a label of repository for issues.
func GetLabelByID ¶
GetLabelByID returns a label by given ID.
func GetLabelOfRepoByID ¶
GetLabelOfRepoByID returns a label by ID in given repository.
func GetLabelOfRepoByName ¶
GetLabelOfRepoByName returns a label by name in given repository.
func GetLabelsByIssueID ¶
GetLabelsByIssueID returns all labels that belong to given issue by ID.
func GetLabelsByRepoID ¶
GetLabelsByRepoID returns all labels that belong to given repository by ID.
func GetLabelsInRepoByIDs ¶
GetLabelsInRepoByIDs returns a list of labels by IDs in given repository, it silently ignores label IDs that are not belong to the repository.
func (*Label) CalOpenIssues ¶
func (label *Label) CalOpenIssues()
CalOpenIssues calculates the open issues of label.
func (*Label) ForegroundColor ¶
ForegroundColor calculates the text color for labels based on their background color.
type ListLoginSourceOptions ¶ added in v0.13.0
type ListLoginSourceOptions struct { // Whether to only include activated login sources. OnlyActivated bool }
type ListOrgsOptions ¶ added in v0.13.0
type LoginSource ¶
type LoginSource struct { ID int64 `gorm:"primaryKey"` Type auth.Type Name string `xorm:"UNIQUE" gorm:"unique"` IsActived bool `xorm:"NOT NULL DEFAULT false" gorm:"not null"` IsDefault bool `xorm:"DEFAULT false"` Provider auth.Provider `xorm:"-" gorm:"-"` Config string `xorm:"TEXT cfg" gorm:"column:cfg;type:TEXT" json:"RawConfig"` Created time.Time `xorm:"-" gorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" gorm:"-" json:"-"` UpdatedUnix int64 File loginSourceFileStore `xorm:"-" gorm:"-" json:"-"` }
LoginSource represents an external way for authorizing users.
func (*LoginSource) AfterFind ¶
func (s *LoginSource) AfterFind(_ *gorm.DB) error
AfterFind implements the GORM query hook.
func (*LoginSource) BeforeCreate ¶
func (s *LoginSource) BeforeCreate(tx *gorm.DB) error
BeforeCreate implements the GORM create hook.
func (*LoginSource) BeforeSave ¶
func (s *LoginSource) BeforeSave(_ *gorm.DB) (err error)
BeforeSave implements the GORM save hook.
func (*LoginSource) BeforeUpdate ¶
func (s *LoginSource) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate implements the GORM update hook.
func (*LoginSource) GitHub ¶
func (s *LoginSource) GitHub() *github.Config
func (*LoginSource) IsDLDAP ¶
func (s *LoginSource) IsDLDAP() bool
func (*LoginSource) IsGitHub ¶
func (s *LoginSource) IsGitHub() bool
func (*LoginSource) IsLDAP ¶
func (s *LoginSource) IsLDAP() bool
func (*LoginSource) IsPAM ¶
func (s *LoginSource) IsPAM() bool
func (*LoginSource) IsSMTP ¶
func (s *LoginSource) IsSMTP() bool
func (*LoginSource) LDAP ¶
func (s *LoginSource) LDAP() *ldap.Config
func (*LoginSource) PAM ¶
func (s *LoginSource) PAM() *pam.Config
func (*LoginSource) SMTP ¶
func (s *LoginSource) SMTP() *smtp.Config
func (*LoginSource) TypeName ¶
func (s *LoginSource) TypeName() string
type LoginSourcesStore ¶
type LoginSourcesStore interface { // Create creates a new login source and persist to database. It returns // ErrLoginSourceAlreadyExist when a login source with same name already exists. Create(ctx context.Context, opts CreateLoginSourceOptions) (*LoginSource, error) // Count returns the total number of login sources. Count(ctx context.Context) int64 // DeleteByID deletes a login source by given ID. It returns ErrLoginSourceInUse // if at least one user is associated with the login source. DeleteByID(ctx context.Context, id int64) error // GetByID returns the login source with given ID. It returns // ErrLoginSourceNotExist when not found. GetByID(ctx context.Context, id int64) (*LoginSource, error) // List returns a list of login sources filtered by options. List(ctx context.Context, opts ListLoginSourceOptions) ([]*LoginSource, error) // ResetNonDefault clears default flag for all the other login sources. ResetNonDefault(ctx context.Context, source *LoginSource) error // Save persists all values of given login source to database or local file. The // Updated field is set to current time automatically. Save(ctx context.Context, t *LoginSource) error }
LoginSourcesStore is the persistent interface for login sources.
var LoginSources LoginSourcesStore
type MergeStyle ¶
type MergeStyle string
MergeStyle represents the approach to merge commits into base branch.
const ( MERGE_STYLE_REGULAR MergeStyle = "create_merge_commit" MERGE_STYLE_REBASE MergeStyle = "rebase_before_merging" )
type MigrateRepoOptions ¶
type Milestone ¶
type Milestone struct { ID int64 RepoID int64 `xorm:"INDEX"` Name string Content string `xorm:"TEXT"` RenderedContent string `xorm:"-" json:"-"` IsClosed bool NumIssues int NumClosedIssues int NumOpenIssues int `xorm:"-" json:"-"` Completeness int // Percentage(1-100). IsOverDue bool `xorm:"-" json:"-"` DeadlineString string `xorm:"-" json:"-"` Deadline time.Time `xorm:"-" json:"-"` DeadlineUnix int64 ClosedDate time.Time `xorm:"-" json:"-"` ClosedDateUnix int64 }
Milestone represents a milestone of repository.
func GetMilestoneByRepoID ¶
GetWebhookByRepoID returns the milestone in a repository.
func GetMilestones ¶
GetMilestones returns a list of milestones of given repository and status.
func GetMilestonesByRepoID ¶
GetMilestonesByRepoID returns all milestones of a repository.
func (*Milestone) BeforeInsert ¶
func (m *Milestone) BeforeInsert()
func (*Milestone) BeforeUpdate ¶
func (m *Milestone) BeforeUpdate()
func (*Milestone) ChangeStatus ¶
func (*Milestone) CountIssues ¶
type Mirror ¶
type Mirror struct { ID int64 RepoID int64 Repo *Repository `xorm:"-" json:"-"` Interval int // Hour. EnablePrune bool `xorm:"NOT NULL DEFAULT true"` // Last and next sync time of Git data from upstream LastSync time.Time `xorm:"-" json:"-"` LastSyncUnix int64 `xorm:"updated_unix"` NextSync time.Time `xorm:"-" json:"-"` NextSyncUnix int64 `xorm:"next_update_unix"` // contains filtered or unexported fields }
Mirror represents mirror information of a repository.
func GetMirrorByRepoID ¶
GetMirrorByRepoID returns mirror information of a repository.
func (*Mirror) Address ¶
Address returns mirror address from Git repository config without credentials.
func (*Mirror) BeforeInsert ¶
func (m *Mirror) BeforeInsert()
func (*Mirror) BeforeUpdate ¶
func (m *Mirror) BeforeUpdate()
func (*Mirror) MosaicsAddress ¶
MosaicsAddress returns mirror address from Git repository config with credentials under mosaics.
func (*Mirror) RawAddress ¶
RawAddress returns raw mirror address directly from Git repository config.
func (*Mirror) SaveAddress ¶
SaveAddress writes new address to Git repository config.
func (*Mirror) ScheduleNextSync ¶
func (m *Mirror) ScheduleNextSync()
ScheduleNextSync calculates and sets next sync time based on repository mirror setting.
type MirrorRepositoryList ¶
type MirrorRepositoryList []*Repository
func (MirrorRepositoryList) LoadAttributes ¶
func (repos MirrorRepositoryList) LoadAttributes() error
type MirrorSyncPushOptions ¶ added in v0.13.0
type MirrorSyncPushOptions struct { Owner *User Repo *Repository RefName string OldCommitID string NewCommitID string Commits *PushCommits }
type NewIssueOptions ¶
type NewIssueOptions struct { Repo *Repository Issue *Issue LableIDs []int64 Attachments []string // In UUID format. IsPull bool }
type Notice ¶
type Notice struct { ID int64 Type NoticeType Description string `xorm:"TEXT"` Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 }
Notice represents a system notice for admin.
func (*Notice) BeforeInsert ¶
func (n *Notice) BeforeInsert()
type OrgUser ¶
type OrgUser struct { ID int64 `gorm:"primaryKey"` Uid int64 `xorm:"INDEX UNIQUE(s)" gorm:"uniqueIndex:org_user_user_org_unique;index;not null"` OrgID int64 `xorm:"INDEX UNIQUE(s)" gorm:"uniqueIndex:org_user_user_org_unique;index;not null"` IsPublic bool `gorm:"not null;default:FALSE"` IsOwner bool `gorm:"not null;default:FALSE"` NumTeams int `gorm:"not null;default:0"` }
OrgUser represents relations of organizations and their members.
type Organization ¶ added in v0.13.0
type Organization = User
func (*Organization) TableName ¶ added in v0.13.0
func (o *Organization) TableName() string
type OrgsStore ¶ added in v0.13.0
type OrgsStore interface { // List returns a list of organizations filtered by options. List(ctx context.Context, opts ListOrgsOptions) ([]*Organization, error) // SearchByName returns a list of organizations whose username or full name // matches the given keyword case-insensitively. Results are paginated by given // page and page size, and sorted by the given order (e.g. "id DESC"). A total // count of all results is also returned. If the order is not given, it's up to // the database to decide. SearchByName(ctx context.Context, keyword string, page, pageSize int, orderBy string) ([]*Organization, int64, error) // CountByUser returns the number of organizations the user is a member of. CountByUser(ctx context.Context, userID int64) (int64, error) }
OrgsStore is the persistent interface for organizations.
var Orgs OrgsStore
func NewOrgsStore ¶ added in v0.13.0
NewOrgsStore returns a persistent interface for orgs with given database connection.
type PermsStore ¶
type PermsStore interface { // AccessMode returns the access mode of given user has to the repository. AccessMode(ctx context.Context, userID, repoID int64, opts AccessModeOptions) AccessMode // Authorize returns true if the user has as good as desired access mode to the // repository. Authorize(ctx context.Context, userID, repoID int64, desired AccessMode, opts AccessModeOptions) bool // SetRepoPerms does a full update to which users have which level of access to // given repository. Keys of the "accessMap" are user IDs. SetRepoPerms(ctx context.Context, repoID int64, accessMap map[int64]AccessMode) error }
PermsStore is the persistent interface for permissions.
var Perms PermsStore
func NewPermsStore ¶ added in v0.13.0
func NewPermsStore(db *gorm.DB) PermsStore
NewPermsStore returns a persistent interface for permissions with given database connection.
type ProtectBranch ¶
type ProtectBranch struct { ID int64 RepoID int64 `xorm:"UNIQUE(protect_branch)"` Name string `xorm:"UNIQUE(protect_branch)"` Protected bool RequirePullRequest bool EnableWhitelist bool WhitelistUserIDs string `xorm:"TEXT"` WhitelistTeamIDs string `xorm:"TEXT"` }
ProtectBranch contains options of a protected branch.
func GetProtectBranchOfRepoByName ¶
func GetProtectBranchOfRepoByName(repoID int64, name string) (*ProtectBranch, error)
GetProtectBranchOfRepoByName returns *ProtectBranch by branch name in given repository.
func GetProtectBranchesByRepoID ¶
func GetProtectBranchesByRepoID(repoID int64) ([]*ProtectBranch, error)
GetProtectBranchesByRepoID returns a list of *ProtectBranch in given repository.
type ProtectBranchWhitelist ¶
type PublicKey ¶
type PublicKey struct { ID int64 `gorm:"primaryKey"` OwnerID int64 `xorm:"INDEX NOT NULL" gorm:"index;not null"` Name string `xorm:"NOT NULL" gorm:"not null"` Fingerprint string `xorm:"NOT NULL" gorm:"not null"` Content string `xorm:"TEXT NOT NULL" gorm:"type:TEXT;not null"` Mode AccessMode `xorm:"NOT NULL DEFAULT 2" gorm:"not null;default:2"` Type KeyType `xorm:"NOT NULL DEFAULT 1" gorm:"not null;default:1"` Created time.Time `xorm:"-" json:"-" gorm:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" json:"-" gorm:"-"` // Note: Updated must below Created for AfterSet. UpdatedUnix int64 HasRecentActivity bool `xorm:"-" json:"-" gorm:"-"` HasUsed bool `xorm:"-" json:"-" gorm:"-"` }
PublicKey represents a user or deploy SSH public key.
func AddPublicKey ¶
AddPublicKey adds new public key to database and authorized_keys file.
func GetPublicKeyByID ¶
GetPublicKeyByID returns public key by given ID.
func ListPublicKeys ¶
ListPublicKeys returns a list of public keys belongs to given user.
func SearchPublicKeyByContent ¶
SearchPublicKeyByContent searches a public key using the content as prefix (i.e. ignore the email part). It returns ErrKeyNotExist if no such key exists.
func (*PublicKey) AuthorizedString ¶
AuthorizedString returns formatted public key string for authorized_keys file.
func (*PublicKey) BeforeInsert ¶
func (k *PublicKey) BeforeInsert()
func (*PublicKey) BeforeUpdate ¶
func (k *PublicKey) BeforeUpdate()
func (*PublicKey) IsDeployKey ¶
IsDeployKey returns true if the public key is used as deploy key.
type PublicKeysStore ¶ added in v0.13.0
type PublicKeysStore interface { // RewriteAuthorizedKeys rewrites the "authorized_keys" file under the SSH root // path with all public keys stored in the database. RewriteAuthorizedKeys() error }
PublicKeysStore is the persistent interface for public keys.
var PublicKeys PublicKeysStore
func NewPublicKeysStore ¶ added in v0.13.0
func NewPublicKeysStore(db *gorm.DB) PublicKeysStore
NewPublicKeysStore returns a persistent interface for public keys with given database connection.
type PullRequest ¶
type PullRequest struct { ID int64 `gorm:"primaryKey"` Type PullRequestType Status PullRequestStatus IssueID int64 `xorm:"INDEX" gorm:"index"` Issue *Issue `xorm:"-" json:"-" gorm:"-"` Index int64 HeadRepoID int64 HeadRepo *Repository `xorm:"-" json:"-" gorm:"-"` BaseRepoID int64 BaseRepo *Repository `xorm:"-" json:"-" gorm:"-"` HeadUserName string HeadBranch string BaseBranch string MergeBase string `xorm:"VARCHAR(40)" gorm:"type:VARCHAR(40)"` HasMerged bool MergedCommitID string `xorm:"VARCHAR(40)" gorm:"type:VARCHAR(40)"` MergerID int64 Merger *User `xorm:"-" json:"-" gorm:"-"` Merged time.Time `xorm:"-" json:"-" gorm:"-"` MergedUnix int64 }
PullRequest represents relation between pull request and repositories.
func GetPullRequestByID ¶
func GetPullRequestByID(id int64) (*PullRequest, error)
GetPullRequestByID returns a pull request by given ID.
func GetPullRequestByIssueID ¶
func GetPullRequestByIssueID(issueID int64) (*PullRequest, error)
GetPullRequestByIssueID returns pull request by given issue ID.
func GetUnmergedPullRequest ¶
func GetUnmergedPullRequest(headRepoID, baseRepoID int64, headBranch, baseBranch string) (*PullRequest, error)
GetUnmergedPullRequest returns a pull request that is open and has not been merged by given head/base and repo/branch.
func GetUnmergedPullRequestsByBaseInfo ¶
func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequest, error)
GetUnmergedPullRequestsByBaseInfo returns all pull requests that are open and has not been merged by given base information (repo and branch).
func GetUnmergedPullRequestsByHeadInfo ¶
func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequest, error)
GetUnmergedPullRequestsByHeadInfo returns all pull requests that are open and has not been merged by given head information (repo and branch).
func (*PullRequest) APIFormat ¶
func (pr *PullRequest) APIFormat() *api.PullRequest
This method assumes following fields have been assigned with valid values: Required - Issue, BaseRepo Optional - HeadRepo, Merger
func (*PullRequest) AddToTaskQueue ¶
func (pr *PullRequest) AddToTaskQueue()
AddToTaskQueue adds itself to pull request test task queue.
func (*PullRequest) AfterSet ¶
func (pr *PullRequest) AfterSet(colName string, _ xorm.Cell)
Note: don't try to get Issue because will end up recursive querying.
func (*PullRequest) BeforeUpdate ¶
func (pr *PullRequest) BeforeUpdate()
func (*PullRequest) CanAutoMerge ¶
func (pr *PullRequest) CanAutoMerge() bool
CanAutoMerge returns true if this pull request can be merged automatically.
func (*PullRequest) IsChecking ¶
func (pr *PullRequest) IsChecking() bool
IsChecking returns true if this pull request is still checking conflict.
func (*PullRequest) LoadAttributes ¶
func (pr *PullRequest) LoadAttributes() error
func (*PullRequest) LoadIssue ¶
func (pr *PullRequest) LoadIssue() (err error)
func (*PullRequest) Merge ¶
func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle, commitDescription string) (err error)
Merge merges pull request to base repository. FIXME: add repoWorkingPull make sure two merges does not happen at same time.
func (*PullRequest) PushToBaseRepo ¶
func (pr *PullRequest) PushToBaseRepo() (err error)
PushToBaseRepo pushes commits from branches of head repository to corresponding branches of base repository. FIXME: Only push branches that are actually updates?
func (*PullRequest) Update ¶
func (pr *PullRequest) Update() error
Update updates all fields of pull request.
func (*PullRequest) UpdateCols ¶
func (pr *PullRequest) UpdateCols(cols ...string) error
Update updates specific fields of pull request.
func (*PullRequest) UpdatePatch ¶
func (pr *PullRequest) UpdatePatch() (err error)
UpdatePatch generates and saves a new patch.
type PullRequestList ¶
type PullRequestList []*PullRequest
func (PullRequestList) LoadAttributes ¶
func (prs PullRequestList) LoadAttributes() error
type PullRequestStatus ¶
type PullRequestStatus int
const ( PULL_REQUEST_STATUS_CONFLICT PullRequestStatus = iota PULL_REQUEST_STATUS_CHECKING PULL_REQUEST_STATUS_MERGEABLE )
type PullRequestType ¶
type PullRequestType int
const ( PULL_REQUEST_GOGS PullRequestType = iota PLLL_ERQUEST_GIT )
type PushCommit ¶
type PushCommit struct { Sha1 string Message string AuthorEmail string AuthorName string CommitterEmail string CommitterName string Timestamp time.Time }
PushCommit contains information of a pushed commit.
func CommitToPushCommit ¶
func CommitToPushCommit(commit *git.Commit) *PushCommit
CommitToPushCommit transforms a git.Commit to PushCommit type.
type PushCommits ¶
type PushCommits struct { Len int Commits []*PushCommit CompareURL string // contains filtered or unexported fields }
PushCommits is a list of pushed commits.
func CommitsToPushCommits ¶
func CommitsToPushCommits(commits []*git.Commit) *PushCommits
func (*PushCommits) APIFormat ¶ added in v0.13.0
func (pcs *PushCommits) APIFormat(ctx context.Context, usersStore UsersStore, repoPath, repoURL string) ([]*api.PayloadCommit, error)
func (*PushCommits) AvatarLink ¶
func (pcs *PushCommits) AvatarLink(email string) string
AvatarLink tries to match user in database with email in order to show custom avatars, and falls back to general avatar link.
FIXME: This method does not belong to PushCommits, should be a pure template function.
type PushTagOptions ¶ added in v0.13.0
type PushTagOptions struct { Owner *User Repo *Repository PusherName string RefFullName string NewCommitID string }
type PushUpdateOptions ¶
type Release ¶
type Release struct { ID int64 RepoID int64 Repo *Repository `xorm:"-" json:"-"` PublisherID int64 Publisher *User `xorm:"-" json:"-"` TagName string LowerTagName string Target string Title string Sha1 string `xorm:"VARCHAR(40)"` NumCommits int64 NumCommitsBehind int64 `xorm:"-" json:"-"` Note string `xorm:"TEXT"` IsDraft bool `xorm:"NOT NULL DEFAULT false"` IsPrerelease bool Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 Attachments []*Attachment `xorm:"-" json:"-"` }
Release represents a release of repository.
func GetDraftReleasesByRepoID ¶
GetDraftReleasesByRepoID returns all draft releases of repository.
func GetPublishedReleasesByRepoID ¶
GetPublishedReleasesByRepoID returns a list of published releases of repository. If matches is not empty, only published releases in matches will be returned. In any case, drafts won't be returned by this function.
func GetRelease ¶
GetRelease returns release by given ID.
func GetReleaseByID ¶
GetReleaseByID returns release with given ID.
func GetReleasesByRepoID ¶
GetReleasesByRepoID returns a list of all releases (including drafts) of given repository.
func (*Release) APIFormat ¶
This method assumes some fields assigned with values: Required - Publisher
func (*Release) BeforeInsert ¶
func (r *Release) BeforeInsert()
func (*Release) LoadAttributes ¶
type ReleaseSorter ¶
type ReleaseSorter struct {
// contains filtered or unexported fields
}
func (*ReleaseSorter) Len ¶
func (rs *ReleaseSorter) Len() int
func (*ReleaseSorter) Less ¶
func (rs *ReleaseSorter) Less(i, j int) bool
func (*ReleaseSorter) Swap ¶
func (rs *ReleaseSorter) Swap(i, j int)
type ReposStore ¶
type ReposStore interface { // Create creates a new repository record in the database. It returns // ErrNameNotAllowed when the repository name is not allowed, or // ErrRepoAlreadyExist when a repository with same name already exists for the // owner. Create(ctx context.Context, ownerID int64, opts CreateRepoOptions) (*Repository, error) // GetByCollaboratorID returns a list of repositories that the given // collaborator has access to. Results are limited to the given limit and sorted // by the given order (e.g. "updated_unix DESC"). Repositories that are owned // directly by the given collaborator are not included. GetByCollaboratorID(ctx context.Context, collaboratorID int64, limit int, orderBy string) ([]*Repository, error) // GetByCollaboratorIDWithAccessMode returns a list of repositories and // corresponding access mode that the given collaborator has access to. // Repositories that are owned directly by the given collaborator are not // included. GetByCollaboratorIDWithAccessMode(ctx context.Context, collaboratorID int64) (map[*Repository]AccessMode, error) // GetByID returns the repository with given ID. It returns ErrRepoNotExist when // not found. GetByID(ctx context.Context, id int64) (*Repository, error) // GetByName returns the repository with given owner and name. It returns // ErrRepoNotExist when not found. GetByName(ctx context.Context, ownerID int64, name string) (*Repository, error) // Star marks the user to star the repository. Star(ctx context.Context, userID, repoID int64) error // Touch updates the updated time to the current time and removes the bare state // of the given repository. Touch(ctx context.Context, id int64) error // ListWatches returns all watches of the given repository. ListWatches(ctx context.Context, repoID int64) ([]*Watch, error) // Watch marks the user to watch the repository. Watch(ctx context.Context, userID, repoID int64) error // HasForkedBy returns true if the given repository has forked by the given user. HasForkedBy(ctx context.Context, repoID, userID int64) bool }
ReposStore is the persistent interface for repositories.
var Repos ReposStore
func NewReposStore ¶ added in v0.13.0
func NewReposStore(db *gorm.DB) ReposStore
NewReposStore returns a persistent interface for repositories with given database connection.
type Repository ¶
type Repository struct { ID int64 `gorm:"primaryKey"` OwnerID int64 `xorm:"UNIQUE(s)" gorm:"uniqueIndex:repo_owner_name_unique"` Owner *User `xorm:"-" gorm:"-" json:"-"` LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL" gorm:"uniqueIndex:repo_owner_name_unique;index;not null"` Name string `xorm:"INDEX NOT NULL" gorm:"index;not null"` Description string `xorm:"VARCHAR(512)" gorm:"type:VARCHAR(512)"` Website string DefaultBranch string Size int64 `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"` UseCustomAvatar bool // Counters NumWatches int NumStars int NumForks int NumIssues int NumClosedIssues int NumOpenIssues int `xorm:"-" gorm:"-" json:"-"` NumPulls int NumClosedPulls int NumOpenPulls int `xorm:"-" gorm:"-" json:"-"` NumMilestones int `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"` NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"` NumOpenMilestones int `xorm:"-" gorm:"-" json:"-"` NumTags int `xorm:"-" gorm:"-" json:"-"` IsPrivate bool // TODO: When migrate to GORM, make sure to do a loose migration with `HasColumn` and `AddColumn`, // see docs in https://gorm.io/docs/migration.html. IsUnlisted bool `xorm:"NOT NULL DEFAULT false" gorm:"not null;default:FALSE"` IsBare bool IsMirror bool *Mirror `xorm:"-" gorm:"-" json:"-"` // Advanced settings EnableWiki bool `xorm:"NOT NULL DEFAULT true" gorm:"not null;default:TRUE"` AllowPublicWiki bool EnableExternalWiki bool ExternalWikiURL string EnableIssues bool `xorm:"NOT NULL DEFAULT true" gorm:"not null;default:TRUE"` AllowPublicIssues bool EnableExternalTracker bool ExternalTrackerURL string ExternalTrackerFormat string ExternalTrackerStyle string ExternalMetas map[string]string `xorm:"-" gorm:"-" json:"-"` EnablePulls bool `xorm:"NOT NULL DEFAULT true" gorm:"not null;default:TRUE"` PullsIgnoreWhitespace bool `xorm:"NOT NULL DEFAULT false" gorm:"not null;default:FALSE"` PullsAllowRebase bool `xorm:"NOT NULL DEFAULT false" gorm:"not null;default:FALSE"` IsFork bool `xorm:"NOT NULL DEFAULT false" gorm:"not null;default:FALSE"` ForkID int64 BaseRepo *Repository `xorm:"-" gorm:"-" json:"-"` Created time.Time `xorm:"-" gorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" gorm:"-" json:"-"` UpdatedUnix int64 }
Repository contains information of a repository.
func CleanUpMigrateInfo ¶
func CleanUpMigrateInfo(repo *Repository) (*Repository, error)
Finish migrating repository and/or wiki with things that don't need to be done for mirrors.
func CreateRepository ¶
func CreateRepository(doer, owner *User, opts CreateRepoOptionsLegacy) (_ *Repository, err error)
CreateRepository creates a repository for given user or organization.
func ForkRepository ¶
func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string) (_ *Repository, err error)
ForkRepository creates a fork of target repository under another user domain.
func GetNonMirrorRepositories ¶
func GetNonMirrorRepositories() ([]*Repository, error)
GetRepositoriesMirror returns only mirror repositories with user.
func GetRecentUpdatedRepositories ¶
func GetRecentUpdatedRepositories(page, pageSize int) (repos []*Repository, err error)
GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
func GetRepositoriesByForkID ¶
func GetRepositoriesByForkID(forkID int64) ([]*Repository, error)
GetRepositoriesByForkID returns all repositories with given fork ID.
func GetRepositoryByID ¶
func GetRepositoryByID(id int64) (*Repository, error)
GetRepositoryByID returns the repository by given id if exists.
func GetRepositoryByName ¶
func GetRepositoryByName(ownerID int64, name string) (*Repository, error)
GetRepositoryByName returns the repository by given name under user if exists. Deprecated: Use Repos.GetByName instead.
func GetRepositoryByRef ¶
func GetRepositoryByRef(ref string) (*Repository, error)
GetRepositoryByRef returns a Repository specified by a GFM reference. See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
func GetUserAndCollaborativeRepositories ¶
func GetUserAndCollaborativeRepositories(userID int64) ([]*Repository, error)
GetUserAndCollaborativeRepositories returns list of repositories the user owns and collaborates.
func GetUserMirrorRepositories ¶
func GetUserMirrorRepositories(userID int64) ([]*Repository, error)
GetUserRepositories returns a list of mirror repositories of given user.
func GetUserRepositories ¶
func GetUserRepositories(opts *UserRepoOptions) ([]*Repository, error)
GetUserRepositories returns a list of repositories of given user.
func HasForkedRepo ¶
func HasForkedRepo(ownerID, repoID int64) (*Repository, bool, error)
HasForkedRepo checks if given user has already forked a repository. When user has already forked, it returns true along with the repository.
func MigrateRepository ¶
func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository, error)
MigrateRepository migrates a existing repository from other project hosting.
func Repositories ¶
func Repositories(page, pageSize int) (_ []*Repository, err error)
func RepositoriesWithUsers ¶
func RepositoriesWithUsers(page, pageSize int) (_ []*Repository, err error)
RepositoriesWithUsers returns number of repos in given page.
func SearchRepositoryByName ¶
func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, count int64, err error)
SearchRepositoryByName takes keyword and part of repository name to search, it returns results in given range and number of total results.
func (*Repository) APIFormat ¶
func (r *Repository) APIFormat(owner *User, opts ...RepositoryAPIFormatOptions) *api.Repository
APIFormat returns the API format of a repository.
func (*Repository) APIFormatLegacy
deprecated
added in
v0.13.0
func (repo *Repository) APIFormatLegacy(permission *api.Permission, user ...*User) *api.Repository
This method assumes following fields have been assigned with valid values: Required - BaseRepo (if fork) Arguments that are allowed to be nil: permission
Deprecated: Use APIFormat instead.
func (*Repository) AddCollaborator ¶
func (repo *Repository) AddCollaborator(u *User) error
AddCollaborator adds new collaboration to a repository with default access mode.
func (*Repository) AddWikiPage ¶
func (repo *Repository) AddWikiPage(doer *User, title, content, message string) error
func (*Repository) AfterFind ¶
func (r *Repository) AfterFind(_ *gorm.DB) error
AfterFind implements the GORM query hook.
func (*Repository) AllowsPulls ¶
func (repo *Repository) AllowsPulls() bool
AllowPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
func (*Repository) AvatarLink ¶
func (repo *Repository) AvatarLink() string
AvatarLink returns repository avatar absolute link.
func (*Repository) BeforeCreate ¶
func (r *Repository) BeforeCreate(tx *gorm.DB) error
BeforeCreate implements the GORM create hook.
func (*Repository) BeforeInsert ¶
func (repo *Repository) BeforeInsert()
func (*Repository) BeforeUpdate ¶
func (r *Repository) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate implements the GORM update hook.
func (*Repository) CanBeForked ¶
func (repo *Repository) CanBeForked() bool
CanBeForked returns true if repository meets the requirements of being forked.
func (*Repository) CanEnableEditor ¶
func (repo *Repository) CanEnableEditor() bool
CanEnableEditor returns true if repository meets the requirements of web editor.
func (*Repository) CanEnablePulls ¶
func (repo *Repository) CanEnablePulls() bool
CanEnablePulls returns true if repository meets the requirements of accepting pulls.
func (*Repository) CanGuestViewIssues ¶
func (repo *Repository) CanGuestViewIssues() bool
func (*Repository) CanGuestViewWiki ¶
func (repo *Repository) CanGuestViewWiki() bool
func (*Repository) ChangeCollaborationAccessMode ¶
func (repo *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessMode) error
ChangeCollaborationAccessMode sets new access mode for the collaboration.
func (*Repository) CheckoutNewBranch ¶
func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error
CheckoutNewBranch checks out to a new branch from the a branch name.
func (*Repository) CloneLink
deprecated
func (repo *Repository) CloneLink() (cl *repoutil.CloneLink)
CloneLink returns clone URLs of repository.
Deprecated: Use repoutil.NewCloneLink instead.
func (*Repository) ComposeCompareURL
deprecated
func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string
Deprecated: Use repoutil.ComparePath instead.
func (*Repository) ComposeMetas ¶
func (repo *Repository) ComposeMetas() map[string]string
ComposeMetas composes a map of metas for rendering SHA1 URL and external issue tracker URL.
func (*Repository) CreateNewBranch ¶
func (repo *Repository) CreateNewBranch(oldBranch, newBranch string) (err error)
func (*Repository) CustomAvatarPath ¶
func (repo *Repository) CustomAvatarPath() string
CustomAvatarPath returns repository custom avatar file path.
func (*Repository) DeleteAvatar ¶
func (repo *Repository) DeleteAvatar() error
DeleteAvatar deletes the repository custom avatar.
func (*Repository) DeleteCollaboration ¶
func (repo *Repository) DeleteCollaboration(userID int64) error
func (*Repository) DeleteRepoFile ¶
func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error)
func (*Repository) DeleteWiki ¶
func (repo *Repository) DeleteWiki()
DeleteWiki removes the actual and local copy of repository wiki.
func (*Repository) DeleteWikiPage ¶
func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error)
func (*Repository) DiscardLocalRepoBranchChanges ¶
func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error
func (*Repository) EditWikiPage ¶
func (repo *Repository) EditWikiPage(doer *User, oldTitle, title, content, message string) error
func (*Repository) FullName ¶
func (repo *Repository) FullName() string
func (*Repository) GetAssigneeByID ¶
func (repo *Repository) GetAssigneeByID(userID int64) (*User, error)
GetAssigneeByID returns the user that has write access of repository by given ID.
func (*Repository) GetAssignees ¶
func (repo *Repository) GetAssignees() (_ []*User, err error)
GetAssignees returns all users that have read access and can be assigned to issues of the repository,
func (*Repository) GetBranches ¶
func (repo *Repository) GetBranches() ([]*Branch, error)
func (*Repository) GetCollaborators ¶
func (repo *Repository) GetCollaborators() ([]*Collaborator, error)
GetCollaborators returns the collaborators for a repository
func (*Repository) GetDiffPreview ¶
func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *gitutil.Diff, err error)
GetDiffPreview produces and returns diff result of a file which is not yet committed.
func (*Repository) GetForks ¶
func (repo *Repository) GetForks() ([]*Repository, error)
func (*Repository) GetMilestoneByID ¶
func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error)
GetMilestoneByID returns the milestone belongs to repository by given ID.
func (*Repository) GetMirror ¶
func (repo *Repository) GetMirror() (err error)
func (*Repository) GetOwner ¶
func (repo *Repository) GetOwner() error
func (*Repository) GetStargazers ¶
func (repo *Repository) GetStargazers(page int) ([]*User, error)
func (*Repository) GetTags ¶ added in v0.12.4
func (repo *Repository) GetTags() ([]*Tag, error)
func (*Repository) GetWatchers ¶
func (repo *Repository) GetWatchers(page int) ([]*User, error)
Repository.GetWatchers returns range of users watching given repository.
func (*Repository) GetWriters ¶
func (repo *Repository) GetWriters() (_ []*User, err error)
GetWriters returns all users that have write access to the repository.
func (*Repository) GitConfigPath ¶
func (repo *Repository) GitConfigPath() string
func (*Repository) HTMLURL
deprecated
func (repo *Repository) HTMLURL() string
Deprecated: Use repoutil.HTMLURL instead.
func (*Repository) HasAccess ¶
func (repo *Repository) HasAccess(userID int64) bool
func (*Repository) HasWiki ¶
func (repo *Repository) HasWiki() bool
HasWiki returns true if repository has wiki.
func (*Repository) InitWiki ¶
func (repo *Repository) InitWiki() error
InitWiki initializes a wiki for repository, it does nothing when repository already has wiki.
func (*Repository) IsBranchRequirePullRequest ¶
func (repo *Repository) IsBranchRequirePullRequest(name string) bool
func (*Repository) IsCollaborator ¶
func (repo *Repository) IsCollaborator(userID int64) bool
func (*Repository) IsOwnedBy ¶
func (repo *Repository) IsOwnedBy(userID int64) bool
func (*Repository) IsPartialPublic ¶
func (repo *Repository) IsPartialPublic() bool
IsPartialPublic returns true if repository is public or allow public access to wiki or issues.
func (*Repository) IssueStats ¶
func (repo *Repository) IssueStats(userID int64, filterMode FilterMode, isPull bool) (int64, int64)
IssueStats returns number of open and closed repository issues by given filter mode.
func (*Repository) Link ¶
func (repo *Repository) Link() string
func (*Repository) LoadAttributes ¶
func (repo *Repository) LoadAttributes() error
func (*Repository) LocalCopyPath ¶
func (repo *Repository) LocalCopyPath() string
func (*Repository) LocalWikiPath ¶
func (repo *Repository) LocalWikiPath() string
func (*Repository) MustOwner ¶
func (repo *Repository) MustOwner() *User
MustOwner always returns a valid *User object to avoid conceptually impossible error handling. It creates a fake object that contains error details when error occurs.
func (*Repository) NextIssueIndex ¶
func (repo *Repository) NextIssueIndex() int64
FIXME: should have a mutex to prevent producing same index for two issues that are created closely enough.
func (*Repository) PatchPath ¶
func (repo *Repository) PatchPath(index int64) (string, error)
PatchPath returns corresponding patch file path of repository by given issue ID.
func (*Repository) RecalculateAccesses ¶
func (repo *Repository) RecalculateAccesses() error
RecalculateAccesses recalculates all accesses for repository.
func (*Repository) RelAvatarLink ¶
func (repo *Repository) RelAvatarLink() string
RelAvatarLink returns relative avatar link to the site domain, which includes app sub-url as prefix. Since Gravatar support not needed here - just check for image path.
func (*Repository) RelLink ¶
func (repo *Repository) RelLink() string
func (*Repository) RepoPath
deprecated
func (repo *Repository) RepoPath() string
Deprecated: Use repoutil.RepositoryPath instead.
func (*Repository) SavePatch ¶
func (repo *Repository) SavePatch(index int64, patch []byte) error
SavePatch saves patch data to corresponding location by given issue ID.
func (*Repository) UpdateLocalCopyBranch ¶
func (repo *Repository) UpdateLocalCopyBranch(branch string) error
UpdateLocalCopyBranch makes sure local copy of repository in given branch is up-to-date.
func (*Repository) UpdateLocalWiki ¶
func (repo *Repository) UpdateLocalWiki() error
UpdateLocalWiki makes sure the local copy of repository wiki is up-to-date.
func (*Repository) UpdateRepoFile ¶
func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error)
UpdateRepoFile adds or updates a file in repository.
func (*Repository) UpdateSize ¶
func (repo *Repository) UpdateSize() error
func (*Repository) UploadAvatar ¶
func (repo *Repository) UploadAvatar(data []byte) error
UploadAvatar saves custom avatar for repository. FIXME: split uploads to different subdirs in case we have massive number of repositories.
func (*Repository) UploadRepoFiles ¶
func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) error
func (*Repository) WikiCloneLink
deprecated
func (repo *Repository) WikiCloneLink() (cl *repoutil.CloneLink)
WikiCloneLink returns clone URLs of repository wiki.
Deprecated: Use repoutil.NewCloneLink instead.
func (*Repository) WikiPath ¶
func (repo *Repository) WikiPath() string
type RepositoryAPIFormatOptions ¶ added in v0.13.0
type RepositoryAPIFormatOptions struct { Permission *api.Permission Parent *api.Repository }
type RepositoryList ¶
type RepositoryList []*Repository
func (RepositoryList) LoadAttributes ¶
func (repos RepositoryList) LoadAttributes() error
type SearchRepoOptions ¶
type SearchRepoOptions struct { Keyword string OwnerID int64 UserID int64 // When set results will contain all public/private repositories user has access to OrderBy string Private bool // Include private repositories in results Page int PageSize int // Can be smaller than or equal to setting.ExplorePagingNum }
type SlackAttachment ¶
type SlackPayload ¶
type SlackPayload struct { Channel string `json:"channel"` Text string `json:"text"` Username string `json:"username"` IconURL string `json:"icon_url"` UnfurlLinks int `json:"unfurl_links"` LinkNames int `json:"link_names"` Attachments []*SlackAttachment `json:"attachments"` }
func GetSlackPayload ¶
func GetSlackPayload(p api.Payloader, event HookEventType, meta string) (payload *SlackPayload, err error)
func (*SlackPayload) JSONPayload ¶
func (p *SlackPayload) JSONPayload() ([]byte, error)
type Statistic ¶
type Statistic struct { Counter struct { User, Org, PublicKey, Repo, Watch, Star, Action, Access, Issue, Comment, Oauth, Follow, Mirror, Release, LoginSource, Webhook, Milestone, Label, HookTask, Team, UpdateTask, Attachment int64 } }
func GetStatistic ¶
type Tag ¶ added in v0.12.4
func GetTagsByPath ¶ added in v0.12.4
type Team ¶
type Team struct { ID int64 OrgID int64 `xorm:"INDEX"` LowerName string Name string Description string Authorize AccessMode Repos []*Repository `xorm:"-" json:"-"` Members []*User `xorm:"-" json:"-"` NumRepos int NumMembers int }
Team represents a organization team.
func GetTeamByID ¶
GetTeamByID returns team by given ID.
func GetTeamOfOrgByName ¶
GetTeamOfOrgByName returns team by given team name and organization.
func GetTeamsByOrgID ¶
GetTeamsByOrgID returns all teams belong to given organization.
func GetTeamsHaveAccessToRepo ¶
func GetTeamsHaveAccessToRepo(orgID, repoID int64, mode AccessMode) ([]*Team, error)
GetTeamsHaveAccessToRepo returns all teams in an organization that have given access level to the repository.
func GetUserTeams ¶
GetUserTeams returns all teams that user belongs to in given organization.
func (*Team) AddMember ¶
AddMember adds new membership of the team to the organization, the user will have membership to the organization automatically when needed.
func (*Team) AddRepository ¶
func (t *Team) AddRepository(repo *Repository) (err error)
AddRepository adds new repository to team of organization.
func (*Team) GetMembers ¶
GetMembers returns all members in team of organization.
func (*Team) GetRepositories ¶
GetRepositories returns all repositories in team of organization.
func (*Team) HasRepository ¶
HasRepository returns true if given repository belong to team.
func (*Team) HasWriteAccess ¶
HasWriteAccess returns true if team has at least write level access mode.
func (*Team) IsOwnerTeam ¶
IsOwnerTeam returns true if team is owner team.
func (*Team) RemoveMember ¶
RemoveMember removes member from team of organization.
func (*Team) RemoveRepository ¶
RemoveRepository removes repository from team of organization.
type TeamRepo ¶
type TeamRepo struct { ID int64 OrgID int64 `xorm:"INDEX"` TeamID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` }
TeamRepo represents an team-repository relation.
type TeamUser ¶
type TeamUser struct { ID int64 OrgID int64 `xorm:"INDEX"` TeamID int64 `xorm:"UNIQUE(s)"` UID int64 `xorm:"UNIQUE(s)"` }
TeamUser represents an team-user relation.
type TwoFactor ¶
type TwoFactor struct { ID int64 `gorm:"primaryKey"` UserID int64 `xorm:"UNIQUE" gorm:"unique"` Secret string Created time.Time `xorm:"-" gorm:"-" json:"-"` CreatedUnix int64 }
TwoFactor is a 2FA token of a user.
func (*TwoFactor) BeforeCreate ¶
BeforeCreate implements the GORM create hook.
type TwoFactorRecoveryCode ¶
type TwoFactorRecoveryCode struct { ID int64 UserID int64 Code string `xorm:"VARCHAR(11)"` IsUsed bool }
TwoFactorRecoveryCode represents a two-factor authentication recovery code.
func GetRecoveryCodesByUserID ¶
func GetRecoveryCodesByUserID(userID int64) ([]*TwoFactorRecoveryCode, error)
GetRecoveryCodesByUserID returns all recovery codes of given user.
type TwoFactorsStore ¶
type TwoFactorsStore interface { // Create creates a new 2FA token and recovery codes for given user. The "key" // is used to encrypt and later decrypt given "secret", which should be // configured in site-level and change of the "key" will break all existing 2FA // tokens. Create(ctx context.Context, userID int64, key, secret string) error // GetByUserID returns the 2FA token of given user. It returns // ErrTwoFactorNotFound when not found. GetByUserID(ctx context.Context, userID int64) (*TwoFactor, error) // IsEnabled returns true if the user has enabled 2FA. IsEnabled(ctx context.Context, userID int64) bool }
TwoFactorsStore is the persistent interface for 2FA.
var TwoFactors TwoFactorsStore
type UpdateRepoFileOptions ¶
type UpdateUserOptions ¶ added in v0.13.0
type UpdateUserOptions struct { LoginSource *int64 LoginName *string Password *string // GenerateNewRands indicates whether to force generate new rands for the user. GenerateNewRands bool FullName *string Email *string Website *string Location *string Description *string MaxRepoCreation *int LastRepoVisibility *bool IsActivated *bool IsAdmin *bool AllowGitHook *bool AllowImportLocal *bool ProhibitLogin *bool Avatar *string AvatarEmail *string }
type Upload ¶
Upload represent a uploaded file to a repo to be deleted when moved
func GetUploadByUUID ¶
func GetUploadsByUUIDs ¶
type UploadRepoFileOptions ¶
type User ¶
type User struct { ID int64 `gorm:"primaryKey"` LowerName string `xorm:"UNIQUE NOT NULL" gorm:"unique;not null"` Name string `xorm:"UNIQUE NOT NULL" gorm:"not null"` FullName string // Email is the primary email address (to be used for communication) Email string `xorm:"NOT NULL" gorm:"not null"` Password string `xorm:"passwd NOT NULL" gorm:"column:passwd;not null"` LoginSource int64 `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"` LoginName string Type UserType Location string Website string Rands string `xorm:"VARCHAR(10)" gorm:"type:VARCHAR(10)"` Salt string `xorm:"VARCHAR(10)" gorm:"type:VARCHAR(10)"` Created time.Time `xorm:"-" gorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" gorm:"-" json:"-"` UpdatedUnix int64 // Remember visibility choice for convenience, true for private LastRepoVisibility bool // Maximum repository creation limit, -1 means use global default MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1" gorm:"not null;default:-1"` // Permissions IsActive bool // Activate primary email IsAdmin bool AllowGitHook bool AllowImportLocal bool // Allow migrate repository by local path ProhibitLogin bool // Avatar Avatar string `xorm:"VARCHAR(2048) NOT NULL" gorm:"type:VARCHAR(2048);not null"` AvatarEmail string `xorm:"NOT NULL" gorm:"not null"` UseCustomAvatar bool // Counters NumFollowers int NumFollowing int `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"` NumStars int NumRepos int // For organization Description string NumTeams int NumMembers int Teams []*Team `xorm:"-" gorm:"-" json:"-"` Members []*User `xorm:"-" gorm:"-" json:"-"` }
User represents the object of an individual or an organization.
func GetOrgByName ¶
GetOrgByName returns organization by given name.
func GetOrgsByUserID ¶
GetOrgsByUserID returns a list of organizations that the given user ID has joined.
func GetOwnedOrgsByUserID ¶
GetOwnedOrgsByUserID returns a list of organizations are owned by given user ID.
func GetOwnedOrgsByUserIDDesc ¶
GetOwnedOrganizationsByUserIDDesc returns a list of organizations are owned by given user ID, ordered descending by the given condition.
func GetParticipantsByIssueID ¶
GetParticipantsByIssueID returns all users who are participated in comments of an issue.
func GetTeamMembers ¶
GetTeamMembers returns all members in given team of organization.
func NewGhostUser ¶
func NewGhostUser() *User
NewGhostUser creates and returns a fake user for people who has deleted their accounts.
TODO: Once migrated to unknwon.dev/i18n, pass in the `i18n.Locale` to translate the text to local language.
func Organizations ¶
Organizations returns number of organizations in given page.
func (*User) AvatarURL ¶ added in v0.13.0
AvatarURL returns the full URL to the user or organization avatar. If the user enables Gravatar-like service, then an external URL will be returned.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User` and move this to the "userutil" package.
func (*User) AvatarURLPath ¶ added in v0.13.0
AvatarURLPath returns the URL path to the user or organization avatar. If the user enables Gravatar-like service, then an external URL will be returned.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User` and move this to the "userutil" package.
func (*User) BeforeCreate ¶
BeforeCreate implements the GORM create hook.
func (*User) CanCreateOrganization ¶
CanCreateOrganization returns true if user can create organizations.
func (*User) CanEditGitHook ¶
CanEditGitHook returns true if user can edit Git hooks.
func (*User) CanImportLocal ¶
CanImportLocal returns true if user can migrate repositories by local path.
func (*User) DisplayName ¶
DisplayName returns the full name of the user if it's not empty, returns the username otherwise.
func (*User) GetMembers ¶
GetMembers returns all members of organization.
func (*User) GetOrganizationCount ¶
GetOrganizationCount returns the count of organization membership that the user has.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User`.
func (*User) GetOwnerTeam ¶
GetOwnerTeam returns owner team of organization.
func (*User) GetUserMirrorRepositories ¶
func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)
GetUserMirrorRepositories returns mirror repositories of the organization which the user has access to.
func (*User) GetUserRepositories ¶
func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repository, int64, error)
GetUserRepositories returns a range of repositories in organization which the user has access to, and total number of records based on given condition.
func (*User) GetUserTeamIDs ¶
GetUserTeamIDs returns of all team IDs of the organization that user is member of.
func (*User) GetUserTeams ¶
GetTeams returns all teams that belong to organization, and that the user has joined.
func (*User) HTMLURL ¶
HTMLURL returns the full URL to the user or organization home page.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User` and move this to the "userutil" package.
func (*User) HomeURLPath ¶ added in v0.13.0
HomeURLPath returns the URL path to the user or organization home page.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User` and move this to the "userutil" package.
func (*User) IsFollowing ¶
IsFollowing returns true if the user is following the given user.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User`.
func (*User) IsOrgMember ¶
IsOrgMember returns true if given user is member of organization.
func (*User) IsOrganization ¶
IsOrganization returns true if the user is an organization.
func (*User) IsPublicMember ¶
IsPublicMember returns true if the user has public membership of the given organization.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User`.
func (*User) IsUserOrgOwner ¶
IsUserOrgOwner returns true if the user is in the owner team of the given organization.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User`.
func (*User) RemoveMember ¶
RemoveMember removes member from organization.
func (*User) RemoveOrgRepo ¶
RemoveOrgRepo removes all team-repository relations of organization.
func (*User) ShortName ¶
ShortName truncates and returns the username at most in given length.
TODO(unknwon): This is also used in templates, which should be fixed by having a dedicated type `template.User`.
func (*User) TeamsHaveAccessToRepo ¶
func (org *User) TeamsHaveAccessToRepo(repoID int64, mode AccessMode) ([]*Team, error)
TeamsHaveAccessToRepo returns all teams that have given access level to the repository.
type UserRepoOptions ¶
type UsersStore ¶
type UsersStore interface { // Authenticate validates username and password via given login source ID. It // returns ErrUserNotExist when the user was not found. // // When the "loginSourceID" is negative, it aborts the process and returns // ErrUserNotExist if the user was not found in the database. // // When the "loginSourceID" is non-negative, it returns ErrLoginSourceMismatch // if the user has different login source ID than the "loginSourceID". // // When the "loginSourceID" is positive, it tries to authenticate via given // login source and creates a new user when not yet exists in the database. Authenticate(ctx context.Context, username, password string, loginSourceID int64) (*User, error) // Create creates a new user and persists to database. It returns // ErrNameNotAllowed if the given name or pattern of the name is not allowed as // a username, or ErrUserAlreadyExist when a user with same name already exists, // or ErrEmailAlreadyUsed if the email has been used by another user. Create(ctx context.Context, username, email string, opts CreateUserOptions) (*User, error) // GetByEmail returns the user (not organization) with given email. It ignores // records with unverified emails and returns ErrUserNotExist when not found. GetByEmail(ctx context.Context, email string) (*User, error) // GetByID returns the user with given ID. It returns ErrUserNotExist when not // found. GetByID(ctx context.Context, id int64) (*User, error) // GetByUsername returns the user with given username. It returns // ErrUserNotExist when not found. GetByUsername(ctx context.Context, username string) (*User, error) // GetByKeyID returns the owner of given public key ID. It returns // ErrUserNotExist when not found. GetByKeyID(ctx context.Context, keyID int64) (*User, error) // GetMailableEmailsByUsernames returns a list of verified primary email // addresses (where email notifications are sent to) of users with given list of // usernames. Non-existing usernames are ignored. GetMailableEmailsByUsernames(ctx context.Context, usernames []string) ([]string, error) // SearchByName returns a list of users whose username or full name matches the // given keyword case-insensitively. Results are paginated by given page and // page size, and sorted by the given order (e.g. "id DESC"). A total count of // all results is also returned. If the order is not given, it's up to the // database to decide. SearchByName(ctx context.Context, keyword string, page, pageSize int, orderBy string) ([]*User, int64, error) // IsUsernameUsed returns true if the given username has been used other than // the excluded user (a non-positive ID effectively meaning check against all // users). IsUsernameUsed(ctx context.Context, username string, excludeUserId int64) bool // ChangeUsername changes the username of the given user and updates all // references to the old username. It returns ErrNameNotAllowed if the given // name or pattern of the name is not allowed as a username, or // ErrUserAlreadyExist when another user with same name already exists. ChangeUsername(ctx context.Context, userID int64, newUsername string) error // Update updates fields for the given user. Update(ctx context.Context, userID int64, opts UpdateUserOptions) error // UseCustomAvatar uses the given avatar as the user custom avatar. UseCustomAvatar(ctx context.Context, userID int64, avatar []byte) error // DeleteCustomAvatar deletes the current user custom avatar and falls back to // use look up avatar by email. DeleteCustomAvatar(ctx context.Context, userID int64) error // DeleteByID deletes the given user and all their resources. It returns // ErrUserOwnRepos when the user still has repository ownership, or returns // ErrUserHasOrgs when the user still has organization membership. It is more // performant to skip rewriting the "authorized_keys" file for individual // deletion in a batch operation. DeleteByID(ctx context.Context, userID int64, skipRewriteAuthorizedKeys bool) error // DeleteInactivated deletes all inactivated users. DeleteInactivated() error // Follow marks the user to follow the other user. Follow(ctx context.Context, userID, followID int64) error // Unfollow removes the mark the user to follow the other user. Unfollow(ctx context.Context, userID, followID int64) error // IsFollowing returns true if the user is following the other user. IsFollowing(ctx context.Context, userID, followID int64) bool // ListFollowers returns a list of users that are following the given user. // Results are paginated by given page and page size, and sorted by the time of // follow in descending order. ListFollowers(ctx context.Context, userID int64, page, pageSize int) ([]*User, error) // ListFollowings returns a list of users that are followed by the given user. // Results are paginated by given page and page size, and sorted by the time of // follow in descending order. ListFollowings(ctx context.Context, userID int64, page, pageSize int) ([]*User, error) // List returns a list of users. Results are paginated by given page and page // size, and sorted by primary key (id) in ascending order. List(ctx context.Context, page, pageSize int) ([]*User, error) // Count returns the total number of users. Count(ctx context.Context) int64 }
UsersStore is the persistent interface for users.
var Users UsersStore
func NewUsersStore ¶ added in v0.13.0
func NewUsersStore(db *gorm.DB) UsersStore
NewUsersStore returns a persistent interface for users with given database connection.
type Watch ¶
type Watch struct { ID int64 `gorm:"primaryKey"` UserID int64 `xorm:"UNIQUE(watch)" gorm:"uniqueIndex:watch_user_repo_unique;not null"` RepoID int64 `xorm:"UNIQUE(watch)" gorm:"uniqueIndex:watch_user_repo_unique;not null"` }
Watch is connection request for receiving repository notification.
func GetWatchers
deprecated
type Webhook ¶
type Webhook struct { ID int64 RepoID int64 OrgID int64 URL string `xorm:"url TEXT"` ContentType HookContentType Secret string `xorm:"TEXT"` Events string `xorm:"TEXT"` *HookEvent `xorm:"-"` // LEGACY [1.0]: Cannot ignore JSON (i.e. json:"-") here, it breaks old backup archive IsSSL bool `xorm:"is_ssl"` IsActive bool HookTaskType HookTaskType Meta string `xorm:"TEXT"` // store hook-specific attributes LastStatus HookStatus // Last delivery status Created time.Time `xorm:"-" json:"-"` CreatedUnix int64 Updated time.Time `xorm:"-" json:"-"` UpdatedUnix int64 }
Webhook represents a web hook object.
func GetWebhookByID ¶
GetWebhookByID returns webhook by given ID. Use this function with caution of accessing unauthorized webhook, which means should only be used in non-user interactive functions.
func GetWebhookByOrgID ¶
GetWebhookByOrgID returns webhook of organization by given ID.
func GetWebhookOfRepoByID ¶
GetWebhookOfRepoByID returns webhook of repository by given ID.
func GetWebhooksByOrgID ¶
GetWebhooksByOrgID returns all webhooks for an organization.
func GetWebhooksByRepoID ¶
GetWebhooksByRepoID returns all webhooks of a repository.
func (*Webhook) BeforeInsert ¶
func (w *Webhook) BeforeInsert()
func (*Webhook) BeforeUpdate ¶
func (w *Webhook) BeforeUpdate()
func (*Webhook) EventsArray ¶
func (*Webhook) HasCreateEvent ¶
HasCreateEvent returns true if hook enabled create event.
func (*Webhook) HasDeleteEvent ¶
HasDeleteEvent returns true if hook enabled delete event.
func (*Webhook) HasForkEvent ¶
HasForkEvent returns true if hook enabled fork event.
func (*Webhook) HasIssueCommentEvent ¶
HasIssueCommentEvent returns true if hook enabled issue comment event.
func (*Webhook) HasIssuesEvent ¶
HasIssuesEvent returns true if hook enabled issues event.
func (*Webhook) HasPullRequestEvent ¶
HasPullRequestEvent returns true if hook enabled pull request event.
func (*Webhook) HasPushEvent ¶
HasPushEvent returns true if hook enabled push event.
func (*Webhook) HasReleaseEvent ¶
HasReleaseEvent returns true if hook enabled release event.
func (*Webhook) UpdateEvent ¶
UpdateEvent handles conversion from HookEvent to Events.
Source Files ¶
- access_tokens.go
- actions.go
- admin.go
- attachment.go
- backup.go
- comment.go
- db.go
- email_addresses.go
- error.go
- issue.go
- issue_label.go
- issue_mail.go
- lfs.go
- login_source_files.go
- login_sources.go
- milestone.go
- mirror.go
- mocks.go
- models.go
- org.go
- org_team.go
- orgs.go
- perms.go
- public_keys.go
- pull.go
- release.go
- repo.go
- repo_branch.go
- repo_collaboration.go
- repo_editor.go
- repo_tag.go
- repos.go
- ssh_key.go
- two_factor.go
- two_factors.go
- update.go
- user_mail.go
- users.go
- webhook.go
- webhook_dingtalk.go
- webhook_discord.go
- webhook_slack.go
- wiki.go