Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func AddAccess(access *Access) error
 - func AddOauth2(oa *Oauth2) error
 - func AddPublicKey(key *PublicKey) (err error)
 - func AddSource(source *LoginSource) error
 - func BindUserOauth2(userId, oauthId int64) error
 - func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error)
 - func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error)
 - func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error)
 - func ChangeUserName(user *User, newUserName string) (err error)
 - func CleanUnbindOauth() error
 - func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, repoId int64, ...) error
 - func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType int, content string) error
 - func CreateRelease(gitRepo *git.Repository, rel *Release) error
 - func CreateWebhook(w *Webhook) error
 - func DelLoginSource(source *LoginSource) error
 - func DeleteAccess(access *Access) error
 - func DeleteLabel(repoId int64, strId string) error
 - func DeleteMilestone(m *Milestone) (err error)
 - func DeleteOauth2ById(id int64) error
 - func DeletePublicKey(key *PublicKey) error
 - func DeleteRepository(userId, repoId int64, userName string) (err error)
 - func DeleteUser(user *User) error
 - func DeleteWebhook(hookId int64) error
 - func DumpDatabase(filePath string) error
 - func Fix() error
 - func FollowUser(userId int64, followId int64) (err error)
 - func ForkRepository(repoName string, uid int64)
 - func GetCollaboratorNames(repoName string) ([]string, 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 HasAccess(uname, repoName string, mode int) (bool, error)
 - func IsEmailUsed(email string) (bool, error)
 - func IsLegalName(repoName string) bool
 - func IsReleaseExist(repoId int64, tagName string) (bool, error)
 - func IsRepositoryExist(u *User, repoName string) (bool, error)
 - func IsUserExist(name string) (bool, error)
 - func IsWatching(uid, rid int64) bool
 - func LoadModelsConfig()
 - func LoadRepoConfig()
 - func LoginAuth(username, password string) smtp.Auth
 - func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error
 - func MirrorUpdate()
 - func NewEngine() (err error)
 - func NewIssue(issue *Issue) (err error)
 - func NewIssueUserPairs(rid, iid, oid, pid, aid int64, repoName string) (err error)
 - func NewLabel(l *Label) error
 - func NewMilestone(m *Milestone) (err error)
 - func NewRepoAction(user *User, repo *Repository) (err error)
 - func NewRepoContext()
 - func NewTestEngine(x *xorm.Engine) (err error)
 - func NotifyWatchers(act *Action) error
 - func PairsContains(ius []*IssueUser, issueId int64) int
 - func RepoPath(userName, repoName string) string
 - func SetEngine() (err error)
 - func SetRepoEnvs(userId int64, userName, repoName, repoUserName string)
 - func SmtpAuth(host string, port int, a smtp.Auth, useTls bool) error
 - func TransferOwnership(user *User, newOwner string, repo *Repository) (err error)
 - func TransferRepoAction(user, newUser *User, repo *Repository) (err error)
 - func UnFollowUser(userId int64, unFollowId int64) (err error)
 - func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, ...)
 - func UpdateAccess(access *Access) error
 - func UpdateAccessWithSession(sess *xorm.Session, access *Access) 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 UpdateMilestone(m *Milestone) error
 - func UpdateMirror(m *Mirror) error
 - func UpdateRepository(repo *Repository) error
 - func UpdateSource(source *LoginSource) error
 - func UpdateUser(u *User) (err error)
 - func UpdateWebhook(w *Webhook) error
 - func UserPath(userName string) string
 - func WatchRepo(uid, rid int64, watch bool) (err error)
 - type Access
 - type Action
 - type Comment
 - type Diff
 - type DiffFile
 - type DiffLine
 - type DiffSection
 - type Follow
 - type HookEvent
 - type Issue
 - type IssueStats
 - type IssueStatus
 - type IssueUser
 - type LDAPConfig
 - type Label
 - type LoginSource
 - type Member
 - type Milestone
 - type Mirror
 - type Oauth2
 - type PublicKey
 - type Release
 - type Repository
 - func CreateRepository(user *User, name, desc, lang, license string, private, mirror, initReadme bool) (*Repository, error)
 - func GetCollaborativeRepos(uname string) ([]*Repository, error)
 - func GetRecentUpdatedRepositories() (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(userId int64, repoName string) (*Repository, error)
 - func MigrateRepository(user *User, name, desc string, private, mirror bool, url string) (*Repository, error)
 
- type SMTPConfig
 - type Statistic
 - type User
 - func GetCollaborators(repoName string) (us []*User, err 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(user *User, name, passwd string, sourceId int64, cfg *LDAPConfig, ...) (*User, error)
 - func LoginUserSMTPSource(user *User, name, passwd string, sourceId int64, cfg *SMTPConfig, ...) (*User, error)
 - func RegisterUser(user *User) (*User, error)
 - func SearchUserByName(key string, limit int) (us []*User, err error)
 - func UserSignIn(uname, passwd string) (*User, error)
 - func VerifyUserActiveCode(code string) (user *User)
 
- type Watch
 - type Webhook
 
Constants ¶
const ( AU_READABLE = iota + 1 AU_WRITABLE )
Access types.
const ( OP_CREATE_REPO = iota + 1 OP_DELETE_REPO OP_STAR_REPO OP_FOLLOW_REPO OP_COMMIT_REPO OP_CREATE_ISSUE OP_PULL_REQUEST OP_TRANSFER_REPO OP_PUSH_TAG OP_COMMENT_ISSUE )
Operation types of user action.
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 ( IT_PLAIN = iota // Pure comment. IT_REOPEN // Issue reopen status change prompt. IT_CLOSE // Issue close status change prompt. )
Issue types.
const ( LT_NOTYPE = iota LT_PLAIN LT_LDAP LT_SMTP )
Login types.
const ( OT_GITHUB = iota + 1 OT_GOOGLE OT_TWITTER OT_QQ OT_WEIBO OT_BITBUCKET OT_OSCHINA OT_FACEBOOK )
OT: Oauth2 Type
const ( UT_INDIVIDUAL = iota + 1 UT_ORGANIZATION )
User types.
const ( CT_JSON = iota + 1 CT_FORM )
Content types.
const DIFF_HEAD = "diff --git "
    Variables ¶
var ( ErrIssueNotExist = errors.New("Issue does not exist") ErrLabelNotExist = errors.New("Label does not exist") ErrMilestoneNotExist = errors.New("Milestone does not exist") )
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, Pwd, Path, SslMode string } EnableSQLite3 bool UseSQLite3 bool )
var ( ErrOauth2RecordNotExist = errors.New("OAuth2 record does not exist") ErrOauth2NotAssociated = errors.New("OAuth2 is not associated with user") )
var ( ErrKeyAlreadyExist = errors.New("Public key already exist") ErrKeyNotExist = errors.New("Public key does not exist") )
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") )
var ( ErrUserOwnRepos = errors.New("User still have ownership of repositories") 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") )
var (
	ErrReleaseAlreadyExist = errors.New("Release already exist")
)
    var (
	ErrWebhookNotExist = errors.New("Webhook does not exist")
)
    var (
	LanguageIgns, Licenses []string
)
    var LoginTypes = map[int]string{ LT_LDAP: "LDAP", LT_SMTP: "SMTP", }
Functions ¶
func AddPublicKey ¶
AddPublicKey adds new public key to database and authorized_keys file.
func AddSource ¶ added in v0.4.0
func AddSource(source *LoginSource) error
func BindUserOauth2 ¶ added in v0.3.0
func ChangeMilestoneAssign ¶ added in v0.4.0
ChangeMilestoneAssign changes assignment of milestone for issue.
func ChangeMilestoneStatus ¶ added in v0.4.0
ChangeMilestoneStatus changes the milestone open/closed status.
func ChangeRepositoryName ¶ added in v0.3.0
ChangeRepositoryName changes all corresponding setting from old repository name to new one.
func ChangeUserName ¶ added in v0.3.0
ChangeUserName changes all corresponding setting from old user name to new one.
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) error
CommitRepoAction adds new action for committing repository.
func CreateComment ¶
func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType int, content string) error
CreateComment creates comment of issue or commit.
func CreateRelease ¶ added in v0.3.0
func CreateRelease(gitRepo *git.Repository, rel *Release) error
CreateRelease creates a new release of repository.
func CreateWebhook ¶ added in v0.4.0
CreateWebhook creates new webhook.
func DelLoginSource ¶ added in v0.4.0
func DelLoginSource(source *LoginSource) error
func DeleteAccess ¶ added in v0.4.0
DeleteAccess deletes access record.
func DeleteLabel ¶ added in v0.4.0
DeleteLabel delete a label of given repository.
func DeleteMilestone ¶ added in v0.4.0
DeleteMilestone deletes a milestone.
func DeleteOauth2ById ¶ added in v0.4.0
DeleteOauth2ById deletes a oauth2 by ID.
func DeletePublicKey ¶
DeletePublicKey deletes SSH key information both in database and authorized_keys file.
func DeleteRepository ¶
DeleteRepository deletes a repository for a user or orgnaztion.
func DeleteUser ¶
DeleteUser completely deletes everything of the user.
func DeleteWebhook ¶ added in v0.4.0
DeleteWebhook deletes webhook of repository.
func DumpDatabase ¶ added in v0.4.0
DumpDatabase dumps all data from database to file system.
func FollowUser ¶
FollowUser marks someone be another's follower.
func ForkRepository ¶
func GetCollaboratorNames ¶ added in v0.4.0
GetCollaboratorNames returns a list of user name of repository's collaborators.
func GetIssueCountByPoster ¶ added in v0.4.0
GetIssueCountByPoster returns number of issues of repository by poster.
func GetRepositoryCount ¶
GetRepositoryCount returns the total number of repositories of user.
func GetUserEmailsByNames ¶ added in v0.3.0
GetUserEmailsByNames returns a slice of e-mails corresponds to names.
func GetUserIdsByNames ¶ added in v0.4.0
GetUserIdsByNames returns a slice of ids corresponds to names.
func HasAccess ¶
HasAccess returns true if someone can read or write to given repository. The repoName should be in format <username>/<reponame>.
func IsEmailUsed ¶
IsEmailUsed returns true if the e-mail has been used.
func IsLegalName ¶
IsLegalName returns false if name contains illegal characters.
func IsReleaseExist ¶ added in v0.3.0
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 IsUserExist ¶
IsUserExist checks if given user name exist, the user name should be noncased unique.
func IsWatching ¶
IsWatching checks if user has watched given repository.
func LoadModelsConfig ¶
func LoadModelsConfig()
func LoadRepoConfig ¶
func LoadRepoConfig()
func MirrorRepository ¶ added in v0.3.0
MirrorRepository creates a mirror repository from source.
func MirrorUpdate ¶ added in v0.3.0
func MirrorUpdate()
MirrorUpdate checks and updates mirror repositories.
func NewIssueUserPairs ¶ added in v0.4.0
NewIssueUserPairs adds new issue-user pairs for new issue of repository.
func NewMilestone ¶ added in v0.4.0
NewMilestone creates new milestone of repository.
func NewRepoAction ¶
func NewRepoAction(user *User, repo *Repository) (err error)
NewRepoAction adds new action for creating repository.
func NewRepoContext ¶
func NewRepoContext()
func NewTestEngine ¶
func NotifyWatchers ¶
NotifyWatchers creates batch of actions for every watcher.
func PairsContains ¶ added in v0.4.0
PairsContains returns true when pairs list contains given issue.
func SetRepoEnvs ¶ added in v0.3.0
SetRepoEnvs sets environment variables for command update.
func TransferOwnership ¶ added in v0.3.0
func TransferOwnership(user *User, newOwner string, repo *Repository) (err error)
TransferOwnership transfers all corresponding setting from old user to new one.
func TransferRepoAction ¶ added in v0.3.0
func TransferRepoAction(user, newUser *User, repo *Repository) (err error)
TransferRepoAction adds new action for transfering repository.
func UnFollowUser ¶
UnFollowUser unmarks someone be another's follower.
func UpdateAccess ¶ added in v0.3.0
UpdateAccess updates access information.
func UpdateAccessWithSession ¶ added in v0.3.0
UpdateAccess updates access information with session for rolling back.
func UpdateIssueUserPairByAssignee ¶ added in v0.4.0
UpdateIssueUserPairByAssignee updates issue-user pair for assigning.
func UpdateIssueUserPairByRead ¶ added in v0.4.0
UpdateIssueUserPairByRead updates issue-user pair for reading.
func UpdateIssueUserPairsByMentions ¶ added in v0.4.0
UpdateIssueUserPairsByMentions updates issue-user pairs by mentioning.
func UpdateIssueUserPairsByStatus ¶ added in v0.4.0
UpdateIssueUserByStatus updates issue-user pairs by issue status.
func UpdateLabel ¶ added in v0.4.0
UpdateLabel updates label information.
func UpdateMilestone ¶ added in v0.4.0
UpdateMilestone updates information of given milestone.
func UpdateMirror ¶ added in v0.3.0
func UpdateRepository ¶
func UpdateRepository(repo *Repository) error
func UpdateSource ¶ added in v0.4.0
func UpdateSource(source *LoginSource) error
func UpdateWebhook ¶ added in v0.4.0
UpdateWebhook updates information of webhook.
Types ¶
type Access ¶
type Access struct {
	Id       int64
	UserName string    `xorm:"unique(s)"`
	RepoName string    `xorm:"unique(s)"` // <user name>/<repo name>
	Mode     int       `xorm:"unique(s)"`
	Created  time.Time `xorm:"created"`
}
    Access represents the accessibility of user to repository.
