models

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2014 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AU_READABLE = iota + 1
	AU_WRITABLE
)

Access types.

View Source
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.

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 (
	IT_PLAIN  = iota // Pure comment.
	IT_REOPEN        // Issue reopen status change prompt.
	IT_CLOSE         // Issue close status change prompt.
)

Issue types.

View Source
const (
	LT_NOTYPE = iota
	LT_PLAIN
	LT_LDAP
	LT_SMTP
)

Login types.

View Source
const (
	OT_GITHUB = iota + 1
	OT_GOOGLE
	OT_TWITTER
	OT_QQ
	OT_WEIBO
	OT_BITBUCKET
	OT_OSCHINA
	OT_FACEBOOK
)

OT: Oauth2 Type

View Source
const (
	UT_INDIVIDUAL = iota + 1
	UT_ORGANIZATION
)

User types.

View Source
const (
	CT_JSON = iota + 1
	CT_FORM
)

Content types.

View Source
const DIFF_HEAD = "diff --git "

Variables

View Source
var (
	ErrIssueNotExist     = errors.New("Issue does not exist")
	ErrLabelNotExist     = errors.New("Label does not exist")
	ErrMilestoneNotExist = errors.New("Milestone does not exist")
)
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 (
	ErrKeyAlreadyExist = errors.New("Public key already exist")
	ErrKeyNotExist     = errors.New("Public key 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")
)
View Source
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")
)
View Source
var (
	ErrReleaseAlreadyExist = errors.New("Release already exist")
)
View Source
var (
	ErrWebhookNotExist = errors.New("Webhook does not exist")
)
View Source
var (
	LanguageIgns, Licenses []string
)
View Source
var LoginTypes = map[int]string{
	LT_LDAP: "LDAP",
	LT_SMTP: "SMTP",
}

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 AddPublicKey

func AddPublicKey(key *PublicKey) (err error)

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

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

ChangeMilestoneStatus changes the milestone open/closed 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(user *User, newUserName string) (err error)

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

func CreateWebhook(w *Webhook) error

CreateWebhook creates new webhook.

func DelLoginSource added in v0.4.0

func DelLoginSource(source *LoginSource) error

func DeleteAccess added in v0.4.0

func DeleteAccess(access *Access) error

DeleteAccess deletes access record.

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 DeletePublicKey

func DeletePublicKey(key *PublicKey) error

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

func DeleteRepository

func DeleteRepository(userId, repoId int64, userName string) (err error)

DeleteRepository deletes a repository for a user or orgnaztion.

func DeleteUser

func DeleteUser(user *User) error

DeleteUser completely deletes everything of the user.

func DeleteWebhook added in v0.4.0

func DeleteWebhook(hookId int64) error

DeleteWebhook deletes webhook of repository.

func DumpDatabase added in v0.4.0

func DumpDatabase(filePath string) error

DumpDatabase dumps all data from database to file system.

func Fix added in v0.4.0

func Fix() error

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 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 int) (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 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 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(user *User, repo *Repository) (err error)

NewRepoAction adds new action for creating repository.

func NewRepoContext

func NewRepoContext()

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 RepoPath

func RepoPath(userName, repoName string) string

RepoPath returns repository path by given user and repository name.

func SetEngine

func SetEngine() (err error)

func SetRepoEnvs added in v0.3.0

func SetRepoEnvs(userId int64, userName, repoName, repoUserName string)

SetRepoEnvs sets environment variables for command update.

func SmtpAuth added in v0.4.0

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

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

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)

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 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 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 UpdateRepository

func UpdateRepository(repo *Repository) error

func UpdateSource added in v0.4.0

func UpdateSource(source *LoginSource) error

func UpdateUser

func UpdateUser(u *User) (err 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, rid 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     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 GetFeeds

func GetFeeds(userid, 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) GetOpType

func (a Action) GetOpType() int

func (Action) GetRepoName

func (a Action) GetRepoName() string

func (Action) GetRepoUserName added in v0.4.0

func (a Action) GetRepoUserName() string

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

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

GetIssueComments returns list of comment by given issue id.

type Diff

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

func GetDiff

func GetDiff(repoPath, commitid string) (*Diff, error)

func ParsePatch

func ParsePatch(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 HookEvent added in v0.4.0

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

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 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) 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 // 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

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

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

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              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

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"`
}

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) (oas []*Oauth2, err error)

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