models

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2014 License: BSD-3-Clause Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIFF_LINE_PLAIN = iota + 1
	DIFF_LINE_ADD
	DIFF_LINE_DEL
	DIFF_LINE_SECTION
)

Diff line types.

View Source
const (
	DIFF_FILE_ADD = iota + 1
	DIFF_FILE_CHANGE
	DIFF_FILE_DEL
)
View Source
const (
	IS_OPEN = iota + 1
	IS_CLOSE
)
View Source
const (
	FM_ASSIGN = iota + 1
	FM_CREATE
	FM_MENTION
)

Filter modes.

View Source
const DIFF_HEAD = "diff --git "
View Source
const OWNER_TEAM = "Owners"
View Source
const (
	SLACK_COLOR string = "#dd4b39"
)
View Source
const (
	TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3\n"
)

Variables

View Source
var (
	// Same as Github. See https://help.github.com/articles/closing-issues-via-commit-messages
	IssueKeywords    = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"}
	IssueKeywordsPat *regexp.Regexp
)
View Source
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")
)
View Source
var (
	ErrAuthenticationAlreadyExist = errors.New("Authentication already exist")
	ErrAuthenticationNotExist     = errors.New("Authentication does not exist")
	ErrAuthenticationUserUsed     = errors.New("Authentication has been used by some users")
)
View Source
var (
	SMTP_PLAIN = "PLAIN"
	SMTP_LOGIN = "LOGIN"
	SMTPAuths  = []string{SMTP_PLAIN, SMTP_LOGIN}
)
View Source
var (
	HasEngine bool

	DbCfg struct {
		Type, Host, Name, User, Pwd, Path, SslMode string
	}

	EnableSQLite3 bool
	UseSQLite3    bool
)
View Source
var (
	ErrOauth2RecordNotExist = errors.New("OAuth2 record does not exist")
	ErrOauth2NotAssociated  = errors.New("OAuth2 is not associated with user")
)
View Source
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")
	ErrLastOrgOwner     = errors.New("The user to remove is the last member in owner team")
)
View Source
var (
	ErrKeyAlreadyExist = errors.New("Public key already exist")
	ErrKeyNotExist     = errors.New("Public key does not exist")
)
View Source
var (
	ErrReleaseAlreadyExist = errors.New("Release already exist")
	ErrReleaseNotExist     = errors.New("Release does not exist")
)
View Source
var (
	ErrRepoAlreadyExist  = errors.New("Repository already exist")
	ErrRepoNotExist      = errors.New("Repository does not 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")
)
View Source
var (
	ErrUserOwnRepos          = errors.New("User still have ownership of repositories")
	ErrUserHasOrgs           = errors.New("User still have membership of organization")
	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")
	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")
)
View Source
var (
	DescriptionPattern = regexp.MustCompile(`https?://\S+`)
)
View Source
var (
	ErrNotImplemented = errors.New("Not implemented yet")
)
View Source
var (
	ErrWebhookNotExist = errors.New("Webhook does not exist")
)
View Source
var (
	Gitignores, Licenses []string
)
View Source
var LoginTypes = map[LoginType]string{
	LDAP: "LDAP",
	SMTP: "SMTP",
}
View Source
var (
	MinimumKeySize = map[string]int{
		"(ED25519)": 256,
		"(ECDSA)":   256,
		"(NTRU)":    1087,
		"(MCE)":     1702,
		"(McE)":     1702,
		"(RSA)":     2048,
	}
)
View Source
var (
	SshPath string // SSH directory.

)

Functions

func AddAccess

func AddAccess(access *Access) error

AddAccess adds new access record.

func AddOauth2 added in v0.3.0

func AddOauth2(oa *Oauth2) error

func AddOrgUser added in v0.5.0

func AddOrgUser(orgId, uid int64) error

AddOrgUser adds new user to given organization.

func AddPublicKey

func AddPublicKey(key *PublicKey) (err error)

AddPublicKey adds new public key to database and authorized_keys file.

func AddTeamMember added in v0.5.0

func AddTeamMember(orgId, teamId, uid int64) error

AddTeamMember adds new member to given team of given organization.

func AddUpdateTask added in v0.5.0

func AddUpdateTask(task *UpdateTask) error

func BindUserOauth2 added in v0.3.0

func BindUserOauth2(userId, oauthId int64) error

func ChangeMilestoneAssign added in v0.4.0

func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error)

ChangeMilestoneAssign changes assignment of milestone for issue.

func ChangeMilestoneIssueStats added in v0.5.0

func ChangeMilestoneIssueStats(issue *Issue) error

ChangeMilestoneIssueStats updates the open/closed issues counter and progress for the milestone associated witht the given issue.

func ChangeMilestoneStatus added in v0.4.0

func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error)

ChangeMilestoneStatus changes the milestone open/closed status.

func ChangeOrgUserStatus added in v0.5.0

func ChangeOrgUserStatus(orgId, uid int64, public bool) error

ChangeOrgUserStatus changes public or private membership status.

func ChangeRepositoryName added in v0.3.0

func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error)

ChangeRepositoryName changes all corresponding setting from old repository name to new one.

func ChangeUserName added in v0.3.0

func ChangeUserName(u *User, newUserName string) (err error)

ChangeUserName changes all corresponding setting from old user name to new one.

func CheckPublicKeyString added in v0.5.0

func CheckPublicKeyString(content string) (bool, error)

CheckPublicKeyString checks if the given public key string is recognized by SSH.

func CleanUnbindOauth added in v0.4.0

func CleanUnbindOauth() error

CleanUnbindOauth deletes all unbind OAuthes.

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 added in v0.5.0

func CountOrganizations() int64

CountOrganizations returns number of organizations.

func CountRepositories added in v0.5.0