type Action ¶
type Action struct {
	Id           int64
	UserId       int64 // Receiver user id.
	OpType       int
	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 (Action) GetActEmail ¶
func (Action) GetActUserName ¶
func (Action) GetContent ¶
func (Action) GetRepoName ¶
func (Action) GetRepoUserName ¶ added in v0.4.0
type Comment ¶
type Comment struct {
	Id       int64
	Type     int
	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 GetIssueComments ¶
GetIssueComments returns list of comment by given issue id.
type DiffSection ¶
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 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
GetIssueById returns an issue by ID.
func GetIssueByIndex ¶
GetIssueByIndex returns issue by given index in repository.
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
GetIssuesByLabel returns a list of issues by given label and repository.
func (*Issue) GetAssignee ¶ added in v0.4.0
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 // User ID.
	IssueId     int64
	RepoId      int64
	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
GetIssueUserPairs returns issue-user pairs by given repository and user.
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
implement
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
GetLabelById returns a label by given 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              int
	Name              string          `xorm:"unique"`
	IsActived         bool            `xorm:"not null default false"`
	Cfg               core.Conversion `xorm:"TEXT"`
	Created           time.Time       `xorm:"created"`
	Updated           time.Time       `xorm:"updated"`
	AllowAutoRegister bool            `xorm:"not null default false"`
}
    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)
