Documentation ¶
Index ¶
- Constants
- Variables
- func AddAccess(access *Access) error
- func AddOauth2(oa *Oauth2) error
- func AddPublicKey(key *PublicKey) (err error)
- func BindUserOauth2(userId, oauthId int64) error
- func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error)
- func ChangeUserName(user *User, newUserName string) (err error)
- func CommitRepoAction(userId int64, userName, actEmail string, repoId int64, repoName string, ...) error
- func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType int, content string) error
- func CreateRelease(repoPath string, rel *Release, gitRepo *git.Repository) error
- func DeletePublicKey(key *PublicKey) (err error)
- func DeleteRepository(userId, repoId int64, userName string) (err error)
- func DeleteUser(user *User) error
- func FollowUser(userId int64, followId int64) (err error)
- func ForkRepository(reposName string, userId int64)
- func GenAuthorizedKey(keyId int64, key string) string
- func GetRepositoryCount(user *User) (int64, error)
- func GetUserEmailsByNames(names []string) []string
- func GetUserIssueCount(userId, repoId int64) int64
- func GetUserSalt() string
- func HasAccess(userName, 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(user *User, repoName string) (bool, error)
- func IsUserExist(name string) (bool, error)
- func IsWatching(userId, repoId int64) bool
- func LoadModelsConfig()
- func LoadRepoConfig()
- func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error
- func MirrorUpdate()
- func NewEngine() (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 RepoPath(userName, repoName string) string
- func SaveAuthorizedKeyFile(key *PublicKey) error
- func SetEngine() (err error)
- func SetRepoEnvs(userId int64, userName, repoName string)
- 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, repoName string, userId int64)
- func UpdateAccess(access *Access) error
- func UpdateAccessWithSession(sess *xorm.Session, access *Access) error
- func UpdateIssue(issue *Issue) error
- func UpdateMirror(m *Mirror) error
- func UpdateRepository(repo *Repository) error
- func UpdateUser(user *User) (err error)
- func UserPath(userName string) string
- func WatchRepo(userId, repoId int64, watch bool) (err error)
- type Access
- type Action
- type Comment
- type Diff
- type DiffFile
- type DiffLine
- type DiffSection
- type Follow
- type Issue
- type Label
- 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 GetRecentUpdatedRepositories() (repos []*Repository, err error)
- func GetRepositories(user *User, private bool) ([]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 Statistic
- type User
- 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 LoginUserLdap(name, passwd string) (*User, error)
- func LoginUserPlain(uname, passwd string) (*User, error)
- func RegisterUser(user *User) (*User, error)
- func VerifyUserActiveCode(code string) (user *User)
- type UserRepo
- type Watch
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 )
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 ( IT_PLAIN = iota // Pure comment. IT_REOPEN // Issue reopen status change prompt. IT_CLOSE // Issue close status change prompt. )
Issue 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 ( LT_PLAIN = iota + 1 LT_LDAP )
Login types.
const DIFF_HEAD = "diff --git "
const (
// "### autogenerated by gitgos, DO NOT EDIT\n"
TPL_PUBLICK_KEY = `command="%s serv key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s`
)
Variables ¶
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 ( ErrRepoAlreadyExist = errors.New("Repository already exist") ErrRepoNotExist = errors.New("Repository does not exist") ErrRepoFileNotExist = errors.New("Target Repo file does not exist") ErrRepoNameIllegal = errors.New("Repository name contains illegal characters") ErrRepoFileNotLoaded = errors.New("repo 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") ErrEmailAlreadyUsed = errors.New("E-mail already used") ErrUserNameIllegal = errors.New("User name contains illegal characters") ErrKeyNotExist = errors.New("Public key does not exist") )
var (
ErrIssueNotExist = errors.New("Issue does not exist")
)
var (
ErrKeyAlreadyExist = errors.New("Public key already exist")
)
var (
ErrReleaseAlreadyExist = errors.New("Release already exist")
)
var (
LanguageIgns, Licenses []string
)
Functions ¶
func AddPublicKey ¶
AddPublicKey adds new public key to database and SSH key file.
func BindUserOauth2 ¶ added in v0.3.0
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 CommitRepoAction ¶
func CommitRepoAction(userId int64, userName, actEmail string, repoId int64, repoName string, refName 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(repoPath string, rel *Release, gitRepo *git.Repository) error
CreateRelease creates a new release of repository.
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 FollowUser ¶
FollowUser marks someone be another's follower.
func ForkRepository ¶
func GenAuthorizedKey ¶
GenAuthorizedKey returns formatted public key string.
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 GetUserIssueCount ¶
GetUserIssueCount returns the number of issues that were created by given user in repository.
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 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 SaveAuthorizedKeyFile ¶
SaveAuthorizedKeyFile writes SSH key content to SSH key file.
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 UpdateMirror ¶ added in v0.3.0
func UpdateRepository ¶
func UpdateRepository(repo *Repository) error
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 // Operations: CREATE DELETE STAR ... ActUserId int64 // Action user id. ActUserName string // Action user name. ActEmail string RepoId int64 RepoName string RefName string 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 ¶
type Comment ¶
type Comment struct { Id int64 Type int PosterId int64 Poster *User `xorm:"-"` IssueId int64 CommitId int64 Line int64 Content string 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 DiffFile ¶
type DiffFile struct { Name string Addition, Deletion int Type int IsBin bool Sections []*DiffSection }
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 Index int64 // Index in one repository. Name string RepoId int64 `xorm:"index"` Repo *Repository `xorm:"-"` PosterId int64 Poster *User `xorm:"-"` MilestoneId int64 AssigneeId int64 IsPull bool // Indicates whether is a pull request or not. IsClosed bool Labels string `xorm:"TEXT"` Mentions string `xorm:"TEXT"` Content string `xorm:"TEXT"` RenderedContent string `xorm:"-"` NumComments int Created time.Time `xorm:"created"` Updated time.Time `xorm:"updated"` }
Issue represents an issue or pull request of repository.
func CreateIssue ¶
func CreateIssue(userId, repoId, milestoneId, assigneeId int64, issueCount int, name, labels, content string, isPull bool) (issue *Issue, err error)
CreateIssue creates new issue for repository.
func GetIssueByIndex ¶
GetIssueById returns issue object by given id.
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 Name string RepoId int64 `xorm:"index"` IsClosed bool Content string NumIssues int DueDate time.Time Created time.Time `xorm:"created"` }
Milestone represents a milestone of repository.
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 of user.
func ListPublicKey ¶
ListPublicKey returns a list of public keys that user has.
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:"-"` 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 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(user *User, private bool) ([]Repository, error)
GetRepositories returns the list of repositories of given user.
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.
type Statistic ¶
type Statistic struct { Counter struct { User, PublicKey, Repo, Watch, Action, Access, Issue, Comment, Mirror, Oauth, Release 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"` Email string `xorm:"unique not null"` Passwd string `xorm:"not null"` LoginType int 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 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 LoginUserLdap ¶ added in v0.3.1
Query if name/passwd can login against the LDAP direcotry pool Create a local user if success Return the same LoginUserPlain semantic
func LoginUserPlain ¶
LoginUserPlain validates user by raw user name and password.
func RegisterUser ¶
RegisterUser creates record of a new user.
func VerifyUserActiveCode ¶
verify active code when active account
func (*User) AvatarLink ¶
AvatarLink returns the user gravatar link.
func (*User) EncodePasswd ¶
func (user *User) EncodePasswd()
EncodePasswd encodes password to safe format.
type UserRepo ¶
type UserRepo struct { *Repository UserName string }
UserRepo reporesents a repository with user name.