func CountRepositories() int64

CountRepositories returns number of repositories.

func CountUsers added in v0.5.0

func CountUsers() int64

CountUsers returns number of users.

func CreateHookTask added in v0.5.0

func CreateHookTask(t *HookTask) error

CreateHookTask creates a new hook task, it handles conversion from Payload to PayloadContent.

func CreateRelease added in v0.3.0

func CreateRelease(gitRepo *git.Repository, rel *Release) error

CreateRelease creates a new release of repository.

func CreateSource added in v0.5.0

func CreateSource(source *LoginSource) error

func CreateUser added in v0.5.0

func CreateUser(u *User) error

CreateUser creates record of a new user.

func CreateWebhook added in v0.4.0

func CreateWebhook(w *Webhook) error

CreateWebhook creates a new web hook.

func DelLoginSource added in v0.4.0

func DelLoginSource(source *LoginSource) error

func DelUpdateTasksByUuid added in v0.5.0

func DelUpdateTasksByUuid(uuid string) error

func DeleteAccess added in v0.4.0

func DeleteAccess(access *Access) error

DeleteAccess deletes access record.

func DeleteAttachment added in v0.5.0

func DeleteAttachment(a *Attachment, remove bool) error

DeleteAttachment deletes the given attachment and optionally the associated file.

func DeleteAttachments added in v0.5.0

func DeleteAttachments(attachments []*Attachment, remove bool) (int, error)

DeleteAttachments deletes the given attachments and optionally the associated files.

func DeleteAttachmentsByComment added in v0.5.0

func DeleteAttachmentsByComment(commentId int64, remove bool) (int, error)

DeleteAttachmentsByComment deletes all attachments associated with the given comment.

func DeleteAttachmentsByIssue added in v0.5.0

func DeleteAttachmentsByIssue(issueId int64, remove bool) (int, error)

DeleteAttachmentsByIssue deletes all attachments associated with the given issue.

func DeleteInactivateUsers added in v0.5.0

func DeleteInactivateUsers() error

DeleteInactivateUsers deletes all inactivate users.

func DeleteLabel added in v0.4.0

func DeleteLabel(repoId int64, strId string) error

DeleteLabel delete a label of given repository.

func DeleteMilestone added in v0.4.0

func DeleteMilestone(m *Milestone) (err error)

DeleteMilestone deletes a milestone.

func DeleteOauth2ById added in v0.4.0

func DeleteOauth2ById(id int64) error

DeleteOauth2ById deletes a oauth2 by ID.

func DeleteOrganization added in v0.5.0

func DeleteOrganization(org *User) (err error)

TODO: need some kind of mechanism to record failure. DeleteOrganization completely and permanently deletes everything of organization.

func DeletePublicKey

func DeletePublicKey(key *PublicKey) error

DeletePublicKey deletes SSH key information both in database and authorized_keys file.

func DeleteRepository

func DeleteRepository(uid, repoId int64, userName string) error

DeleteRepository deletes a repository for a user or orgnaztion.

func DeleteTeam added in v0.5.0

func DeleteTeam(t *Team) error

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

func DeleteUser

func DeleteUser(u *User) error

TODO: need some kind of mechanism to record failure. DeleteUser completely and permanently deletes everything of user.

func DeleteWebhook added in v0.4.0

func DeleteWebhook(hookId int64) error

DeleteWebhook deletes webhook of repository.

func DeliverHooks added in v0.5.0

func DeliverHooks()

DeliverHooks checks and delivers undelivered hooks.

func DumpDatabase added in v0.4.0

func DumpDatabase(filePath string) error

DumpDatabase dumps all data from database to file system.

func FollowUser

func FollowUser(userId int64, followId int64) (err error)

FollowUser marks someone be another's follower.

func ForkRepository

func ForkRepository(repoName string, uid int64)

func GetCollaboratorNames added in v0.4.0

func GetCollaboratorNames(repoName string) ([]string, error)

GetCollaboratorNames returns a list of user name of repository's collaborators.

func GetIssueCountByPoster added in v0.4.0

func GetIssueCountByPoster(uid, rid int64, isClosed bool) int64

GetIssueCountByPoster returns number of issues of repository by poster.

func GetRepositoryCount

func GetRepositoryCount(user *User) (int64, error)

GetRepositoryCount returns the total number of repositories of user.

func GetSlackURL added in v0.5.0

func GetSlackURL(domain string, token string) string

func GetUserEmailsByNames added in v0.3.0

func GetUserEmailsByNames(names []string) []string

GetUserEmailsByNames returns a slice of e-mails corresponds to names.

func GetUserIdsByNames added in v0.4.0

func GetUserIdsByNames(names []string) []int64

GetUserIdsByNames returns a slice of ids corresponds to names.

func GetUserSalt

func GetUserSalt() string

GetUserSalt returns a user salt token

func HasAccess

func HasAccess(uname, repoName string, mode AccessType) (bool, error)

HasAccess returns true if someone can read or write to given repository. The repoName should be in format <username>/<reponame>.

func IsEmailUsed

func IsEmailUsed(email string) (bool, error)

IsEmailUsed returns true if the e-mail has been used.

func IsLegalName

func IsLegalName(repoName string) bool

IsLegalName returns false if name contains illegal characters.

func IsOrganizationMember added in v0.5.0

func IsOrganizationMember(orgId, uid int64) bool

IsOrganizationMember returns true if given user is member of organization.

func IsOrganizationOwner added in v0.5.0

func IsOrganizationOwner(orgId, uid int64) bool

IsOrganizationOwner returns true if given user is in the owner team.

func IsPublicMembership added in v0.5.0

func IsPublicMembership(orgId, uid int64) bool

IsPublicMembership returns ture if given user public his/her membership.