for xorm callback
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 Member ¶
type Member struct {
	Id     int64
	OrgId  int64 `xorm:"unique(member) index"`
	UserId int64 `xorm:"unique(member)"`
}
    Member represents user is member of organization.
type Milestone ¶
type Milestone struct {
	Id              int64
	RepoId          int64 `xorm:"INDEX"`
	Index           int64
	Name            string
	Content         string
	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
GetMilestoneById returns the milestone by given ID.
func GetMilestoneByIndex ¶ added in v0.4.0
GetMilestoneByIndex returns the milestone of given repository and index.
func GetMilestones ¶ added in v0.4.0
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.
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"`
}
    func GetOauth2ById ¶ added in v0.3.0
func GetOauthByUserId ¶ added in v0.3.0
GetOauthByUserId returns list of oauthes that are releated to given user.
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 `xorm:"UPDATED"`
}
    PublicKey represents a SSH key.
func ListPublicKey ¶
ListPublicKey returns a list of all public keys that user has.
func (*PublicKey) GetAuthorizedString ¶ added in v0.4.0
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:"-"`
	Title            string
	TagName          string
	LowerTagName     string
	SHA1             string
	NumCommits       int
	NumCommitsBehind int    `xorm:"-"`
	Note             string `xorm:"TEXT"`
	IsPrerelease     bool
	Created          time.Time `xorm:"created"`
}
    Release represents a release of repository.
func GetReleasesByRepoId ¶ added in v0.3.0
GetReleasesByRepoId returns a list of releases of repository.
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:"-"`
	NumMilestones       int `xorm:"NOT NULL DEFAULT 0"`
	NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
	NumOpenMilestones   int `xorm:"-"`
	NumTags             int `xorm:"-"`
	IsPrivate           bool
	IsMirror            bool
	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(user *User, name, desc, lang, license string, private, mirror, initReadme bool) (*Repository, error)
