Documentation
¶
Index ¶
- Constants
- Variables
- func AddEmailAddress(email *EmailAddress) error
- func AddOauth2(oa *Oauth2) error
- func AddOrgUser(orgId, uid int64) error
- func AddPublicKey(key *PublicKey) (err error)
- func AddTeamMember(orgId, teamId, uid int64) error
- func AddTeamRepo(orgID, teamID, repoID int64) error
- func AddUpdateTask(task *UpdateTask) error
- func BindUserOauth2(userId, oauthId int64) error
- func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error)
- func ChangeMilestoneIssueStats(issue *Issue) error
- func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error)
- func ChangeOrgUserStatus(orgId, uid int64, public bool) error
- func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error)
- func ChangeUserName(u *User, newUserName string) (err error)
- func CheckPublicKeyString(content string) (bool, error)
- func CleanUnbindOauth() error
- func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, repoId int64, ...) error
- func CountNotices() int64
- func CountOrganizations() int64
- func CountRepositories() int64
- func CountUsers() int64
- func CreateHookTask(t *HookTask) error
- func CreateNotice(tp NoticeType, desc string) error
- func CreateRelease(gitRepo *git.Repository, rel *Release) error
- func CreateRepositoryNotice(desc string) error
- func CreateSource(source *LoginSource) error
- func CreateUser(u *User) error
- func CreateWebhook(w *Webhook) error
- func DelLoginSource(source *LoginSource) error
- func DelUpdateTasksByUuid(uuid string) error
- func DeleteAccessTokenById(id int64) 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 DeleteBeans(e Engine, beans ...interface{}) (err error)
- func DeleteEmailAddress(email *EmailAddress) error
- func DeleteInactivateUsers() error
- func DeleteLabel(repoId int64, strId string) error
- func DeleteMilestone(m *Milestone) (err error)
- func DeleteNotice(id int64) error
- func DeleteOauth2ById(id int64) error
- func DeleteOrganization(org *User) (err error)
- func DeletePublicKey(key *PublicKey) error
- func DeleteRepository(uid, repoID int64, userName string) error
- func DeleteRepositoryArchives() error
- func DeleteTeam(t *Team) error
- func DeleteUser(u *User) error
- func DeleteWebhook(hookId int64) error
- func DeliverHooks()
- func DumpDatabase(filePath string) error
- func FollowUser(userId int64, followId int64) (err error)
- func GetIssueCountByPoster(uid, rid int64, isClosed bool) int64
- func GetRepositoryCount(user *User) (int64, error)
- func GetUserEmailsByNames(names []string) []string
- func GetUserIdsByNames(names []string) []int64
- func GetUserSalt() string
- func GitFsck()
- func GitGcRepos() error
- func HasAccess(u *User, repo *Repository, testMode AccessMode) (bool, error)
- func HasTeamRepo(orgID, teamID, repoID int64) bool
- func IsEmailUsed(email string) (bool, error)
- func IsErrLastOrgOwner(err error) bool
- func IsErrRepoNotExist(err error) bool
- func IsErrUserHasOrgs(err error) bool
- func IsErrUserOwnRepos(err error) bool
- func IsLegalName(repoName string) bool
- func IsOrgEmailUsed(email string) (bool, error)
- func IsOrganizationMember(orgId, uid int64) bool
- func IsOrganizationOwner(orgId, uid int64) bool
- func IsPublicMembership(orgId, uid int64) bool
- func IsReleaseExist(repoId int64, tagName string) (bool, error)
- func IsRepositoryExist(u *User, repoName string) bool
- func IsStaring(uid, repoId int64) bool
- func IsTeamMember(orgID, teamID, uid int64) bool
- func IsUserExist(uid int64, name string) (bool, error)
- func IsValidHookContentType(name string) bool
- func IsValidHookTaskType(name string) bool
- func IsWatching(uid, repoId int64) bool
- func LoadModelsConfig()
- func LoadRepoConfig()
- func LoginAuth(username, password string) smtp.Auth
- func MakeEmailPrimary(email *EmailAddress) error
- func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error
- func MirrorUpdate()
- func NewAccessToken(t *AccessToken) error
- func NewEngine() (err error)
- func NewIssue(issue *Issue) (err error)
- func NewIssueUserPairs(repo *Repository, issueID, orgID, posterID, assigneeID int64) (err error)
- func NewLabel(l *Label) error
- func NewMilestone(m *Milestone) (err error)
- func NewRepoAction(u *User, repo *Repository) (err error)
- func NewRepoContext()
- func NewTeam(t *Team) error
- func NewTestEngine(x *xorm.Engine) (err error)
- func NotifyWatchers(act *Action) error
- func PairsContains(ius []*IssueUser, issueId int64) int
- func ParseKeyString(content string) (string, error)
- func Ping() error
- func RemoveOrgRepo(orgID, repoID int64) error
- func RemoveOrgUser(orgId, uid int64) error
- func RemoveTeamMember(orgId, teamId, uid int64) error
- func RemoveTeamRepo(teamID, repoID int64) error
- func RepoPath(userName, repoName string) string
- func RewriteAllPublicKeys() error
- func RewriteRepositoryUpdateHook() error
- func SetEngine() (err error)
- func SlackLinkFormatter(url string, text string) string
- func SlackTextFormatter(s string) string
- func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error
- func SortReleases(rels []*Release)
- func StarRepo(uid, repoId int64, star bool) (err error)
- func TransferOwnership(u *User, newOwnerName string, repo *Repository) error
- func TransferRepoAction(actUser, oldOwner, newOwner *User, repo *Repository) (err error)
- func UnFollowUser(userId int64, unFollowId int64) (err error)
- func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, ...) error
- func UpdateHookTask(t *HookTask) error
- func UpdateIssue(issue *Issue) error
- func UpdateIssueUserPairByAssignee(aid, iid int64) error
- func UpdateIssueUserPairByRead(uid, iid int64) error
- func UpdateIssueUserPairsByMentions(uids []int64, iid int64) error
- func UpdateIssueUserPairsByStatus(iid int64, isClosed bool) error
- func UpdateLabel(l *Label) error
- func UpdateMentions(userNames []string, issueId int64) error
- func UpdateMilestone(m *Milestone) error
- func UpdateMirror(m *Mirror) error
- func UpdateOauth2(oa *Oauth2) error
- func UpdatePublicKey(key *PublicKey) error
- func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error)
- func UpdateRepository(repo *Repository, visibilityChanged bool) (err error)
- func UpdateSource(source *LoginSource) error
- func UpdateTeam(t *Team, authChanged bool) (err error)
- func UpdateUser(u *User) error
- func UpdateWebhook(w *Webhook) error
- func UserPath(userName string) string
- func ValidateCommitsWithEmails(oldCommits *list.List) *list.List
- func WatchRepo(uid, repoId int64, watch bool) (err error)
- type Access
- type AccessMode
- type AccessToken
- type Action
- func (a Action) GetActEmail() string
- func (a Action) GetActUserName() string
- func (a Action) GetBranch() string
- func (a Action) GetContent() string
- func (a Action) GetCreate() time.Time
- func (a Action) GetIssueInfos() []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
- type ActionType
- type Attachment
- func CreateAttachment(issueId, commentId int64, name, path string) (*Attachment, error)
- func GetAttachmentById(id int64) (*Attachment, error)
- func GetAttachmentsByComment(commentId int64) ([]*Attachment, error)
- func GetAttachmentsByIssue(issueId int64) ([]*Attachment, error)
- func GetAttachmentsForIssue(issueId int64) ([]*Attachment, error)
- type BasePayload
- type CloneLink
- type Collaboration
- type Comment
- type CommentType
- type Diff
- type DiffFile
- type DiffLine
- type DiffSection
- type EmailAddress
- type Engine
- type ErrLastOrgOwner
- type ErrRepoNotExist
- type ErrUserHasOrgs
- type ErrUserOwnRepos
- type Follow
- type HookContentType
- type HookEvent
- type HookEventType
- type HookTask
- type HookTaskType
- type Issue
- func GetIssueById(id int64) (*Issue, error)
- func GetIssueByIndex(rid, index int64) (*Issue, error)
- func GetIssueByRef(ref string) (issue *Issue, err error)
- func GetIssues(uid, rid, pid, mid int64, page int, isClosed bool, labelIds, sortType string) ([]Issue, error)
- func GetIssuesByLabel(repoId int64, label string) ([]*Issue, error)
- type IssueStats
- type IssueStatus
- type IssueUser
- type LDAPConfig
- type Label
- type LoginSource
- type LoginType
- type Milestone
- type Mirror
- type Notice
- type NoticeType
- type Oauth2
- type OauthType
- type OrgUser
- type Payload
- type PayloadAuthor
- type PayloadCommit
- type PayloadRepo
- type PublicKey
- type Release
- type ReleaseSorter
- type Repository
- func CreateRepository(u *User, name, desc, lang, license string, ...) (_ *Repository, err error)
- func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error)
- func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error)
- func GetRepositories(uid int64, private bool) ([]*Repository, error)
- func GetRepositoriesWithUsers(num, offset int) ([]*Repository, error)
- func GetRepositoryById(id int64) (*Repository, error)
- func GetRepositoryByName(uid int64, repoName string) (*Repository, error)
- func GetRepositoryByRef(ref string) (*Repository, error)
- func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error)
- func SearchRepositoryByName(opt SearchOption) (repos []*Repository, err error)
- func (repo *Repository) AddCollaborator(u *User) error
- func (repo *Repository) CloneLink() (cl CloneLink, err error)
- func (repo *Repository) DeleteCollaborator(u *User) (err error)
- func (repo *Repository) DescriptionHtml() template.HTML
- func (repo *Repository) GetCollaborators() ([]*User, error)
- func (repo *Repository) GetForkRepo() (err error)
- func (repo *Repository) GetMirror() (err error)
- func (repo *Repository) GetOwner() (err error)
- func (repo *Repository) HasAccess(u *User) bool
- func (repo *Repository) IsOwnedBy(u *User) bool
- func (r *Repository) RecalculateAccesses() error
- func (repo *Repository) RepoLink() (string, error)
- func (repo *Repository) RepoPath() (string, error)
- type SMTPConfig
- type SearchOption
- type Slack
- type SlackAttachment
- type SlackPayload
- type Star
- type Statistic
- type Team
- func (t *Team) AddMember(uid int64) error
- func (t *Team) AddRepository(repo *Repository) (err error)
- func (t *Team) GetMembers() (err error)
- func (t *Team) GetRepositories() error
- func (t *Team) HasRepository(repoID int64) bool
- func (t *Team) IsMember(uid 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 UpdateTask
- type User
- func CreateOrganization(org, owner *User) (*User, error)
- func GetOrgByName(name string) (*User, error)
- func GetOrganizations(num, offset int) ([]*User, error)
- func GetTeamMembers(teamID int64) ([]*User, error)
- func GetUserByEmail(email string) (*User, error)
- func GetUserById(id int64) (*User, error)
- func GetUserByKeyId(keyId int64) (*User, error)
- func GetUserByName(name string) (*User, error)
- func GetUsers(num, offset int) ([]*User, error)
- func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, ...) (*User, error)
- func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTPConfig, ...) (*User, error)
- func SearchUserByName(opt SearchOption) (us []*User, err error)
- func UserSignIn(uname, passwd string) (*User, error)
- func ValidateCommitWithEmail(c *git.Commit) *User
- func VerifyUserActiveCode(code string) (user *User)
- func (org *User) AddMember(uid int64) error
- func (u *User) AvatarLink() string
- func (u *User) CustomAvatarPath() string
- func (u *User) DashboardLink() string
- func (u *User) EncodePasswd()
- func (u *User) GetAccessibleRepositories() (map[*Repository]AccessMode, error)
- func (u *User) GetFullNameFallback() string
- func (org *User) GetMembers() error
- func (u *User) GetOrganizationCount() (int64, error)
- func (u *User) GetOrganizations() error
- func (org *User) GetOwnerTeam() (*Team, error)
- func (u *User) GetRepositories() (err error)
- func (org *User) GetTeam(name string) (*Team, error)
- func (org *User) GetTeams() error
- func (u *User) HomeLink() string
- func (org *User) IsOrgMember(uid int64) bool
- func (u *User) IsOrganization() bool
- func (org *User) IsOwnedBy(uid int64) bool
- func (u *User) IsPublicMember(orgId int64) bool
- func (u *User) IsUserOrgOwner(orgId int64) bool
- func (u *User) NewGitSig() *git.Signature
- func (org *User) RemoveMember(uid int64) error
- func (org *User) RemoveOrgRepo(repoID int64) error
- func (u *User) UploadAvatar(data []byte) error
- func (u *User) ValidtePassword(passwd string) bool
- type UserCommit
- type UserType
- type Watch
- type Webhook
- func GetActiveWebhooksByOrgId(orgId int64) (ws []*Webhook, err error)
- func GetActiveWebhooksByRepoId(repoId int64) (ws []*Webhook, err error)
- func GetWebhookById(hookId int64) (*Webhook, error)
- func GetWebhooksByOrgId(orgId int64) (ws []*Webhook, err error)
- func GetWebhooksByRepoId(repoId int64) (ws []*Webhook, err error)
Constants ¶
const ( DIFF_LINE_PLAIN = iota + 1 DIFF_LINE_ADD DIFF_LINE_DEL DIFF_LINE_SECTION )
Diff line types.
const ( DIFF_FILE_ADD = iota + 1 DIFF_FILE_CHANGE DIFF_FILE_DEL )
const ( IS_OPEN = iota + 1 IS_CLOSE )
const ( FM_ASSIGN = iota + 1 FM_CREATE FM_MENTION )
Filter modes.
const DIFF_HEAD = "diff --git "
const (
MAX_COMMITS int = 5
)
const OWNER_TEAM = "Owners"
const (
SLACK_COLOR string = "#dd4b39"
)
Variables ¶
var ( // Same as Github. See https://help.github.com/articles/closing-issues-via-commit-messages IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} IssueReopenKeywords = []string{"reopen", "reopens", "reopened"} IssueCloseKeywordsPat, IssueReopenKeywordsPat *regexp.Regexp IssueReferenceKeywordsPat *regexp.Regexp )
var ( ErrIssueNotExist = errors.New("Issue does not exist") ErrLabelNotExist = errors.New("Label does not exist") ErrMilestoneNotExist = errors.New("Milestone does not exist") ErrWrongIssueCounter = errors.New("Invalid number of issues for this milestone") ErrAttachmentNotExist = errors.New("Attachment does not exist") ErrAttachmentNotLinked = errors.New("Attachment does not belong to this issue") ErrMissingIssueNumber = errors.New("No issue number specified") )
var ( ErrAuthenticationAlreadyExist = errors.New("Authentication already exist") ErrAuthenticationNotExist = errors.New("Authentication does not exist") ErrAuthenticationUserUsed = errors.New("Authentication has been used by some users") )
var ( SMTP_PLAIN = "PLAIN" SMTP_LOGIN = "LOGIN" SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN} )
var ( HasEngine bool DbCfg struct { Type, Host, Name, User, Passwd, Path, SSLMode string } EnableSQLite3 bool )
var ( ErrOauth2RecordNotExist = errors.New("OAuth2 record does not exist") ErrOauth2NotAssociated = errors.New("OAuth2 is not associated with user") )
var ( ErrOrgNotExist = errors.New("Organization does not exist") ErrTeamAlreadyExist = errors.New("Team already exist") ErrTeamNotExist = errors.New("Team does not exist") ErrTeamNameIllegal = errors.New("Team name contains illegal characters") )
var ( ErrKeyAlreadyExist = errors.New("Public key already exists") ErrKeyNotExist = errors.New("Public key does not exist") ErrKeyUnableVerify = errors.New("Unable to verify public key") )
var ( ErrReleaseAlreadyExist = errors.New("Release already exist") ErrReleaseNotExist = errors.New("Release does not exist") )
var ( ErrRepoAlreadyExist = errors.New("Repository already exist") ErrRepoFileNotExist = errors.New("Repository file does not exist") ErrRepoNameIllegal = errors.New("Repository name contains illegal characters") ErrRepoFileNotLoaded = errors.New("Repository file not loaded") ErrMirrorNotExist = errors.New("Mirror does not exist") ErrInvalidReference = errors.New("Invalid reference specified") )
var ( ErrUserAlreadyExist = errors.New("User already exist") ErrUserNotExist = errors.New("User does not exist") ErrUserNotKeyOwner = errors.New("User does not the owner of public key") ErrEmailAlreadyUsed = errors.New("E-mail already used") ErrEmailNotExist = errors.New("E-mail does not exist") ErrEmailNotActivated = errors.New("E-mail address has not been activated") ErrUserNameIllegal = errors.New("User name contains illegal characters") ErrLoginSourceNotExist = errors.New("Login source does not exist") ErrLoginSourceNotActived = errors.New("Login source is not actived") ErrUnsupportedLoginType = errors.New("Login source is unknown") )
var (
DescPattern = regexp.MustCompile(`https?://\S+`)
)
var (
ErrAccessTokenNotExist = errors.New("Access token does not exist")
)
var (
ErrNotImplemented = errors.New("Not implemented yet")
)
var (
ErrWebhookNotExist = errors.New("Webhook does not exist")
)
var (
Gitignores, Licenses []string
)
var LoginTypes = map[LoginType]string{ LDAP: "LDAP", SMTP: "SMTP", }
var (
SSHPath string // SSH directory.
)
Functions ¶
func AddEmailAddress ¶
func AddEmailAddress(email *EmailAddress) error
func AddOrgUser ¶
AddOrgUser adds new user to given organization.
func AddPublicKey ¶
AddPublicKey adds new public key to database and authorized_keys file.
func AddTeamMember ¶
AddTeamMember adds new member to given team of given organization.
func AddTeamRepo ¶
AddTeamRepo adds new repository relation to team.
func AddUpdateTask ¶
func AddUpdateTask(task *UpdateTask) error
func BindUserOauth2 ¶
func ChangeMilestoneAssign ¶
ChangeMilestoneAssign changes assignment of milestone for issue.
func ChangeMilestoneIssueStats ¶
ChangeMilestoneIssueStats updates the open/closed issues counter and progress for the milestone associated witht the given issue.
func ChangeMilestoneStatus ¶
ChangeMilestoneStatus changes the milestone open/closed status.
func ChangeOrgUserStatus ¶
ChangeOrgUserStatus changes public or private membership status.
func ChangeRepositoryName ¶
ChangeRepositoryName changes all corresponding setting from old repository name to new one.
func ChangeUserName ¶
ChangeUserName changes all corresponding setting from old user name to new one.
func CheckPublicKeyString ¶
CheckPublicKeyString checks if the given public key string is recognized by SSH.
func CommitRepoAction ¶
func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, repoId int64, repoUserName, repoName string, refFullName string, commit *base.PushCommits, oldCommitId string, newCommitId string) error
CommitRepoAction adds new action for committing repository.
func CountOrganizations ¶
func CountOrganizations() int64
CountOrganizations returns number of organizations.
func CountRepositories ¶
func CountRepositories() int64
CountRepositories returns number of repositories.
func CreateHookTask ¶
CreateHookTask creates a new hook task, it handles conversion from Payload to PayloadContent.
func CreateNotice ¶
func CreateNotice(tp NoticeType, desc string) error
CreateNotice creates new system notice.
func CreateRelease ¶
func CreateRelease(gitRepo *git.Repository, rel *Release) error
CreateRelease creates a new release of repository.
func CreateRepositoryNotice ¶
CreateRepositoryNotice creates new system notice with type NOTICE_REPOSITORY.
func CreateSource ¶
func CreateSource(source *LoginSource) error
func DelLoginSource ¶
func DelLoginSource(source *LoginSource) error
func DelUpdateTasksByUuid ¶
func DeleteAccessTokenById ¶
DeleteAccessTokenById deletes access token by given ID.
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 DeleteBeans ¶
DeleteBeans deletes all given beans, beans should contain delete conditions.
func DeleteEmailAddress ¶
func DeleteEmailAddress(email *EmailAddress) error
func DeleteInactivateUsers ¶
func DeleteInactivateUsers() error
DeleteInactivateUsers deletes all inactivate users and email addresses.
func DeleteLabel ¶
DeleteLabel delete a label of given repository.
func DeleteMilestone ¶
DeleteMilestone deletes a milestone.
func DeleteNotice ¶
DeleteNotice deletes a system notice by given ID.
func DeleteOauth2ById ¶
DeleteOauth2ById deletes a oauth2 by ID.
func DeleteOrganization ¶
TODO: need some kind of mechanism to record failure. DeleteOrganization completely and permanently deletes everything of organization.
func DeletePublicKey ¶
DeletePublicKey deletes SSH key information both in database and authorized_keys file.
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 DeleteUser ¶
FIXME: need some kind of mechanism to record failure. HINT: system notice DeleteUser completely and permanently deletes everything of user.
func DeleteWebhook ¶
DeleteWebhook deletes webhook of repository.
func DeliverHooks ¶
func DeliverHooks()
DeliverHooks checks and delivers undelivered hooks. FIXME: maybe can use goroutine to shoot a number of them at same time?
func DumpDatabase ¶
DumpDatabase dumps all data from database to file system.
func FollowUser ¶
FollowUser marks someone be another's follower.
func GetIssueCountByPoster ¶
GetIssueCountByPoster returns number of issues of repository by poster.
func GetRepositoryCount ¶
GetRepositoryCount returns the total number of repositories of user.
func GetUserEmailsByNames ¶
GetUserEmailsByNames returns a list of e-mails corresponds to names.
func GetUserIdsByNames ¶
GetUserIdsByNames returns a slice of ids corresponds to names.
func GitGcRepos ¶
func GitGcRepos() error
func HasAccess ¶
func HasAccess(u *User, repo *Repository, testMode AccessMode) (bool, error)
HasAccess returns true if someone has the request access level. User can be nil!
func HasTeamRepo ¶
HasTeamRepo returns true if given repository belongs to team.
func IsEmailUsed ¶
IsEmailUsed returns true if the e-mail has been used.
func IsErrLastOrgOwner ¶
func IsErrRepoNotExist ¶
func IsErrUserHasOrgs ¶
func IsErrUserOwnRepos ¶
func IsLegalName ¶
IsLegalName returns false if name contains illegal characters.
func IsOrgEmailUsed ¶
IsOrgEmailUsed returns true if the e-mail has been used in organization account.
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 IsUserExist ¶
IsUserExist checks if given user name exist, the user name should be noncased unique. If uid is presented, then check will rule out that one, it is used when update a user name in settings page.
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 LoadModelsConfig ¶
func LoadModelsConfig()
func LoadRepoConfig ¶
func LoadRepoConfig()
func MakeEmailPrimary ¶
func MakeEmailPrimary(email *EmailAddress) error
func MirrorRepository ¶
MirrorRepository creates a mirror repository from source.
func NewAccessToken ¶
func NewAccessToken(t *AccessToken) error
NewAccessToken creates new access token.
func NewIssueUserPairs ¶
func NewIssueUserPairs(repo *Repository, issueID, orgID, posterID, assigneeID int64) (err error)
NewIssueUserPairs adds new issue-user pairs for new issue of repository.
func NewMilestone ¶
NewMilestone creates new milestone of repository.
func NewRepoAction ¶
func NewRepoAction(u *User, repo *Repository) (err error)
NewRepoAction adds new action for creating 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 NotifyWatchers ¶
NotifyWatchers creates batch of actions for every watcher.
func PairsContains ¶
PairsContains returns true when pairs list contains given issue.
func ParseKeyString ¶
Parse any key string in openssh or ssh2 format to clean openssh string (rfc4253)
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 RewriteAllPublicKeys ¶
func RewriteAllPublicKeys() error
RewriteAllPublicKeys removes any authorized key and rewrite all keys from database again.
func RewriteRepositoryUpdateHook ¶
func RewriteRepositoryUpdateHook() error
RewriteRepositoryUpdateHook rewrites all repositories' update hook.
func SlackLinkFormatter ¶
func SlackTextFormatter ¶
func SortReleases ¶
func SortReleases(rels []*Release)
SortReleases sorts releases by number of commits and created time.
func TransferOwnership ¶
func TransferOwnership(u *User, newOwnerName string, repo *Repository) error
TransferOwnership transfers all corresponding setting from old user to new one.
func TransferRepoAction ¶
func TransferRepoAction(actUser, oldOwner, newOwner *User, repo *Repository) (err error)
TransferRepoAction adds new action for transferring repository.
func UnFollowUser ¶
UnFollowUser unmarks someone be another's follower.
func UpdateHookTask ¶
UpdateHookTask updates information of hook task.
func UpdateIssueUserPairByAssignee ¶
UpdateIssueUserPairByAssignee updates issue-user pair for assigning.
func UpdateIssueUserPairByRead ¶
UpdateIssueUserPairByRead updates issue-user pair for reading.
func UpdateIssueUserPairsByMentions ¶
UpdateIssueUserPairsByMentions updates issue-user pairs by mentioning.
func UpdateIssueUserPairsByStatus ¶
UpdateIssueUserByStatus updates issue-user pairs by issue status.
func UpdateMentions ¶
func UpdateMilestone ¶
UpdateMilestone updates information of given milestone.
func UpdateMirror ¶
func UpdatePublicKey ¶
UpdatePublicKey updates given public key.
func UpdateRelease ¶
func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error)
UpdateRelease updates information of a release.
func UpdateRepository ¶
func UpdateRepository(repo *Repository, visibilityChanged bool) (err error)
func UpdateSource ¶
func UpdateSource(source *LoginSource) error
func UpdateTeam ¶
UpdateTeam updates information of team.
func UpdateWebhook ¶
UpdateWebhook updates information of webhook.
func ValidateCommitsWithEmails ¶
ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
Types ¶
type Access ¶
type Access struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"UNIQUE(s)"`
RepoID int64 `xorm:"UNIQUE(s)"`
Mode AccessMode
}
Access represents the highest access level of a user to the 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
const ( ACCESS_MODE_NONE AccessMode = iota ACCESS_MODE_READ ACCESS_MODE_WRITE ACCESS_MODE_ADMIN ACCESS_MODE_OWNER )
func AccessLevel ¶
func AccessLevel(u *User, repo *Repository) (AccessMode, error)
AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the user does not have access. User can be nil!
type AccessToken ¶
type AccessToken struct {
Id int64
Uid int64
Name string
Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
Created time.Time `xorm:"CREATED"`
Updated time.Time
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
}
AccessToken represents a personal access token.
func GetAccessTokenBySha ¶
func GetAccessTokenBySha(sha string) (*AccessToken, error)
GetAccessTokenBySha returns access token by given sha1.
func ListAccessTokens ¶
func ListAccessTokens(uid int64) ([]*AccessToken, error)
ListAccessTokens returns a list of access tokens belongs to given user.
type Action ¶
type Action struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 // Receiver user id.
OpType ActionType
ActUserID int64 // Action user id.
ActUserName string // Action user name.
ActEmail string
ActAvatar string `xorm:"-"`
RepoID int64
RepoUserName string
RepoName string
RefName string
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
Content string `xorm:"TEXT"`
Created time.Time `xorm:"created"`
}
Action represents user operation type and other information to repository., it implemented interface base.Actioner so that can be used in template render.
func (Action) GetActEmail ¶
func (Action) GetActUserName ¶
func (Action) GetContent ¶
func (Action) GetIssueInfos ¶
func (Action) GetRepoLink ¶
func (Action) GetRepoName ¶
func (Action) GetRepoPath ¶
func (Action) GetRepoUserName ¶
type ActionType ¶
type ActionType int
const ( CREATE_REPO ActionType = iota + 1 // 1 DELETE_REPO // 2 STAR_REPO // 3 FOLLOW_REPO // 4 COMMIT_REPO // 5 CREATE_ISSUE // 6 PULL_REQUEST // 7 TRANSFER_REPO // 8 PUSH_TAG // 9 COMMENT_ISSUE // 10 )
type Attachment ¶
type Attachment struct {
Id int64
IssueId int64
CommentId int64
Name string
Path string `xorm:"TEXT"`
Created time.Time `xorm:"CREATED"`
}
func CreateAttachment ¶
func CreateAttachment(issueId, commentId int64, name, path string) (*Attachment, error)
CreateAttachment creates a new attachment inside the database and
func GetAttachmentById ¶
func GetAttachmentById(id int64) (*Attachment, error)
Attachment returns the attachment by given ID.
func GetAttachmentsByComment ¶
func GetAttachmentsByComment(commentId int64) ([]*Attachment, error)
GetAttachmentsByComment returns a list of attachments for the given comment
func GetAttachmentsByIssue ¶
func GetAttachmentsByIssue(issueId int64) ([]*Attachment, error)
GetAttachmentsByIssue returns a list of attachments for the given issue
func GetAttachmentsForIssue ¶
func GetAttachmentsForIssue(issueId int64) ([]*Attachment, error)
type BasePayload ¶
type Collaboration ¶
type Collaboration struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
UserID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
Created time.Time `xorm:"CREATED"`
}
A Collaboration is a relation between an individual and a repository
type Comment ¶
type Comment struct {
Id int64
Type CommentType
PosterId int64
Poster *User `xorm:"-"`
IssueId int64
CommitId int64
Line int64
Content string `xorm:"TEXT"`
Created time.Time `xorm:"CREATED"`
}
Comment represents a comment in commit and issue page.
func CreateComment ¶
func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType CommentType, content string, attachments []int64) (*Comment, error)
CreateComment creates comment of issue or commit.
func GetCommentById ¶
GetCommentById returns the comment with the given id
func GetIssueComments ¶
GetIssueComments returns list of comment by given issue id.
func (*Comment) AfterDelete ¶
func (c *Comment) AfterDelete()
func (*Comment) Attachments ¶
func (c *Comment) Attachments() []*Attachment
Attachments returns the attachments for this comment.
func (*Comment) ContentHtml ¶
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 (Line > 0) COMMENT_TYPE_COMMENT CommentType = iota COMMENT_TYPE_REOPEN COMMENT_TYPE_CLOSE // References. COMMENT_TYPE_ISSUE // Reference from some commit (not part of a pull request) COMMENT_TYPE_COMMIT // Reference from some pull request COMMENT_TYPE_PULL )
type DiffSection ¶
type EmailAddress ¶
type EmailAddress struct {
Id int64
Uid int64 `xorm:"INDEX NOT NULL"`
Email string `xorm:"UNIQUE NOT NULL"`
IsActivated bool
IsPrimary bool `xorm:"-"`
}
EmailAdresses 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 e-mail addresses belongs to given user.
func VerifyActiveEmailCode ¶
func VerifyActiveEmailCode(code, email string) *EmailAddress
verify active code when active account
func (*EmailAddress) Activate ¶
func (email *EmailAddress) Activate() error
type Engine ¶
type Engine interface {
Delete(interface{}) (int64, error)
Exec(string, ...interface{}) (sql.Result, error)
Find(interface{}, ...interface{}) error
Get(interface{}) (bool, error)
Insert(...interface{}) (int64, error)
InsertOne(interface{}) (int64, error)
Id(interface{}) *xorm.Session
Sql(string, ...interface{}) *xorm.Session
Where(string, ...interface{}) *xorm.Session
}
Engine represents a xorm engine or session.
type ErrLastOrgOwner ¶
type ErrLastOrgOwner struct {
UID int64
}
func (ErrLastOrgOwner) Error ¶
func (err ErrLastOrgOwner) Error() string
type ErrRepoNotExist ¶
func (ErrRepoNotExist) Error ¶
func (err ErrRepoNotExist) Error() string
type ErrUserHasOrgs ¶
type ErrUserHasOrgs struct {
UID int64
}
func (ErrUserHasOrgs) Error ¶
func (err ErrUserHasOrgs) Error() string
type ErrUserOwnRepos ¶
type ErrUserOwnRepos struct {
UID int64
}
func (ErrUserOwnRepos) Error ¶
func (err ErrUserOwnRepos) Error() string
type Follow ¶
type Follow struct {
Id int64
UserID int64 `xorm:"unique(follow)"`
FollowID int64 `xorm:"unique(follow)"`
}
Follow is connection request for receiving user notification.
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"`
}
HookEvent represents events that will delivery hook.
type HookTask ¶
type HookTask struct {
Id int64
Uuid string
Type HookTaskType
Url string
BasePayload `xorm:"-"`
PayloadContent string `xorm:"TEXT"`
ContentType HookContentType
EventType HookEventType
IsSsl bool
IsDelivered bool
IsSucceed bool
}
HookTask represents a hook task.
type HookTaskType ¶
type HookTaskType int
const ( GOGS HookTaskType = iota + 1 SLACK )
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
RepoId int64 `xorm:"INDEX"`
Index int64 // Index in one repository.
Name string
Repo *Repository `xorm:"-"`
PosterId int64
Poster *User `xorm:"-"`
LabelIds string `xorm:"TEXT"`
Labels []*Label `xorm:"-"`
MilestoneId int64
AssigneeId int64
Assignee *User `xorm:"-"`
IsRead bool `xorm:"-"`
IsPull bool // Indicates whether is a pull request or not.
IsClosed bool
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
Priority int
NumComments int
Deadline time.Time
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
}
Issue represents an issue or pull request of repository.
func GetIssueById ¶
GetIssueById returns an issue by ID.
func GetIssueByIndex ¶
GetIssueByIndex returns issue by given index in repository.
func GetIssueByRef ¶
GetIssueByRef returns an Issue specified by a GFM reference. See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
func GetIssues ¶
func GetIssues(uid, rid, pid, mid int64, page int, isClosed bool, labelIds, sortType string) ([]Issue, error)
GetIssues returns a list of issues by given conditions.
func GetIssuesByLabel ¶
GetIssuesByLabel returns a list of issues by given label and repository.
func (*Issue) AfterDelete ¶
func (i *Issue) AfterDelete()
func (*Issue) Attachments ¶
func (i *Issue) Attachments() []*Attachment
func (*Issue) GetAssignee ¶
type IssueStats ¶
type IssueStats struct {
OpenCount, ClosedCount int64
AllCount int64
AssignCount int64
CreateCount int64
MentionCount int64
}
IssueStats represents issue statistic information.
func GetIssueStats ¶
func GetIssueStats(rid, uid int64, isShowClosed bool, filterMode int) *IssueStats
GetIssueStats returns issue statistic information by given conditions.
func GetUserIssueStats ¶
func GetUserIssueStats(uid int64, filterMode int) *IssueStats
GetUserIssueStats returns issue statistic information for dashboard by given conditions.
type IssueStatus ¶
type IssueStatus int
type IssueUser ¶
type IssueUser struct {
Id int64
Uid int64 `xorm:"INDEX"` // User ID.
IssueId int64
RepoId int64 `xorm:"INDEX"`
MilestoneId int64
IsRead bool
IsAssigned bool
IsMentioned bool
IsPoster bool
IsClosed bool
}
IssueUser represents an issue-user relation.
func GetIssueUserPairs ¶
GetIssueUserPairs returns issue-user pairs by given repository and user.
type LDAPConfig ¶
type LDAPConfig struct {
ldap.Ldapsource
}
func (*LDAPConfig) FromDB ¶
func (cfg *LDAPConfig) FromDB(bs []byte) error
func (*LDAPConfig) ToDB ¶
func (cfg *LDAPConfig) ToDB() ([]byte, error)
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:"-"`
IsChecked bool `xorm:"-"`
}
Label represents a label of repository for issues.
func GetLabelById ¶
GetLabelById returns a label by given ID.
func (*Label) CalOpenIssues ¶
func (m *Label) CalOpenIssues()
CalOpenIssues calculates the open issues of label.
type LoginSource ¶
type LoginSource struct {
Id int64
Type LoginType
Name string `xorm:"UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"`
AllowAutoRegister bool `xorm:"NOT NULL DEFAULT false"`
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
}
func GetAuths ¶
func GetAuths() ([]*LoginSource, error)
func GetLoginSourceById ¶
func GetLoginSourceById(id int64) (*LoginSource, error)
func (*LoginSource) LDAP ¶
func (source *LoginSource) LDAP() *LDAPConfig
func (*LoginSource) SMTP ¶
func (source *LoginSource) SMTP() *SMTPConfig
func (*LoginSource) TypeString ¶
func (source *LoginSource) TypeString() string
type Milestone ¶
type Milestone struct {
Id int64
RepoId int64 `xorm:"INDEX"`
Index int64
Name string
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
IsClosed bool
NumIssues int
NumClosedIssues int
NumOpenIssues int `xorm:"-"`
Completeness int // Percentage(1-100).
Deadline time.Time
DeadlineString string `xorm:"-"`
ClosedDate time.Time
}
Milestone represents a milestone of repository.
func GetMilestoneById ¶
GetMilestoneById returns the milestone by given ID.
func GetMilestoneByIndex ¶
GetMilestoneByIndex returns the milestone of given repository and index.
func GetMilestones ¶
GetMilestones returns a list of milestones of given repository and status.
func (*Milestone) CalOpenIssues ¶
func (m *Milestone) CalOpenIssues()
CalOpenIssues calculates the open issues of milestone.
type Mirror ¶
type Mirror struct {
Id int64
RepoId int64
RepoName string // <user name>/<repo name>
Interval int // Hour.
Updated time.Time `xorm:"UPDATED"`
NextUpdate time.Time
}
Mirror represents a mirror information of repository.
type Notice ¶
type Notice struct {
Id int64
Type NoticeType
Description string `xorm:"TEXT"`
Created time.Time `xorm:"CREATED"`
}
Notice represents a system notice for admin.
func GetNotices ¶
GetNotices returns given number of notices with offset.
type Oauth2 ¶
type Oauth2 struct {
Id int64
Uid int64 `xorm:"unique(s)"` // userId
User *User `xorm:"-"`
Type int `xorm:"unique(s) unique(oauth)"` // twitter,github,google...
Identity string `xorm:"unique(s) unique(oauth)"` // id..
Token string `xorm:"TEXT not null"`
Created time.Time `xorm:"CREATED"`
Updated time.Time
HasRecentActivity bool `xorm:"-"`
}
func GetOauth2ById ¶
func GetOauthByUserId ¶
GetOauthByUserId returns list of oauthes that are related to given user.
type OrgUser ¶
type OrgUser struct {
ID int64 `xorm:"pk autoincr"`
Uid int64 `xorm:"INDEX UNIQUE(s)"`
OrgID int64 `xorm:"INDEX UNIQUE(s)"`
IsPublic bool
IsOwner bool
NumTeams int
}
OrgUser represents an organization-user relation.
func GetOrgUsersByOrgId ¶
GetOrgUsersByOrgId returns all organization-user relations by organization ID.
func GetOrgUsersByUserId ¶
GetOrgUsersByUserId returns all organization-user relations by user ID.
type Payload ¶
type Payload struct {
Secret string `json:"secret"`
Ref string `json:"ref"`
Commits []*PayloadCommit `json:"commits"`
Repo *PayloadRepo `json:"repository"`
Pusher *PayloadAuthor `json:"pusher"`
Before string `json:"before"`
After string `json:"after"`
CompareUrl string `json:"compare_url"`
}
Payload represents a payload information of hook.
func (Payload) GetJSONPayload ¶
type PayloadAuthor ¶
type PayloadAuthor struct {
Name string `json:"name"`
Email string `json:"email"`
UserName string `json:"username"`
}
FIXME: just use go-gogs-client structs maybe?
type PayloadCommit ¶
type PayloadCommit struct {
Id string `json:"id"`
Message string `json:"message"`
Url string `json:"url"`
Author *PayloadAuthor `json:"author"`
}
type PayloadRepo ¶
type PublicKey ¶
type PublicKey struct {
Id int64
OwnerId int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"UNIQUE(s) NOT NULL"`
Fingerprint string `xorm:"INDEX NOT NULL"`
Content string `xorm:"TEXT NOT NULL"`
Created time.Time `xorm:"CREATED"`
Updated time.Time
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
}
PublicKey represents a SSH key.
func GetPublicKeyById ¶
GetPublicKeyById returns public key by given ID.
func ListPublicKeys ¶
ListPublicKeys returns a list of public keys belongs to given user.
func (*PublicKey) GetAuthorizedString ¶
GetAuthorizedString generates and returns formatted public key string for authorized_keys file.
type Release ¶
type Release struct {
Id int64
RepoId int64
PublisherId int64
Publisher *User `xorm:"-"`
TagName string
LowerTagName string
Target string
Title string
Sha1 string `xorm:"VARCHAR(40)"`
NumCommits int
NumCommitsBehind int `xorm:"-"`
Note string `xorm:"TEXT"`
IsDraft bool `xorm:"NOT NULL DEFAULT false"`
IsPrerelease bool
Created time.Time `xorm:"CREATED"`
}
Release represents a release of repository.
func GetRelease ¶
GetRelease returns release by given ID.
func GetReleasesByRepoId ¶
GetReleasesByRepoId returns a list of releases of repository.
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 Repository ¶
type Repository struct {
Id int64
OwnerId int64 `xorm:"UNIQUE(s)"`
Owner *User `xorm:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
Description string
Website string
DefaultBranch string
NumWatches int
NumStars int
NumForks int
NumIssues int
NumClosedIssues int
NumOpenIssues int `xorm:"-"`
NumPulls int
NumClosedPulls int
NumOpenPulls int `xorm:"-"`
NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumOpenMilestones int `xorm:"-"`
NumTags int `xorm:"-"`
IsPrivate bool
IsBare bool
IsMirror bool
*Mirror `xorm:"-"`
IsFork bool `xorm:"NOT NULL DEFAULT false"`
ForkId int64
ForkRepo *Repository `xorm:"-"`
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
}
Repository represents a git repository.
func CreateRepository ¶
func CreateRepository(u *User, name, desc, lang, license string, isPrivate, isMirror, initReadme bool) (_ *Repository, err error)
CreateRepository creates a repository for given user or organization.
func ForkRepository ¶
func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error)
func GetRecentUpdatedRepositories ¶
func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error)
GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
func GetRepositories ¶
func GetRepositories(uid int64, private bool) ([]*Repository, error)
GetRepositories returns a list of repositories of given user.
func GetRepositoriesWithUsers ¶
func GetRepositoriesWithUsers(num, offset int) ([]*Repository, error)
GetRepositoriesWithUsers returns given number of repository objects with offset. It also auto-gets corresponding users.
func GetRepositoryById ¶
func GetRepositoryById(id int64) (*Repository, error)
GetRepositoryById returns the repository by given id if exists.
func GetRepositoryByName ¶
func GetRepositoryByName(uid int64, repoName string) (*Repository, error)
GetRepositoryByName returns the repository by given name under user if exists.
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 MigrateRepository ¶
func MigrateRepository(u *User, name, desc string, private, mirror bool, url string) (*Repository, error)
MigrateRepository migrates a existing repository from other project hosting.
func SearchRepositoryByName ¶
func SearchRepositoryByName(opt SearchOption) (repos []*Repository, err error)
SearchRepositoryByName returns given number of repositories whose name contains keyword.
func (*Repository) AddCollaborator ¶
func (repo *Repository) AddCollaborator(u *User) error
Add collaborator and accompanying access
func (*Repository) CloneLink ¶
func (repo *Repository) CloneLink() (cl CloneLink, err error)
CloneLink returns clone URLs of repository.
func (*Repository) DeleteCollaborator ¶
func (repo *Repository) DeleteCollaborator(u *User) (err error)
Delete collaborator and accompanying access
func (*Repository) DescriptionHtml ¶
func (repo *Repository) DescriptionHtml() template.HTML
DescriptionHtml does special handles to description and return HTML string.
func (*Repository) GetCollaborators ¶
func (repo *Repository) GetCollaborators() ([]*User, error)
GetCollaborators returns the collaborators for a repository
func (*Repository) GetForkRepo ¶
func (repo *Repository) GetForkRepo() (err error)
func (*Repository) GetMirror ¶
func (repo *Repository) GetMirror() (err error)
func (*Repository) GetOwner ¶
func (repo *Repository) GetOwner() (err error)
func (*Repository) HasAccess ¶
func (repo *Repository) HasAccess(u *User) bool
func (*Repository) IsOwnedBy ¶
func (repo *Repository) IsOwnedBy(u *User) bool
func (*Repository) RecalculateAccesses ¶
func (r *Repository) RecalculateAccesses() error
RecalculateAccesses recalculates all accesses for repository.
func (*Repository) RepoLink ¶
func (repo *Repository) RepoLink() (string, error)
func (*Repository) RepoPath ¶
func (repo *Repository) RepoPath() (string, error)
type SMTPConfig ¶
func (*SMTPConfig) FromDB ¶
func (cfg *SMTPConfig) FromDB(bs []byte) error
func (*SMTPConfig) ToDB ¶
func (cfg *SMTPConfig) ToDB() ([]byte, error)
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 *Payload, meta string) (*SlackPayload, error)
func (SlackPayload) GetJSONPayload ¶
func (p SlackPayload) GetJSONPayload() ([]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 ¶
func GetStatistic() (stats Statistic)
type Team ¶
type Team struct {
ID int64 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
LowerName string
Name string
Description string
Authorize AccessMode
Repos []*Repository `xorm:"-"`
Members []*User `xorm:"-"`
NumRepos int
NumMembers int
}
Team represents a organization team.
func GetTeamById ¶
GetTeamById returns team by given ID.
func GetUserTeams ¶
GetUserTeams returns all teams that user belongs to in given organization.
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) 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 `xorm:"pk autoincr"`
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 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
TeamID int64 `xorm:"UNIQUE(s)"`
Uid int64 `xorm:"UNIQUE(s)"`
}
TeamUser represents an team-user relation.
type UpdateTask ¶
type UpdateTask struct {
Id int64
Uuid string `xorm:"index"`
RefName string
OldCommitId string
NewCommitId string
}
func GetUpdateTasksByUuid ¶
func GetUpdateTasksByUuid(uuid string) ([]*UpdateTask, error)
type User ¶
type User struct {
Id int64
LowerName string `xorm:"UNIQUE NOT NULL"`
Name string `xorm:"UNIQUE NOT NULL"`
FullName string
// Email is the primary email address (to be used for communication).
Email string `xorm:"UNIQUE(s) NOT NULL"`
Passwd string `xorm:"NOT NULL"`
LoginType LoginType
LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
LoginName string
Type UserType `xorm:"UNIQUE(s)"`
Orgs []*User `xorm:"-"`
Repos []*Repository `xorm:"-"`
Location string
Website string
Rands string `xorm:"VARCHAR(10)"`
Salt string `xorm:"VARCHAR(10)"`
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
// Permissions.
IsActive bool
IsAdmin bool
AllowGitHook bool
// Avatar.
Avatar string `xorm:"VARCHAR(2048) NOT NULL"`
AvatarEmail string `xorm:"NOT NULL"`
UseCustomAvatar bool
// Counters.
NumFollowers int
NumFollowings int
NumStars int
NumRepos int
// For organization.
Description string
NumTeams int
NumMembers int
Teams []*Team `xorm:"-"`
Members []*User `xorm:"-"`
}
User represents the object of individual and member of organization.
func CreateOrganization ¶
CreateOrganization creates record of a new organization.
func GetOrgByName ¶
GetOrgByName returns organization by given name.
func GetOrganizations ¶
GetOrganizations returns given number of organizations with offset.
func GetTeamMembers ¶
GetTeamMembers returns all members in given team of organization.
func GetUserByEmail ¶
GetUserByEmail returns the user object by given e-mail if exists.
func GetUserById ¶
GetUserById returns the user object by given ID if exists.
func GetUserByKeyId ¶
func GetUserByName ¶
GetUserByName returns user by given name.
func LoginUserLdapSource ¶
func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, autoRegister bool) (*User, error)
Query if name/passwd can login against the LDAP directory pool Create a local user if success Return the same LoginUserPlain semantic FIXME: https://github.com/gogits/gogs/issues/672
func LoginUserSMTPSource ¶
func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTPConfig, autoRegister bool) (*User, error)
Query if name/passwd can login against the LDAP directory pool Create a local user if success Return the same LoginUserPlain semantic
func SearchUserByName ¶
func SearchUserByName(opt SearchOption) (us []*User, err error)
SearchUserByName returns given number of users whose name contains keyword.
func UserSignIn ¶
UserSignIn validates user name and password.
func ValidateCommitWithEmail ¶
ValidateCommitWithEmail chceck if author's e-mail of commit is corresponsind to a user.
func VerifyUserActiveCode ¶
verify active code when active account
func (*User) CustomAvatarPath ¶
CustomAvatarPath returns user custom avatar file path.
func (*User) DashboardLink ¶
DashboardLink returns the user dashboard page link.
func (*User) EncodePasswd ¶
func (u *User) EncodePasswd()
EncodePasswd encodes password to safe format.
func (*User) GetAccessibleRepositories ¶
func (u *User) GetAccessibleRepositories() (map[*Repository]AccessMode, error)
GetAccessibleRepositories finds all repositories where a user has access to, besides his own.
func (*User) GetFullNameFallback ¶
GetFullNameFallback returns Full Name if set, otherwise username
func (*User) GetMembers ¶
GetMembers returns all members of organization.
func (*User) GetOrganizationCount ¶
GetOrganizationCount returns count of membership of organization of user.
func (*User) GetOrganizations ¶
GetOrganizations returns all organizations that user belongs to.
func (*User) GetOwnerTeam ¶
GetOwnerTeam returns owner team of organization.
func (*User) GetRepositories ¶
GetRepositories returns all repositories that user owns, including private repositories.
func (*User) IsOrgMember ¶
IsOrgMember returns true if given user is member of organization.
func (*User) IsOrganization ¶
IsOrganization returns true if user is actually a organization.
func (*User) IsPublicMember ¶
IsPublicMember returns true if user public his/her membership in give organization.
func (*User) IsUserOrgOwner ¶
IsUserOrgOwner returns true if user is in the owner team of given organization.
func (*User) RemoveMember ¶
RemoveMember removes member from organization.
func (*User) RemoveOrgRepo ¶
RemoveOrgRepo removes all team-repository relations of organization.
func (*User) UploadAvatar ¶
UploadAvatar saves custom avatar for user. FIXME: split uploads to different subdirs in case we have massive users.
func (*User) ValidtePassword ¶
ValidtePassword checks if given password matches the one belongs to the user.
type UserCommit ¶
UserCommit represents a commit with validation of user.
type Watch ¶
type Watch struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"UNIQUE(watch)"`
RepoID int64 `xorm:"UNIQUE(watch)"`
}
Watch is connection request for receiving repository notification.
func GetWatchers ¶
GetWatchers returns all watchers of given repository.
type Webhook ¶
type Webhook struct {
Id int64
RepoId int64
Url string `xorm:"TEXT"`
ContentType HookContentType
Secret string `xorm:"TEXT"`
Events string `xorm:"TEXT"`
*HookEvent `xorm:"-"`
IsSsl bool
IsActive bool
HookTaskType HookTaskType
Meta string `xorm:"TEXT"` // store hook-specific attributes
OrgId int64
Created time.Time `xorm:"CREATED"`
Updated time.Time `xorm:"UPDATED"`
}
Webhook represents a web hook object.
func GetActiveWebhooksByOrgId ¶
GetActiveWebhooksByOrgId returns all active webhooks for an organization.
func GetActiveWebhooksByRepoId ¶
GetActiveWebhooksByRepoId returns all active webhooks of repository.
func GetWebhookById ¶
GetWebhookById returns webhook by given ID.
func GetWebhooksByOrgId ¶
GetWebhooksByOrgId returns all webhooks for an organization.
func GetWebhooksByRepoId ¶
GetWebhooksByRepoId returns all webhooks of repository.
func (*Webhook) GetEvent ¶
func (w *Webhook) GetEvent()
GetEvent handles conversion from Events to HookEvent.
func (*Webhook) GetSlackHook ¶
func (*Webhook) HasPushEvent ¶
HasPushEvent returns true if hook enabled push event.
func (*Webhook) UpdateEvent ¶
UpdateEvent handles conversion from HookEvent to Events.