func IsReleaseExist added in v0.3.0

func IsReleaseExist(repoId int64, tagName string) (bool, error)

IsReleaseExist returns true if release with given tag name already exists.

func IsRepositoryExist

func IsRepositoryExist(u *User, repoName string) (bool, error)

IsRepositoryExist returns true if the repository with given name under user has already existed.

func IsStaring added in v0.5.0

func IsStaring(uid, repoId int64) bool

IsStaring checks if user has starred given repository.

func IsTeamMember added in v0.5.0

func IsTeamMember(orgId, teamId, uid int64) bool

IsTeamMember returns true if given user is a member of team.

func IsUserExist

func IsUserExist(name string) (bool, error)

IsUserExist checks if given user name exist, the user name should be noncased unique.

func IsWatching

func IsWatching(uid, rid int64) bool

IsWatching checks if user has watched given repository.

func LoadModelsConfig

func LoadModelsConfig()

func LoadRepoConfig

func LoadRepoConfig()

func LoginAuth added in v0.4.0

func LoginAuth(username, password string) smtp.Auth

func MirrorRepository added in v0.3.0

func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error

MirrorRepository creates a mirror repository from source.

func MirrorUpdate added in v0.3.0

func MirrorUpdate()

MirrorUpdate checks and updates mirror repositories.

func NewEngine

func NewEngine() (err error)

func NewIssue added in v0.4.0

func NewIssue(issue *Issue) (err error)

CreateIssue creates new issue for repository.

func NewIssueUserPairs added in v0.4.0

func NewIssueUserPairs(rid, iid, oid, pid, aid int64, repoName string) (err error)

NewIssueUserPairs adds new issue-user pairs for new issue of repository.

func NewLabel added in v0.4.0

func NewLabel(l *Label) error

NewLabel creates new label of repository.

func NewMilestone added in v0.4.0

func NewMilestone(m *Milestone) (err error)

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 added in v0.5.0

func NewTeam(t *Team) error

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

func NewTestEngine

func NewTestEngine(x *xorm.Engine) (err error)

func NotifyWatchers

func NotifyWatchers(act *Action) error

NotifyWatchers creates batch of actions for every watcher.

func PairsContains added in v0.4.0

func PairsContains(ius []*IssueUser, issueId int64) int

PairsContains returns true when pairs list contains given issue.

func Ping added in v0.5.0

func Ping() error

func RemoveOrgUser added in v0.5.0

func RemoveOrgUser(orgId, uid int64) error

RemoveOrgUser removes user from given organization.

func RemoveTeamMember added in v0.5.0

func RemoveTeamMember(orgId, teamId, uid int64) error

RemoveTeamMember removes member from given team of given organization.

func RepoPath

func RepoPath(userName, repoName string) string

RepoPath returns repository path by given user and repository name.

func SetEngine

func SetEngine() (err error)

func SlackLinkFormatter added in v0.5.0

func SlackLinkFormatter(url string, text string) string

func SlackTextFormatter added in v0.5.0

func SlackTextFormatter(s string) string

see: https://api.slack.com/docs/formatting

func SmtpAuth added in v0.4.0

func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error

func SortReleases added in v0.5.0

func SortReleases(rels []*Release)

SortReleases sorts releases by number of commits and created time.

func StarRepo added in v0.5.0

func StarRepo(uid, repoId int64, star bool) (err error)

Star or unstar repository.

func TransferOwnership added in v0.3.0

func TransferOwnership(u *User, newOwner string, repo *Repository) error

TransferOwnership transfers all corresponding setting from old user to new one.

func TransferRepoAction added in v0.3.0

func TransferRepoAction(u, newUser *User, repo *Repository) (err error)

TransferRepoAction adds new action for transfering repository.

func UnFollowUser

func UnFollowUser(userId int64, unFollowId int64) (err error)

UnFollowUser unmarks someone be another's follower.

func Update added in v0.3.0

func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) error

func UpdateAccess added in v0.3.0

func UpdateAccess(access *Access) error

UpdateAccess updates access information.

func UpdateAccessWithSession added in v0.3.0

func UpdateAccessWithSession(sess *xorm.Session, access *Access) error

UpdateAccess updates access information with session for rolling back.

func UpdateHookTask added in v0.5.0

func UpdateHookTask(t *HookTask) error

UpdateHookTask updates information of hook task.

func UpdateIssue

func UpdateIssue(issue *Issue) error

UpdateIssue updates information of issue.

func UpdateIssueUserPairByAssignee added in v0.4.0

func UpdateIssueUserPairByAssignee(aid, iid int64) error

UpdateIssueUserPairByAssignee updates issue-user pair for assigning.

func UpdateIssueUserPairByRead added in v0.4.0

func UpdateIssueUserPairByRead(uid, iid int64) error

UpdateIssueUserPairByRead updates issue-user pair for reading.

func UpdateIssueUserPairsByMentions added in v0.4.0

func UpdateIssueUserPairsByMentions(uids []int64, iid int64) error

UpdateIssueUserPairsByMentions updates issue-user pairs by mentioning.

func UpdateIssueUserPairsByStatus added in v0.4.0

func UpdateIssueUserPairsByStatus(iid int64, isClosed bool) error

UpdateIssueUserByStatus updates issue-user pairs by issue status.

func UpdateLabel added in v0.4.0

func UpdateLabel(l *Label) error

UpdateLabel updates label information.

func UpdateMentions added in v0.5.0

func UpdateMentions(userNames []string, issueId int64) error

func UpdateMilestone added in v0.4.0

func UpdateMilestone(m *Milestone) error

UpdateMilestone updates information of given milestone.

func UpdateMirror added in v0.3.0

func UpdateMirror(m *Mirror) error

func UpdateOauth2 added in v0.5.0