CreateRepository creates a repository for given user or orgnaziation.
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() (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(userId int64, repoName string) (*Repository, error)
GetRepositoryByName returns the repository by given name under user if exists.
func MigrateRepository ¶ added in v0.3.0
func MigrateRepository(user *User, name, desc string, private, mirror bool, url string) (*Repository, error)
MigrateRepository migrates a existing repository from other project hosting.
func (*Repository) GetOwner ¶ added in v0.4.0
func (repo *Repository) GetOwner() (err error)
type SMTPConfig ¶ added in v0.4.0
func (*SMTPConfig) FromDB ¶ added in v0.4.0
func (cfg *SMTPConfig) FromDB(bs []byte) error
implement
func (*SMTPConfig) ToDB ¶ added in v0.4.0
func (cfg *SMTPConfig) ToDB() ([]byte, error)
type Statistic ¶
type Statistic struct {
	Counter struct {
		User, PublicKey, Repo, Watch, Action, Access,
		Issue, Comment, Mirror, Oauth, Release,
		LoginSource, Webhook, Milestone int64
	}
}
    func GetStatistic ¶
func GetStatistic() (stats Statistic)
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     int
	LoginSource   int64 `xorm:"not null default 0"`
	LoginName     string
	Type          int
	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"`
}
    User represents the object of individual and member of organization.