func UpdateOauth2(oa *Oauth2) error

UpdateOauth2 updates given OAuth2.

func UpdatePublicKey added in v0.5.0

func UpdatePublicKey(key *PublicKey) error

UpdatePublicKey updates given public key.

func UpdateRelease added in v0.5.0

func UpdateRelease(gitRepo *git.Repository, rel *Release) (err error)

UpdateRelease updates information of a release.

func UpdateRepository

func UpdateRepository(repo *Repository) error

func UpdateSource added in v0.4.0

func UpdateSource(source *LoginSource) error

func UpdateTeam added in v0.5.0

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

UpdateTeam updates information of team.

func UpdateUser

func UpdateUser(u *User) error

UpdateUser updates user's information.

func UpdateWebhook added in v0.4.0

func UpdateWebhook(w *Webhook) error

UpdateWebhook updates information of webhook.

func UserPath

func UserPath(userName string) string

UserPath returns the path absolute path of user repositories.

func WatchRepo

func WatchRepo(uid, repoId int64, watch bool) (err error)

Watch or unwatch repository.

Types

type Access

type Access struct {
	Id       int64
	UserName string     `xorm:"UNIQUE(s)"`
	RepoName string     `xorm:"UNIQUE(s)"` // <user name>/<repo name>
	Mode     AccessType `xorm:"UNIQUE(s)"`
	Created  time.Time  `xorm:"CREATED"`
}

Access represents the accessibility of user to repository.

type AccessType added in v0.5.0

type AccessType int
const (
	READABLE AccessType = iota + 1
	WRITABLE
)

func AuthorizeToAccessType added in v0.5.0

func AuthorizeToAccessType(auth AuthorizeType) AccessType

type Action

type Action struct {
	Id           int64
	UserId       int64 // Receiver user id.
	OpType       ActionType
	ActUserId    int64  // Action user id.
	ActUserName  string // Action user name.
	ActEmail     string
	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 GetFeeds

func GetFeeds(uid, offset int64, isProfile bool) ([]*Action, error)

GetFeeds returns action list of given user in given context.

func (Action) GetActEmail

func (a Action) GetActEmail() string

func (Action) GetActUserName

func (a Action) GetActUserName() string

func (Action) GetBranch

func (a Action) GetBranch() string

func (Action) GetContent

func (a Action) GetContent() string

func (Action) GetCreate added in v0.5.0

func (a Action) GetCreate() time.Time

func (Action) GetIssueInfos added in v0.5.0

func (a Action) GetIssueInfos() []string

func (Action) GetOpType

func (a Action) GetOpType() int
func (a Action) GetRepoLink() string

func (Action) GetRepoName

func (a Action) GetRepoName() string

func (Action) GetRepoUserName added in v0.4.0

func (a Action) GetRepoUserName() string

type ActionType added in v0.5.0

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 added in v0.5.0

type Attachment struct {
	Id        int64
	IssueId   int64
	CommentId int64
	Name      string
	Path      string    `xorm:"TEXT"`
	Created   time.Time `xorm:"CREATED"`
}

func CreateAttachment added in v0.5.0

func CreateAttachment(issueId, commentId int64, name, path string) (*Attachment, error)

CreateAttachment creates a new attachment inside the database and

func GetAttachmentById added in v0.5.0

func GetAttachmentById(id int64) (*Attachment, error)

Attachment returns the attachment by given ID.

func GetAttachmentsByComment added in v0.5.0

func GetAttachmentsByComment(commentId int64) ([]*Attachment, error)

GetAttachmentsByComment returns a list of attachments for the given comment

func GetAttachmentsByIssue added in v0.5.0

func GetAttachmentsByIssue(issueId int64) ([]*Attachment, error)

GetAttachmentsByIssue returns a list of attachments for the given issue

func GetAttachmentsForIssue added in v0.5.0

func GetAttachmentsForIssue(issueId int64) ([]*Attachment, error)

type AuthorizeType added in v0.5.0

type AuthorizeType int
const (
	ORG_READABLE AuthorizeType = iota + 1
	ORG_WRITABLE
	ORG_ADMIN
)

func GetHighestAuthorize added in v0.5.0

func GetHighestAuthorize(orgId, uid, repoId, teamId int64) (AuthorizeType, error)

GetHighestAuthorize returns highest repository authorize level for given user and team.

type BasePayload added in v0.5.0

type BasePayload interface {
	GetJSONPayload() ([]byte, error)
}

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 added in v0.5.0

func GetCommentById(commentId int64) (*Comment, error)

GetCommentById returns the comment with the given id

func GetIssueComments

func GetIssueComments(issueId int64) ([]Comment, error)

GetIssueComments returns list of comment by given issue id.

func (*Comment) AfterDelete added in v0.5.0

func (c *Comment) AfterDelete()

func (*Comment) Attachments added in v0.5.0

func (c *Comment) Attachments() []*Attachment

Attachments returns the attachments for this comment.

func (*Comment) ContentHtml added in v0.5.0

func (c *Comment) ContentHtml() template.HTML

type CommentType added in v0.5.0

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 CommentType = iota

	// Reopen action
	REOPEN

	// Close action
	CLOSE

	// Reference from another issue
	ISSUE

	// Reference from some commit (not part of a pull request)
	COMMIT

	// Reference from some pull request
	PULL
)

type Diff

type Diff struct {
	TotalAddition, TotalDeletion int
	Files                        []*DiffFile
}

func GetDiffCommit added in v0.5.0

func GetDiffCommit(repoPath, commitId string) (*Diff, error)

func GetDiffRange added in v0.5.0

func GetDiffRange(repoPath, beforeCommitId string, afterCommitId string) (*Diff, error)

func ParsePatch

func ParsePatch(pid int64, cmd *exec.Cmd, reader io.Reader) (*Diff, error)

func (*Diff) NumFiles

func (diff *Diff) NumFiles() int

type DiffFile

type DiffFile struct {
	Name               string
	Index              int
	Addition, Deletion int
	Type               int
	IsBin              bool
	Sections           []*DiffSection
}

type DiffLine

type DiffLine struct {
	LeftIdx  int
	RightIdx int
	Type     int
	Content  string
}

func (DiffLine) GetType

func (d DiffLine) GetType() int

type DiffSection

type DiffSection struct {
	Name  string
	Lines []*DiffLine
}

type Follow

type Follow struct {
	Id       int64
	UserId   int64 `xorm:"unique(follow)"`
	FollowId int64 `xorm:"unique(follow)"`
}

Follow is connection request for receiving user notifycation.

type HookContentType added in v0.5.0

type HookContentType int
const (
	JSON HookContentType = iota + 1
	FORM
)

type HookEvent added in v0.4.0

type HookEvent struct {
	PushOnly bool `json:"push_only"`
}

HookEvent represents events that will delivery hook.

type HookEventType added in v0.5.0

type HookEventType string
const (
	PUSH HookEventType = "push"
)

type HookTask added in v0.5.0

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 added in v0.5.0

type HookTaskType int
const (
	GOGS HookTaskType = iota + 1
	SLACK
)

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 added in v0.4.0

func GetIssueById(id int64) (*Issue, error)

GetIssueById returns an issue by ID.

func GetIssueByIndex

func GetIssueByIndex(rid, index int64) (*Issue, error)

GetIssueByIndex returns issue by given index in repository.

func GetIssueByRef added in v0.5.0

func GetIssueByRef(ref string) (issue *Issue, err error)

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 added in v0.4.0

func GetIssuesByLabel(repoId int64, label string) ([]*Issue, error)

GetIssuesByLabel returns a list of issues by given label and repository.

func (*Issue) AfterDelete added in v0.5.0

func (i *Issue) AfterDelete()

func (*Issue) Attachments added in v0.5.0

func (i *Issue) Attachments() []*Attachment

func (*Issue) GetAssignee added in v0.4.0

func (i *Issue) GetAssignee() (err error)

func (*Issue) GetLabels added in v0.4.0

func (i *Issue) GetLabels() error

func (*Issue) GetPoster added in v0.4.0

func (i *Issue) GetPoster() (err error)

type IssueStats added in v0.4.0

type IssueStats struct {
	OpenCount, ClosedCount int64
	AllCount               int64
	AssignCount            int64
	CreateCount            int64
	MentionCount           int64
}

IssueStats represents issue statistic information.

func GetIssueStats added in v0.4.0

func GetIssueStats(rid, uid int64, isShowClosed bool, filterMode int) *IssueStats

GetIssueStats returns issue statistic information by given conditions.

func GetUserIssueStats added in v0.4.0

func GetUserIssueStats(uid int64, filterMode int) *IssueStats

GetUserIssueStats returns issue statistic information for dashboard by given conditions.

type IssueStatus added in v0.4.0

type IssueStatus int

type IssueUser added in v0.4.0

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 added in v0.4.0

func GetIssueUserPairs(rid, uid int64, isClosed bool) ([]*IssueUser, error)

GetIssueUserPairs returns issue-user pairs by given repository and user.

func GetIssueUserPairsByMode added in v0.4.0

func GetIssueUserPairsByMode(uid, rid int64, isClosed bool, page, filterMode int) ([]*IssueUser, error)

GetIssueUserPairsByMode returns issue-user pairs by given repository and user.

func GetIssueUserPairsByRepoIds added in v0.4.0

func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*IssueUser, error)

GetIssueUserPairsByRepoIds returns issue-user pairs by given repository IDs.

type LDAPConfig added in v0.4.0

type LDAPConfig struct {
	ldap.Ldapsource
}

func (*LDAPConfig) FromDB added in v0.4.0

func (cfg *LDAPConfig) FromDB(bs []byte) error

func (*LDAPConfig) ToDB added in v0.4.0

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 added in v0.4.0

func GetLabelById(id int64) (*Label, error)

GetLabelById returns a label by given ID.

func GetLabels added in v0.4.0

func GetLabels(repoId int64) ([]*Label, error)

GetLabels returns a list of labels of given repository ID.

func (*Label) CalOpenIssues added in v0.4.0

func (m *Label) CalOpenIssues()

CalOpenIssues calculates the open issues of label.

type LoginSource added in v0.4.0

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 added in v0.4.0

func GetAuths() ([]*LoginSource, error)

func GetLoginSourceById added in v0.4.0

func GetLoginSourceById(id int64) (*LoginSource, error)

func (*LoginSource) BeforeSet added in v0.4.0

func (source *LoginSource) BeforeSet(colName string, val xorm.Cell)

func (*LoginSource) LDAP added in v0.4.0

func (source *LoginSource) LDAP() *LDAPConfig

func (*LoginSource) SMTP added in v0.4.0

func (source *LoginSource) SMTP() *SMTPConfig

func (*LoginSource) TypeString added in v0.4.0

func (source *LoginSource) TypeString() string

type LoginType added in v0.5.0

type LoginType int
const (
	NOTYPE LoginType = iota
	PLAIN
	LDAP
	SMTP
)

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 added in v0.4.0

func GetMilestoneById(id int64) (*Milestone, error)

GetMilestoneById returns the milestone by given ID.

func GetMilestoneByIndex added in v0.4.0

func GetMilestoneByIndex(repoId, idx int64) (*Milestone, error)

GetMilestoneByIndex returns the milestone of given repository and index.

func GetMilestones added in v0.4.0

func GetMilestones(repoId int64, isClosed bool) ([]*Milestone, error)