func GetCollaborators ¶ added in v0.4.0
GetCollaborators returns a list of users of repository's collaborators.
func GetUserByEmail ¶ added in v0.3.0
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 the user object by given name if exists.
func LoginUserLdapSource ¶ added in v0.4.0
func LoginUserLdapSource(user *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(user *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 RegisterUser ¶
RegisterUser creates record of a new user.
func SearchUserByName ¶ added in v0.4.0
SearchUserByName returns given number of users whose name contains keyword.
func UserSignIn ¶ added in v0.4.2
UserSignIn validates user name and password.
func VerifyUserActiveCode ¶
verify active code when active account
func (*User) AvatarLink ¶
AvatarLink returns user gravatar link.
func (*User) EncodePasswd ¶
func (user *User) EncodePasswd()
EncodePasswd encodes password to safe format.
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
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 int
	Secret      string `xorm:"TEXT"`
	Events      string `xorm:"TEXT"`
	*HookEvent  `xorm:"-"`
	IsSsl       bool
	IsActive    bool
}
    func GetActiveWebhooksByRepoId ¶ added in v0.4.0
GetActiveWebhooksByRepoId returns all active webhooks of repository.
func GetWebhookById ¶ added in v0.4.0
GetWebhookById returns webhook by given ID.
func GetWebhooksByRepoId ¶ added in v0.4.0
GetWebhooksByRepoId returns all webhooks of repository.