GetMilestones returns a list of milestones of given repository and status.

func (*Milestone) CalOpenIssues added in v0.4.0

func (m *Milestone) CalOpenIssues()

CalOpenIssues calculates the open issues of milestone.

type Mirror added in v0.3.0

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.

func GetMirror added in v0.3.0

func GetMirror(repoId int64) (*Mirror, error)

type Oauth2 added in v0.3.0

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 GetOauth2 added in v0.3.0

func GetOauth2(identity string) (oa *Oauth2, err error)

func GetOauth2ById added in v0.3.0

func GetOauth2ById(id int64) (oa *Oauth2, err error)

func GetOauthByUserId added in v0.3.0

func GetOauthByUserId(uid int64) ([]*Oauth2, error)

GetOauthByUserId returns list of oauthes that are releated to given user.

type OauthType added in v0.5.0

type OauthType int
const (
	GITHUB OauthType = iota + 1
	GOOGLE
	TWITTER
	QQ
	WEIBO
	BITBUCKET
	FACEBOOK
)

type OrgUser added in v0.5.0

type OrgUser struct {
	Id       int64
	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 added in v0.5.0

func GetOrgUsersByOrgId(orgId int64) ([]*OrgUser, error)

GetOrgUsersByOrgId returns all organization-user relations by organization ID.

func GetOrgUsersByUserId added in v0.5.0

func GetOrgUsersByUserId(uid int64) ([]*OrgUser, error)

GetOrgUsersByUserId returns all organization-user relations by user ID.

type Payload added in v0.5.0

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 added in v0.5.0

func (p Payload) GetJSONPayload() ([]byte, error)

type PayloadAuthor added in v0.5.0

type PayloadAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type PayloadCommit added in v0.5.0

type PayloadCommit struct {
	Id      string         `json:"id"`
	Message string         `json:"message"`
	Url     string         `json:"url"`
	Author  *PayloadAuthor `json:"author"`
}

type PayloadRepo added in v0.5.0

type PayloadRepo struct {
	Id          int64          `json:"id"`
	Name        string         `json:"name"`
	Url         string         `json:"url"`
	Description string         `json:"description"`
	Website     string         `json:"website"`
	Watchers    int            `json:"watchers"`
	Owner       *PayloadAuthor `json:"author"`
	Private     bool           `json:"private"`
}

type PublicKey

type PublicKey struct {
	Id                int64
	OwnerId           int64  `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name              string `xorm:"UNIQUE(s) NOT NULL"`
	Fingerprint       string
	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 added in v0.5.0

func GetPublicKeyById(keyId int64) (*PublicKey, error)

GetPublicKeyById returns public key by given ID.

func ListPublicKey

func ListPublicKey(uid int64) ([]*PublicKey, error)

ListPublicKey returns a list of all public keys that user has.

func (*PublicKey) GetAuthorizedString added in v0.4.0

func (key *PublicKey) GetAuthorizedString() string

GetAuthorizedString generates and returns formatted public key string for authorized_keys file.

type Release added in v0.3.0

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 added in v0.5.0

func GetRelease(repoId int64, tagName string) (*Release, error)

GetRelease returns release by given ID.

func GetReleasesByRepoId added in v0.3.0

func GetReleasesByRepoId(repoId int64) (rels []*Release, err error)

GetReleasesByRepoId returns a list of releases of repository.

type ReleaseSorter added in v0.5.0

type ReleaseSorter struct {
	// contains filtered or unexported fields
}

func (*ReleaseSorter) Len added in v0.5.0

func (rs *ReleaseSorter) Len() int

func (*ReleaseSorter) Less added in v0.5.0

func (rs *ReleaseSorter) Less(i, j int) bool

func (*ReleaseSorter) Swap added in v0.5.0

func (rs *ReleaseSorter) Swap(i, j int)

type Repository

type Repository struct {
	Id                  int64
	OwnerId             int64 `xorm:"UNIQUE(s)"`
	Owner               *User `xorm:"-"`
	ForkId              int64
	LowerName           string `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name                string `xorm:"INDEX NOT NULL"`
	Description         string
	Website             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
	IsMirror            bool
	*Mirror             `xorm:"-"`
	IsFork              bool `xorm:"NOT NULL DEFAULT false"`
	IsBare              bool
	IsGoget             bool
	DefaultBranch       string
	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, private, mirror, initReadme bool) (*Repository, error)

CreateRepository creates a repository for given user or organization.

func GetCollaborativeRepos added in v0.4.0

func GetCollaborativeRepos(uname string) ([]*Repository, error)

GetCollaborativeRepos returns a list of repositories that user is collaborator.

func GetRecentUpdatedRepositories added in v0.3.0

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 added in v0.4.0

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 added in v0.5.0

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 added in v0.3.0

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 added in v0.5.0

func SearchRepositoryByName(opt SearchOption) (repos []*Repository, err error)

SearchRepositoryByName returns given number of repositories whose name contains keyword.

func (*Repository) DescriptionHtml added in v0.5.0

func (repo *Repository) DescriptionHtml() template.HTML

DescriptionHtml does special handles to description and return HTML string.

func (*Repository) GetMirror added in v0.5.0

func (repo *Repository) GetMirror() (err error)

func (*Repository) GetOwner added in v0.4.0

func (repo *Repository) GetOwner() (err error)

type SMTPConfig added in v0.4.0

type SMTPConfig struct {
	Auth string
	Host string
	Port int
	TLS  bool
}

func (*SMTPConfig) FromDB added in v0.4.0

func (cfg *SMTPConfig) FromDB(bs []byte) error

func (*SMTPConfig) ToDB added in v0.4.0

func (cfg *SMTPConfig) ToDB() ([]byte, error)

type SearchOption added in v0.5.0

type SearchOption struct {
	Keyword string
	Uid     int64
	Limit   int
}

type Slack added in v0.5.0

type Slack struct {
	Domain  string `json:"domain"`
	Token   string `json:"token"`
	Channel string `json:"channel"`
}

type SlackAttachment added in v0.5.0

type SlackAttachment struct {
	Color string `json:"color"`
	Text  string `json:"text"`
}

type SlackPayload added in v0.5.0

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 added in v0.5.0

func GetSlackPayload(p *Payload, meta string) (*SlackPayload, error)

func (SlackPayload) GetJSONPayload added in v0.5.0

func (p SlackPayload) GetJSONPayload() ([]byte, error)

type Star added in v0.5.0

type Star struct {
	Id     int64
	Uid    int64 `xorm:"UNIQUE(s)"`
	RepoId int64 `xorm:"UNIQUE(s)"`
}

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 added in v0.5.0

type Team struct {
	Id          int64
	OrgId       int64 `xorm:"INDEX"`
	LowerName   string
	Name        string
	Description string
	Authorize   AuthorizeType
	RepoIds     string        `xorm:"TEXT"`
	Repos       []*Repository `xorm:"-"`
	Members     []*User       `xorm:"-"`
	NumRepos    int
	NumMembers  int
}

Team represents a organization team.

func GetTeam added in v0.5.0

func GetTeam(orgId int64, name string) (*Team, error)

GetTeam returns team by given team name and organization.

func GetTeamById added in v0.5.0

func GetTeamById(teamId int64) (*Team, error)

GetTeamById returns team by given ID.

func GetUserTeams added in v0.5.0

func GetUserTeams(orgId, uid int64) ([]*Team, error)

GetUserTeams returns all teams that user belongs to in given origanization.

func (*Team) AddMember added in v0.5.0

func (t *Team) AddMember(uid int64) error

AddMember adds new member to team of organization.

func (*Team) AddRepository added in v0.5.0

func (t *Team) AddRepository(repo *Repository) (err error)

AddRepository adds new repository to team of organization.

func (*Team) GetMembers added in v0.5.0

func (t *Team) GetMembers() (err error)

GetMembers returns all members in team of organization.

func (*Team) GetRepositories added in v0.5.0

func (t *Team) GetRepositories() error

GetRepositories returns all repositories in team of organization.

func (*Team) IsMember added in v0.5.0

func (t *Team) IsMember(uid int64) bool

IsTeamMember returns true if given user is a member of team.

func (*Team) IsOwnerTeam added in v0.5.0

func (t *Team) IsOwnerTeam() bool

IsOwnerTeam returns true if team is owner team.

func (*Team) RemoveMember added in v0.5.0

func (t *Team) RemoveMember(uid int64) error

RemoveMember removes member from team of organization.

func (*Team) RemoveRepository added in v0.5.0

func (t *Team) RemoveRepository(repoId int64) error

RemoveRepository removes repository from team of organization.

type TeamUser added in v0.5.0

type TeamUser struct {
	Id     int64
	Uid    int64
	OrgId  int64 `xorm:"INDEX"`
	TeamId int64
}

TeamUser represents an team-user relation.

type UpdateTask added in v0.5.0

type UpdateTask struct {
	Id          int64
	Uuid        string `xorm:"index"`
	RefName     string
	OldCommitId string
	NewCommitId string
}

func GetUpdateTasksByUuid added in v0.5.0

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         string `xorm:"UNIQUE NOT NULL"`
	Passwd        string `xorm:"NOT NULL"`
	LoginType     LoginType
	LoginSource   int64 `xorm:"NOT NULL DEFAULT 0"`
	LoginName     string
	Type          UserType
	Orgs          []*User       `xorm:"-"`
	Repos         []*Repository `xorm:"-"`
	NumFollowers  int
	NumFollowings int
	NumStars      int
	NumRepos      int
	Avatar        string `xorm:"VARCHAR(2048) NOT NULL"`
	AvatarEmail   string `xorm:"NOT NULL"`
	Location      string
	Website       string
	IsActive      bool
	IsAdmin       bool
	Rands         string    `xorm:"VARCHAR(10)"`
	Salt          string    `xorm:"VARCHAR(10)"`
	Created       time.Time `xorm:"CREATED"`
	Updated       time.Time `xorm:"UPDATED"`

	// 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 added in v0.5.0

func CreateOrganization(org, owner *User) (*User, error)

CreateOrganization creates record of a new organization.

func GetCollaborators added in v0.4.0

func GetCollaborators(repoName string) (us []*User, err error)

GetCollaborators returns a list of users of repository's collaborators.

func GetOrganizations added in v0.5.0

func GetOrganizations(num, offset int) ([]*User, error)

GetOrganizations returns given number of organizations with offset.

func GetTeamMembers added in v0.5.0

func GetTeamMembers(orgId, teamId int64) ([]*User, error)

GetTeamMembers returns all members in given team of organization.

func GetUserByEmail added in v0.3.0

func GetUserByEmail(email string) (*User, error)

GetUserByEmail returns the user object by given e-mail if exists.

func GetUserById

func GetUserById(id int64) (*User, error)

GetUserById returns the user object by given ID if exists.

func GetUserByKeyId

func GetUserByKeyId(keyId int64) (*User, error)

func GetUserByName

func GetUserByName(name string) (*User, error)

GetUserByName returns the user object by given name if exists.

func GetUsers

func GetUsers(num, offset int) ([]*User, error)

GetUsers returns given number of user objects with offset.

func LoginUserLdapSource added in v0.4.0

func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, autoRegister bool) (*User, error)

Query if name/passwd can login against the LDAP direcotry pool Create a local user if success Return the same LoginUserPlain semantic

func LoginUserSMTPSource added in v0.4.0

func LoginUserSMTPSource(u *User, name, passwd string, sourceId int64, cfg *SMTPConfig, autoRegister bool) (*User, error)

Query if name/passwd can login against the LDAP direcotry pool Create a local user if success Return the same LoginUserPlain semantic

func SearchUserByName added in v0.4.0

func SearchUserByName(opt SearchOption) (us []*User, err error)

SearchUserByName returns given number of users whose name contains keyword.

func UserSignIn added in v0.4.2

func UserSignIn(uname, passwd string) (*User, error)

UserSignIn validates user name and password.

func VerifyUserActiveCode

func VerifyUserActiveCode(code string) (user *User)

verify active code when active account

func (*User) AddMember added in v0.5.0

func (org *User) AddMember(uid int64) error

AddMember adds new member to organization.

func (u *User) AvatarLink() string

AvatarLink returns user gravatar link.

func (u *User) DashboardLink() string

DashboardLink returns the user dashboard page link.

func (*User) EncodePasswd

func (u *User) EncodePasswd()

EncodePasswd encodes password to safe format.

func (*User) GetMembers added in v0.5.0

func (org *User) GetMembers() error

GetMembers returns all members of organization.

func (*User) GetOrganizationCount added in v0.5.0

func (u *User) GetOrganizationCount() (int64, error)

GetOrganizationCount returns count of membership of organization of user.

func (*User) GetOrganizations added in v0.5.0

func (u *User) GetOrganizations() error

GetOrganizations returns all organizations that user belongs to.

func (*User) GetOwnerTeam added in v0.5.0

func (org *User) GetOwnerTeam() (*Team, error)

GetOwnerTeam returns owner team of organization.

func (*User) GetRepositories added in v0.5.0

func (u *User) GetRepositories() (err error)

GetRepositories returns all repositories that user owns, including private repositories.

func (*User) GetTeam added in v0.5.0

func (org *User) GetTeam(name string) (*Team, error)

GetTeam returns named team of organization.

func (*User) GetTeams added in v0.5.0

func (org *User) GetTeams() error

GetTeams returns all teams that belong to organization.

func (u *User) HomeLink() string

HomeLink returns the user home page link.

func (*User) IsOrgMember added in v0.5.0

func (org *User) IsOrgMember(uid int64) bool

IsOrgMember returns true if given user is member of organization.

func (*User) IsOrgOwner added in v0.5.0

func (org *User) IsOrgOwner(uid int64) bool

IsOrgOwner returns true if given user is in the owner team.

func (*User) IsOrganization added in v0.5.0

func (u *User) IsOrganization() bool

IsOrganization returns true if user is actually a organization.

func (*User) IsPublicMember added in v0.5.0

func (u *User) IsPublicMember(orgId int64) bool

IsPublicMember returns true if user public his/her membership in give organization.

func (*User) IsUserOrgOwner added in v0.5.0

func (u *User) IsUserOrgOwner(orgId int64) bool

IsUserOrgOwner returns true if user is in the owner team of given organization.

func (*User) NewGitSig

func (u *User) NewGitSig() *git.Signature

NewGitSig generates and returns the signature of given user.

func (*User) RemoveMember added in v0.5.0

func (org *User) RemoveMember(uid int64) error

RemoveMember removes member from organization.

func (*User) ValidtePassword added in v0.5.0

func (u *User) ValidtePassword(passwd string) bool

ValidtePassword checks if given password matches the one belongs to the user.

type UserType added in v0.5.0

type UserType int
const (
	INDIVIDUAL UserType = iota // Historic reason to make it starts at 0.
	ORGANIZATION
)

type Watch

type Watch struct {
	Id     int64
	UserId int64 `xorm:"UNIQUE(watch)"`
	RepoId int64 `xorm:"UNIQUE(watch)"`
}

Watch is connection request for receiving repository notifycation.

func GetWatchers added in v0.4.0

func GetWatchers(rid int64) ([]*Watch, error)

GetWatchers returns all watchers of given repository.

type Webhook added in v0.4.0

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
}

Webhook represents a web hook object.

func GetActiveWebhooksByOrgId added in v0.5.0

func GetActiveWebhooksByOrgId(orgId int64) (ws []*Webhook, err error)

GetActiveWebhooksByOrgId returns all active webhooks for an organization.

func GetActiveWebhooksByRepoId added in v0.4.0

func GetActiveWebhooksByRepoId(repoId int64) (ws []*Webhook, err error)

GetActiveWebhooksByRepoId returns all active webhooks of repository.

func GetWebhookById added in v0.4.0

func GetWebhookById(hookId int64) (*Webhook, error)

GetWebhookById returns webhook by given ID.

func GetWebhooksByOrgId added in v0.5.0

func GetWebhooksByOrgId(orgId int64) (ws []*Webhook, err error)

GetWebhooksByOrgId returns all webhooks for an organization.

func GetWebhooksByRepoId added in v0.4.0

func GetWebhooksByRepoId(repoId int64) (ws []*Webhook, err error)

GetWebhooksByRepoId returns all webhooks of repository.

func (*Webhook) GetEvent added in v0.4.0

func (w *Webhook) GetEvent()

GetEvent handles conversion from Events to HookEvent.

func (*Webhook) GetSlackHook added in v0.5.0

func (w *Webhook) GetSlackHook() *Slack

func (*Webhook) HasPushEvent added in v0.4.0

func (w *Webhook) HasPushEvent() bool

HasPushEvent returns true if hook enbaled push event.

func (*Webhook) UpdateEvent added in v0.5.0

func (w *Webhook) UpdateEvent() error

UpdateEvent handles conversion from HookEvent to Events.

Jump to

Keyboard shortcuts

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