models

package
v0.11.79 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: MIT Imports: 73 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMTP_PLAIN = "PLAIN"
	SMTP_LOGIN = "LOGIN"
)
View Source
const (
	ENV_AUTH_USER_ID           = "GOGS_AUTH_USER_ID"
	ENV_AUTH_USER_NAME         = "GOGS_AUTH_USER_NAME"
	ENV_AUTH_USER_EMAIL        = "GOGS_AUTH_USER_EMAIL"
	ENV_REPO_OWNER_NAME        = "GOGS_REPO_OWNER_NAME"
	ENV_REPO_OWNER_SALT_MD5    = "GOGS_REPO_OWNER_SALT_MD5"
	ENV_REPO_ID                = "GOGS_REPO_ID"
	ENV_REPO_NAME              = "GOGS_REPO_NAME"
	ENV_REPO_CUSTOM_HOOKS_PATH = "GOGS_REPO_CUSTOM_HOOKS_PATH"
)
View Source
const (
	KEY_TYPE_USER = iota + 1
	KEY_TYPE_DEPLOY
)
View Source
const (
	HOOK_STATUS_NONE = iota
	HOOK_STATUS_SUCCEED
	HOOK_STATUS_FAILED
)
View Source
const (
	DingtalkNotificationTitle = "Gogs Notification"
)
View Source
const GIT_SHORT_EMPTY_SHA = "0000000"
View Source
const OWNER_TEAM = "Owners"
View Source
const REPO_AVATAR_URL_PREFIX = "repo-avatars"

REPO_AVATAR_URL_PREFIX is used to identify a URL is to access repository avatar.

View Source
const USER_AVATAR_URL_PREFIX = "avatars"

USER_AVATAR_URL_PREFIX is used to identify a URL is to access user avatar.

Variables

View Source
var (
	// Same as Github. See https://help.github.com/articles/closing-issues-via-commit-messages
	IssueCloseKeywords  = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"}
	IssueReopenKeywords = []string{"reopen", "reopens", "reopened"}

	IssueCloseKeywordsPat, IssueReopenKeywordsPat *regexp.Regexp
	IssueReferenceKeywordsPat                     *regexp.Regexp
)
View Source
var (
	HasEngine bool

	DbCfg struct {
		Type, Host, Name, User, Passwd, Path, SSLMode string
	}

	EnableSQLite3 bool
)
View Source
var (
	Gitignores, Licenses, Readmes, LabelTemplates []string

	// Maximum items per page in forks, watchers and stars of a repo
	ItemsPerPage = 40
)
View Source
var (
	ErrMissingIssueNumber = errors.New("No issue number specified")
)
View Source
var (
	ErrOrgNotExist = errors.New("Organization does not exist")
)
View Source
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
View Source
var LoginNames = map[LoginType]string{
	LOGIN_LDAP:  "LDAP (via BindDN)",
	LOGIN_DLDAP: "LDAP (simple auth)",
	LOGIN_SMTP:  "SMTP",
	LOGIN_PAM:   "PAM",
}
View Source
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
View Source
var PullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)
View Source
var SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN}

Functions

func AddEmailAddress added in v0.5.11

func AddEmailAddress(email *EmailAddress) error

func AddEmailAddresses added in v0.8.10

func AddEmailAddresses(emails []*EmailAddress) error

func AddOrgUser added in v0.5.0

func AddOrgUser(orgID, uid int64) error

AddOrgUser adds new user to given organization.

func AddTeamMember added in v0.5.0

func AddTeamMember(orgID, teamID, userID int64) error

AddTeamMember adds new membership of given team to given organization, the user will have membership to given organization automatically when needed.

func AddTeamRepo added in v0.6.0

func AddTeamRepo(orgID, teamID, repoID int64) error

AddTeamRepo adds new repository relation to team.

func AddTestPullRequestTask added in v0.7.0

func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool)

AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch, and generate new patch for testing as needed.

func AttachmentLocalPath added in v0.6.5

func AttachmentLocalPath(uuid string) string

AttachmentLocalPath returns where attachment is stored in local file system based on given UUID.

func Cell2Int64 added in v0.8.25

func Cell2Int64(val xorm.Cell) int64

Cell2Int64 converts a xorm.Cell type to int64, and handles possible irregular cases.

func ChangeMilestoneAssign added in v0.4.0

func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err error)

ChangeMilestoneAssign changes assignment of milestone for issue.

func ChangeMilestoneIssueStats added in v0.5.0

func ChangeMilestoneIssueStats(issue *Issue) (err error)

ChangeMilestoneIssueStats updates the open/closed issues counter and progress for the milestone associated with 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. If milestone passes with changed values, those values will be updated to database as well.

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(u *User, 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 ChangeUsernameInPullRequests added in v0.8.25

func ChangeUsernameInPullRequests(oldUserName, newUserName string) error

func CheckPublicKeyString added in v0.5.0

func CheckPublicKeyString(content string) (_ string, err error)

CheckPublicKeyString checks if the given public key string is recognized by SSH. It returns the actual public key line on success.

func CheckRepoStats added in v0.6.3

func CheckRepoStats()

func CommentHashTag added in v0.10.18

func CommentHashTag(id int64) string

func CommitRepoAction

func CommitRepoAction(opts CommitRepoActionOptions) error

CommitRepoAction adds new commit actio to the repository, and prepare corresponding webhooks.

func ComposeHTTPSCloneURL added in v0.9.71

func ComposeHTTPSCloneURL(owner, repo string) string

ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.

func ComposeHookEnvs added in v0.11.66

func ComposeHookEnvs(opts ComposeHookEnvsOptions) []string

func CountLoginSources added in v0.6.15

func CountLoginSources() int64

CountLoginSources returns total number of login sources.

func CountNotices added in v0.5.5

func CountNotices() int64

CountNotices returns number of notices.

func CountOrganizations added in v0.5.0

func CountOrganizations() int64

CountOrganizations returns number of organizations.

func CountRepoClosedMilestones added in v0.6.5

func CountRepoClosedMilestones(repoID int64) int64

CountRepoClosedMilestones returns number of closed milestones in given repository.

func CountRepoMilestones added in v0.6.5

func CountRepoMilestones(repoID int64) int64

CountRepoMilestones returns number of milestones in given repository.

func CountRepositories added in v0.5.0

func CountRepositories(private bool) int64

CountRepositories returns number of repositories. Argument private only takes effect when it is false, set it true to count all repositories.

func CountUserRepositories added in v0.9.60

func CountUserRepositories(userID int64, private bool) int64

CountUserRepositories returns number of repositories user owns. Argument private only takes effect when it is false, set it true to count all repositories.

func CountUsers added in v0.5.0

func CountUsers() int64

CountUsers returns number of users.

func CreateLoginSource added in v0.9.97

func CreateLoginSource(source *LoginSource) error

func CreateNotice added in v0.5.5

func CreateNotice(tp NoticeType, desc string) error

CreateNotice creates new system notice.

func CreateOrganization added in v0.5.0

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

CreateOrganization creates record of a new organization.

func CreateRefComment added in v0.6.15

func CreateRefComment(doer *User, repo *Repository, issue *Issue, content, commitSHA string) error

CreateRefComment creates a commit reference comment to issue.

func CreateRepositoryNotice added in v0.5.5

func CreateRepositoryNotice(desc string) error

CreateRepositoryNotice creates new system notice with type NOTICE_REPOSITORY.

func CreateUser added in v0.5.0

func CreateUser(u *User) (err 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 DeleteAccessTokenOfUserByID added in v0.9.113

func DeleteAccessTokenOfUserByID(userID, id int64) error

DeleteAccessTokenOfUserByID deletes access token by given ID.

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

func DeleteCollaboration(repo *Repository, userID int64) (err error)

DeleteCollaboration removes collaboration relation between the user and repository.

func DeleteCommentByID added in v0.9.60

func DeleteCommentByID(doer *User, id int64) error

DeleteCommentByID deletes the comment by given ID.

func DeleteDeployKey added in v0.6.5

func DeleteDeployKey(doer *User, id int64) error

DeleteDeployKey deletes deploy key from its repository authorized_keys file if needed.

func DeleteEmailAddress added in v0.5.11

func DeleteEmailAddress(email *EmailAddress) (err error)

func DeleteEmailAddresses added in v0.8.10

func DeleteEmailAddresses(emails []*EmailAddress) (err error)

func DeleteInactivateUsers added in v0.5.0

func DeleteInactivateUsers() (err error)

DeleteInactivateUsers deletes all inactivate users and email addresses.

func DeleteIssueLabel added in v0.6.5

func DeleteIssueLabel(issue *Issue, label *Label) (err error)

DeleteIssueLabel deletes issue-label relation.

func DeleteLabel added in v0.4.0

func DeleteLabel(repoID, labelID int64) error

DeleteLabel delete a label of given repository.

func DeleteMilestoneOfRepoByID added in v0.9.113

func DeleteMilestoneOfRepoByID(repoID, id int64) error

DeleteMilestoneOfRepoByID deletes a milestone from a repository.

func DeleteMirrorByRepoID added in v0.8.43

func DeleteMirrorByRepoID(repoID int64) error

func DeleteMissingRepositories added in v0.7.19

func DeleteMissingRepositories() error

DeleteMissingRepositories deletes all repository records that lost Git files.

func DeleteNotice added in v0.5.5

func DeleteNotice(id int64) error

DeleteNotice deletes a system notice by given ID.

func DeleteNotices added in v0.7.33

func DeleteNotices(start, end int64) error

DeleteNotices deletes all notices with ID from start to end (inclusive).

func DeleteNoticesByIDs added in v0.7.33

func DeleteNoticesByIDs(ids []int64) error

DeleteNoticesByIDs deletes notices by given IDs.

func DeleteOldRepositoryArchives added in v0.10.1

func DeleteOldRepositoryArchives()

func DeleteOrganization added in v0.5.0

func DeleteOrganization(org *User) (err error)

DeleteOrganization completely and permanently deletes everything of organization.

func DeletePublicKey

func DeletePublicKey(doer *User, id int64) (err error)

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

func DeleteReleaseOfRepoByID added in v0.9.113

func DeleteReleaseOfRepoByID(repoID, id int64) error

DeleteReleaseOfRepoByID deletes a release and corresponding Git tag by given ID.

func DeleteRepository

func DeleteRepository(uid, repoID int64) error

DeleteRepository deletes a repository for a user or organization.

func DeleteRepositoryArchives added in v0.5.8

func DeleteRepositoryArchives() error

DeleteRepositoryArchives deletes all repositories' archives.

func DeleteSource added in v0.6.15

func DeleteSource(source *LoginSource) error

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

func DeleteTwoFactor(userID int64) (err error)

DeleteTwoFactor removes two-factor authentication token and recovery codes of given user.

func DeleteUpload added in v0.9.97

func DeleteUpload(u *Upload) error

func DeleteUploadByUUID added in v0.9.97

func DeleteUploadByUUID(uuid string) error

func DeleteUploads added in v0.9.97

func DeleteUploads(uploads ...*Upload) (err error)

func DeleteUser

func DeleteUser(u *User) (err error)

DeleteUser completely and permanently deletes everything of a user, but issues/comments/pulls will be kept and shown as someone has been deleted.

func DeleteWebhookOfOrgByID added in v0.9.113

func DeleteWebhookOfOrgByID(orgID, id int64) error

DeleteWebhookOfOrgByID deletes webhook of organization by given ID.

func DeleteWebhookOfRepoByID added in v0.9.113

func DeleteWebhookOfRepoByID(repoID, id int64) error

DeleteWebhookOfRepoByID deletes webhook of repository by given ID.

func DeliverHooks added in v0.5.0

func DeliverHooks()

DeliverHooks checks and delivers undelivered hooks. TODO: shoot more hooks at same time.

func DiscordLinkFormatter added in v0.10.1

func DiscordLinkFormatter(url string, text string) string

func DiscordSHALinkFormatter added in v0.10.1

func DiscordSHALinkFormatter(url string, text string) string

func DiscordTextFormatter added in v0.10.1

func DiscordTextFormatter(s string) string

func DumpDatabase added in v0.4.0

func DumpDatabase(dirPath string) (err error)

DumpDatabase dumps all data from database to file system in JSON format.

func FilterRepositoryWithIssues added in v0.9.128

func FilterRepositoryWithIssues(repoIDs []int64) ([]int64, error)

FilterRepositoryWithIssues selects repositories that are using interal issue tracker and has disabled external tracker from given set. It returns nil if result set is empty.

func FollowUser

func FollowUser(userID, followID int64) (err error)

FollowUser marks someone be another's follower.

func GetLabelTemplateFile added in v0.9.97

func GetLabelTemplateFile(name string) ([][2]string, error)

GetLabelTemplateFile loads the label template file by given name, then parses and returns a list of name-color pairs.

func GetOrgIDsByUserID added in v0.10.8

func GetOrgIDsByUserID(userID int64, showPrivate bool) ([]int64, error)

GetOrgIDsByUserID returns a list of organization IDs that user belongs to. The showPrivate indicates whether to include private memberships.

func GetRepoIssueStats added in v0.6.9

func GetRepoIssueStats(repoID, userID int64, filterMode FilterMode, isPull bool) (numOpen int64, numClosed int64)

GetRepoIssueStats returns number of open and closed repository issues by given filter mode.

func GetRepositoryCount

func GetRepositoryCount(u *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 list of e-mails corresponds to names.

func GetUserIDsByNames added in v0.9.46

func GetUserIDsByNames(names []string) []int64

GetUserIDsByNames returns a slice of ids corresponds to names.

func GetUserSalt

func GetUserSalt() (string, error)

GetUserSalt returns a ramdom user salt token.

func GitFsck added in v0.5.9

func GitFsck()

GitFsck calls 'git fsck' to check repository health.

func GitGcRepos added in v0.5.9

func GitGcRepos() error

func HandleMirrorCredentials added in v0.11.4

func HandleMirrorCredentials(url string, mosaics bool) string

HandleMirrorCredentials replaces user credentials from HTTP/HTTPS URL with placeholder <credentials>. It returns original string if protocol is not HTTP/HTTPS.

func HasAccess

func HasAccess(userID int64, repo *Repository, testMode AccessMode) (bool, error)

HasAccess returns true if someone has the request access level. User can be nil!

func HasDeployKey added in v0.6.5

func HasDeployKey(keyID, repoID int64) bool

HasDeployKey returns true if public key is a deploy key of given repository.

func HasIssueLabel added in v0.6.5

func HasIssueLabel(issueID, labelID int64) bool

HasIssueLabel returns true if issue has been labeled.

func HasTeamRepo added in v0.6.0

func HasTeamRepo(orgID, teamID, repoID int64) bool

HasTeamRepo returns true if given team has access to the repository of the organization.

func ImportDatabase added in v0.10.8

func ImportDatabase(dirPath string, verbose bool) (err error)

ImportDatabase imports data from backup archive.

func InitDeliverHooks added in v0.6.3

func InitDeliverHooks()

func InitSyncMirrors added in v0.9.97

func InitSyncMirrors()

func InitTestPullRequests added in v0.7.0

func InitTestPullRequests()

func IsBranchOfRepoRequirePullRequest added in v0.10.1

func IsBranchOfRepoRequirePullRequest(repoID int64, name string) bool

IsBranchOfRepoRequirePullRequest returns true if branch requires pull request in given repository.

func IsCollaborator added in v0.11.4

func IsCollaborator(repoID, userID int64) bool

IsCollaborator returns true if the user is a collaborator of the repository.

func IsEmailUsed

func IsEmailUsed(email string) (bool, error)

IsEmailUsed returns true if the email has been used.

func IsErrAccessTokenEmpty added in v0.9.46

func IsErrAccessTokenEmpty(err error) bool

func IsErrAccessTokenNotExist added in v0.6.9

func IsErrAccessTokenNotExist(err error) bool

func IsErrAttachmentNotExist added in v0.6.5

func IsErrAttachmentNotExist(err error) bool

func IsErrCommentNotExist added in v0.6.9

func IsErrCommentNotExist(err error) bool

func IsErrDeployKeyAlreadyExist added in v0.6.5

func IsErrDeployKeyAlreadyExist(err error) bool

func IsErrDeployKeyNameAlreadyUsed added in v0.6.5

func IsErrDeployKeyNameAlreadyUsed(err error) bool

func IsErrDeployKeyNotExist added in v0.7.19

func IsErrDeployKeyNotExist(err error) bool

func IsErrEmailAlreadyUsed added in v0.6.3

func IsErrEmailAlreadyUsed(err error) bool

func IsErrInvalidCloneAddr added in v0.7.0

func IsErrInvalidCloneAddr(err error) bool

func IsErrInvalidTagName added in v0.9.60

func IsErrInvalidTagName(err error) bool

func IsErrKeyAccessDenied added in v0.7.33

func IsErrKeyAccessDenied(err error) bool

func IsErrKeyAlreadyExist added in v0.6.5

func IsErrKeyAlreadyExist(err error) bool

func IsErrKeyNameAlreadyUsed added in v0.6.5

func IsErrKeyNameAlreadyUsed(err error) bool

func IsErrKeyNotExist added in v0.6.5

func IsErrKeyNotExist(err error) bool

func IsErrKeyUnableVerify added in v0.7.19

func IsErrKeyUnableVerify(err error) bool

func IsErrLabelNotExist added in v0.6.5

func IsErrLabelNotExist(err error) bool

func IsErrLastOrgOwner added in v0.6.0

func IsErrLastOrgOwner(err error) bool

func IsErrLoginSourceAlreadyExist added in v0.9.97

func IsErrLoginSourceAlreadyExist(err error) bool

func IsErrLoginSourceInUse added in v0.9.97

func IsErrLoginSourceInUse(err error) bool

func IsErrMilestoneNotExist added in v0.6.5

func IsErrMilestoneNotExist(err error) bool

func IsErrNamePatternNotAllowed added in v0.6.3

func IsErrNamePatternNotAllowed(err error) bool

func IsErrNameReserved added in v0.6.3

func IsErrNameReserved(err error) bool

func IsErrPullRequestNotExist added in v0.6.9

func IsErrPullRequestNotExist(err error) bool

func IsErrReleaseAlreadyExist added in v0.7.19

func IsErrReleaseAlreadyExist(err error) bool

func IsErrReleaseNotExist added in v0.7.19

func IsErrReleaseNotExist(err error) bool

func IsErrRepoAlreadyExist added in v0.6.5

func IsErrRepoAlreadyExist(err error) bool

func IsErrRepoFileAlreadyExist added in v0.9.97

func IsErrRepoFileAlreadyExist(err error) bool

func IsErrTeamAlreadyExist added in v0.8.25

func IsErrTeamAlreadyExist(err error) bool

func IsErrUpdateTaskNotExist added in v0.7.0

func IsErrUpdateTaskNotExist(err error) bool

func IsErrUploadNotExist added in v0.9.97

func IsErrUploadNotExist(err error) bool

func IsErrUserAlreadyExist added in v0.6.3

func IsErrUserAlreadyExist(err error) bool

func IsErrUserHasOrgs added in v0.6.0

func IsErrUserHasOrgs(err error) bool

func IsErrUserOwnRepos added in v0.6.0

func IsErrUserOwnRepos(err error) bool

func IsErrWikiAlreadyExist added in v0.7.33

func IsErrWikiAlreadyExist(err error) bool

func IsFollowing added in v0.8.25

func IsFollowing(userID, followID int64) bool

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, userID 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 true 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(userID, 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 IsUsableRepoName added in v0.9.60

func IsUsableRepoName(name string) error

IsUsableRepoName return an error if given name is a reserved name or pattern.

func IsUsableTeamName added in v0.10.1

func IsUsableTeamName(name string) error

IsUsableTeamName return an error if given name is a reserved name or pattern.

func IsUsableUsername added in v0.9.60

func IsUsableUsername(name string) error

func IsUserEnabledTwoFactor added in v0.11.19

func IsUserEnabledTwoFactor(userID int64) bool

IsUserEnabledTwoFactor returns true if user has enabled two-factor authentication.

func IsUserExist

func IsUserExist(uid int64, name string) (bool, error)

IsUserExist checks if given user name exist, the user name should be noncased unique. If uid is presented, then check will rule out that one, it is used when update a user name in settings page.

func IsUserInProtectBranchWhitelist added in v0.10.1

func IsUserInProtectBranchWhitelist(repoID, userID int64, branch string) bool

IsUserInProtectBranchWhitelist returns true if given user is in the whitelist of a branch in a repository.

func IsValidHookContentType added in v0.5.8

func IsValidHookContentType(name string) bool

IsValidHookContentType returns true if given name is a valid hook content type.

func IsValidHookTaskType added in v0.5.8

func IsValidHookTaskType(name string) bool

IsValidHookTaskType returns true if given name is a valid hook task type.

func IsWatching

func IsWatching(userID, repoID int64) bool

IsWatching checks if user has watched given repository.

func IssuesCount added in v0.10.1

func IssuesCount(opts *IssuesOptions) (int64, error)

IssuesCount returns the number of issues by given conditions.

func LoadAuthSources added in v0.11.53

func LoadAuthSources()

LoadAuthSources loads authentication sources from local files and converts them into login sources.

func LoadConfigs added in v0.6.15

func LoadConfigs()

func LoadRepoConfig

func LoadRepoConfig()

func MakeEmailPrimary added in v0.5.11

func MakeEmailPrimary(email *EmailAddress) error

func MarkdownLinkFormatter added in v0.11.33

func MarkdownLinkFormatter(link, text string) string

Format link addr and title into markdown style

func MergePullRequestAction added in v0.6.9

func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue) error

MergePullRequestAction adds new action for merging pull request.

func MilestoneStats added in v0.6.5

func MilestoneStats(repoID int64) (open int64, closed int64)

MilestoneStats returns number of open and closed milestones of given repository.

func MirrorSyncCreateAction added in v0.11.53

func MirrorSyncCreateAction(repo *Repository, refName string) error

MirrorSyncCreateAction adds new action for mirror synchronization of new reference.

func MirrorSyncDeleteAction added in v0.11.53

func MirrorSyncDeleteAction(repo *Repository, refName string) error

MirrorSyncCreateAction adds new action for mirror synchronization of delete reference.

func MirrorSyncPushAction added in v0.11.53

func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) error

MirrorSyncPushAction adds new action for mirror synchronization of pushed commits.

func MirrorUpdate added in v0.3.0

func MirrorUpdate()

MirrorUpdate checks and updates mirror repositories.

func NewAccessToken added in v0.5.8

func NewAccessToken(t *AccessToken) error

NewAccessToken creates new access token.

func NewEngine

func NewEngine() (err error)

func NewIssue added in v0.4.0

func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error)

NewIssue creates new issue with labels and attachments for repository.

func NewIssueLabel added in v0.6.5

func NewIssueLabel(issue *Issue, label *Label) (err error)

NewIssueLabel creates a new issue-label relation.

func NewIssueLabels added in v0.9.60

func NewIssueLabels(issue *Issue, labels []*Label) (err error)

NewIssueLabels creates a list of issue-label relations.

func NewIssueUsers added in v0.6.5

func NewIssueUsers(repo *Repository, issue *Issue) (err error)

NewIssueUsers adds new issue-user relations for new issue of repository.

func NewLabels added in v0.9.97

func NewLabels(labels ...*Label) error

NewLabels creates new label(s) for a repository.

func NewMailerIssue added in v0.9.128

func NewMailerIssue(issue *Issue) mailer.Issue

func NewMailerRepo added in v0.9.128

func NewMailerRepo(repo *Repository) mailer.Repository

func NewMailerUser added in v0.9.128

func NewMailerUser(u *User) mailer.User

func NewMilestone added in v0.4.0

func NewMilestone(m *Milestone) (err error)

NewMilestone creates new milestone of repository.

func NewPullRequest added in v0.6.9

func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []string, pr *PullRequest, patch []byte) (err error)

NewPullRequest creates new pull request with labels for repository.

func NewRelease added in v0.10.18

func NewRelease(gitRepo *git.Repository, r *Release, uuids []string) error

NewRelease creates a new release with attachments for repository.

func NewRepoAction

func NewRepoAction(doer, owner *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 NewTwoFactor added in v0.11.19

func NewTwoFactor(userID int64, secret string) error

NewTwoFactor creates a new two-factor authentication token and recovery codes for given user.

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, uid int64) int

PairsContains returns true when pairs list contains given issue.

func Ping added in v0.5.0

func Ping() error

func PrepareWebhooks added in v0.6.9

func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) error

PrepareWebhooks adds all active webhooks to task queue.

func PushUpdate added in v0.8.43

func PushUpdate(opts PushUpdateOptions) (err error)

PushUpdate must be called for any push actions in order to generates necessary push action history feeds.

func RegenerateRecoveryCodes added in v0.11.19

func RegenerateRecoveryCodes(userID int64) error

RegenerateRecoveryCodes regenerates new set of recovery codes for given user.

func ReinitMissingRepositories added in v0.8.43

func ReinitMissingRepositories() error

ReinitMissingRepositories reinitializes all repository records that lost Git files.

func RemoveAllWithNotice added in v0.8.43

func RemoveAllWithNotice(title, path string)

RemoveAllWithNotice removes all directories in given path and creates a system notice when error occurs.

func RemoveOrgRepo added in v0.6.0

func RemoveOrgRepo(orgID, repoID int64) error

RemoveOrgRepo removes all team-repository relations of given organization.

func RemoveOrgUser added in v0.5.0

func RemoveOrgUser(orgID, userID 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 RemoveTeamRepo added in v0.6.0

func RemoveTeamRepo(teamID, repoID int64) error

RemoveTeamRepo deletes repository relation to team.

func RenameRepoAction added in v0.6.9

func RenameRepoAction(actUser *User, oldRepoName string, repo *Repository) error

RenameRepoAction adds new action for renaming a repository.

func RepoPath

func RepoPath(userName, repoName string) string

RepoPath returns repository path by given user and repository name.

func ResetNonDefaultLoginSources added in v0.11.66

func ResetNonDefaultLoginSources(source *LoginSource) error

ResetNonDefaultLoginSources clean other default source flag

func RewriteAuthorizedKeys added in v0.11.43

func RewriteAuthorizedKeys() error

RewriteAuthorizedKeys removes any authorized key and rewrite all keys from database again. Note: x.Iterate does not get latest data after insert/delete, so we have to call this function outsite any session scope independently.

func SMTPAuth added in v0.6.9

func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error

func SSHKeyGenParsePublicKey added in v0.9.0

func SSHKeyGenParsePublicKey(key string) (string, int, error)

SSHKeyGenParsePublicKey extracts key type and length using ssh-keygen.

func SSHNativeParsePublicKey added in v0.9.0

func SSHNativeParsePublicKey(keyLine string) (string, int, error)

SSHNativeParsePublicKey extracts the key type and length using the golang SSH library.

func SetEngine

func SetEngine() (err error)

func SlackLinkFormatter added in v0.5.0

func SlackLinkFormatter(url string, text string) string

func SlackShortTextFormatter added in v0.9.97

func SlackShortTextFormatter(s string) string

func SlackTextFormatter added in v0.5.0

func SlackTextFormatter(s string) string

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

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(userID, repoID int64, star bool) (err error)

Star or unstar repository.

func SyncMirrors added in v0.9.97

func SyncMirrors()

SyncMirrors checks and syncs mirrors. TODO: sync more mirrors at same time.

func SyncRepositoryHooks added in v0.10.1

func SyncRepositoryHooks() error

SyncRepositoryHooks rewrites all repositories' pre-receive, update and post-receive hooks to make sure the binary and custom conf path are up-to-date.

func TestPullRequests added in v0.7.0

func TestPullRequests()

TestPullRequests checks and tests untested patches of pull requests. TODO: test more pull requests at same time.

func TestWebhook added in v0.10.1

func TestWebhook(repo *Repository, event HookEventType, p api.Payloader, webhookID int64) error

TestWebhook adds the test webhook matches the ID to task queue.

func ToWikiPageName added in v0.7.33

func ToWikiPageName(urlString string) string

ToWikiPageName formats a URL back to corresponding wiki page name, and removes leading characters './' to prevent changing files that are not belong to wiki repository.

func ToWikiPageURL added in v0.7.33

func ToWikiPageURL(name string) string

ToWikiPageURL formats a string to corresponding wiki URL name.

func TransferOwnership added in v0.3.0

func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error

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

func TransferRepoAction added in v0.3.0

func TransferRepoAction(doer, oldOwner *User, repo *Repository) error

TransferRepoAction adds new action for transferring repository, the Owner field of repository is assumed to be new owner.

func UnfollowUser added in v0.8.25

func UnfollowUser(userID, followID int64) (err error)

UnfollowUser unmarks someone be another's follower.

func UpdateAccessToken added in v0.8.25

func UpdateAccessToken(t *AccessToken) error

UpdateAccessToken updates information of access token.

func UpdateComment added in v0.6.9

func UpdateComment(doer *User, c *Comment, oldContent string) (err error)

UpdateComment updates information of comment.

func UpdateDeployKey added in v0.6.5

func UpdateDeployKey(key *DeployKey) error

UpdateDeployKey updates deploy key information.

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 all fields of given issue.

func UpdateIssueCols added in v0.9.97

func UpdateIssueCols(issue *Issue, cols ...string) error

UpdateIssueCols only updates values of specific columns for given issue.

func UpdateIssueUserByAssignee added in v0.6.5

func UpdateIssueUserByAssignee(issue *Issue) (err error)

UpdateIssueUserByAssignee updates issue-user relation for assignee.

func UpdateIssueUserByRead added in v0.6.5

func UpdateIssueUserByRead(uid, issueID int64) error

UpdateIssueUserByRead updates issue-user relation for reading.

func UpdateIssueUsersByStatus added in v0.6.5

func UpdateIssueUsersByStatus(issueID int64, isClosed bool) error

UpdateIssueUsersByStatus updates issue-user relations by issue status.

func UpdateIssuesCommit added in v0.9.97

func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) error

UpdateIssuesCommit checks if issues are manipulated by commit message.

func UpdateLabel added in v0.4.0

func UpdateLabel(l *Label) error

UpdateLabel updates label information.

func UpdateLocalCopyBranch added in v0.9.97

func UpdateLocalCopyBranch(repoPath, localPath, branch string, isWiki bool) (err error)

UpdateLocalCopy fetches latest changes of given branch from repoPath to localPath. It creates a new clone if local copy does not exist, but does not checks out to a specific branch if the local copy belongs to a wiki. For existing local copy, it checks out to target branch by default, and safe to assume subsequent operations are against target branch when caller has confidence about no race condition.

func UpdateLoginSource added in v0.11.53

func UpdateLoginSource(source *LoginSource) error

UpdateLoginSource updates information of login source to database or local file.

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

func UpdateOrgProtectBranch(repo *Repository, protectBranch *ProtectBranch, whitelistUserIDs, whitelistTeamIDs string) (err error)

UpdateOrgProtectBranch saves branch protection options of organizational repository. If ID is 0, it creates a new record. Otherwise, updates existing record. This function also performs check if whitelist user and team's IDs have been changed to avoid unnecessary whitelist delete and regenerate.

func UpdateProtectBranch added in v0.10.1

func UpdateProtectBranch(protectBranch *ProtectBranch) (err error)

UpdateProtectBranch saves branch protection options. If ID is 0, it creates a new record. Otherwise, updates existing record.

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(doer *User, gitRepo *git.Repository, r *Release, isPublish bool, uuids []string) (err error)

UpdateRelease updates information of a release.

func UpdateRepository

func UpdateRepository(repo *Repository, visibilityChanged bool) (err 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 UploadLocalPath added in v0.9.97

func UploadLocalPath(uuid string) string

UploadLocalPath returns where uploads is stored in local file system based on given UUID.

func UseRecoveryCode added in v0.11.19

func UseRecoveryCode(userID int64, code string) error

UseRecoveryCode validates recovery code of given user and marks it is used if valid.

func UserPath

func UserPath(userName string) string

UserPath returns the path absolute path of user repositories.

func ValidateCommitsWithEmails added in v0.5.5

func ValidateCommitsWithEmails(oldCommits *list.List) *list.List

ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.

func WatchRepo

func WatchRepo(userID, repoID int64, watch bool) (err error)

Watch or unwatch repository.

func WikiPath added in v0.7.33

func WikiPath(userName, repoName string) string

WikiPath returns wiki data path by given user and repository name.

Types

type Access

type Access struct {
	ID     int64
	UserID int64 `xorm:"UNIQUE(s)"`
	RepoID int64 `xorm:"UNIQUE(s)"`
	Mode   AccessMode
}

Access represents the highest access level of a user to the repository. The only access type that is not in this table is the real owner of a repository. In case of an organization repository, the members of the owners team are in this table.

type AccessMode added in v0.6.0

type AccessMode int
const (
	ACCESS_MODE_NONE  AccessMode = iota // 0
	ACCESS_MODE_READ                    // 1
	ACCESS_MODE_WRITE                   // 2
	ACCESS_MODE_ADMIN                   // 3
	ACCESS_MODE_OWNER                   // 4
)

func AccessLevel added in v0.6.0

func AccessLevel(userID int64, repo *Repository) (AccessMode, error)

AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the user does not have access.

func ParseAccessMode added in v0.9.46

func ParseAccessMode(permission string) AccessMode

ParseAccessMode returns corresponding access mode to given permission string.

func (AccessMode) String added in v0.9.46

func (mode AccessMode) String() string

type AccessToken added in v0.5.8

type AccessToken struct {
	ID   int64
	UID  int64 `xorm:"INDEX"`
	Name string
	Sha1 string `xorm:"UNIQUE VARCHAR(40)"`

	Created           time.Time `xorm:"-" json:"-"`
	CreatedUnix       int64
	Updated           time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
	UpdatedUnix       int64
	HasRecentActivity bool `xorm:"-" json:"-"`
	HasUsed           bool `xorm:"-" json:"-"`
}

AccessToken represents a personal access token.

func GetAccessTokenBySHA added in v0.6.9

func GetAccessTokenBySHA(sha string) (*AccessToken, error)

GetAccessTokenBySHA returns access token by given sha1.

func ListAccessTokens added in v0.5.8

func ListAccessTokens(uid int64) ([]*AccessToken, error)

ListAccessTokens returns a list of access tokens belongs to given user.

func (*AccessToken) AfterSet added in v0.9.13

func (t *AccessToken) AfterSet(colName string, _ xorm.Cell)

func (*AccessToken) BeforeInsert added in v0.9.13

func (t *AccessToken) BeforeInsert()

func (*AccessToken) BeforeUpdate added in v0.9.13

func (t *AccessToken) BeforeUpdate()

type Action

type Action struct {
	ID           int64
	UserID       int64 // Receiver user ID
	OpType       ActionType
	ActUserID    int64  // Doer user ID
	ActUserName  string // Doer user name
	ActAvatar    string `xorm:"-" json:"-"`
	RepoID       int64  `xorm:"INDEX"`
	RepoUserName string
	RepoName     string
	RefName      string
	IsPrivate    bool      `xorm:"NOT NULL DEFAULT false"`
	Content      string    `xorm:"TEXT"`
	Created      time.Time `xorm:"-" json:"-"`
	CreatedUnix  int64
}

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(ctxUser *User, actorID, afterID int64, isProfile bool) ([]*Action, error)

GetFeeds returns action list of given user in given context. actorID is the user who's requesting, ctxUserID is the user/org that is requested. actorID can be -1 when isProfile is true or to skip the permission check.

func (*Action) AfterSet added in v0.6.9

func (a *Action) AfterSet(colName string, _ xorm.Cell)

func (*Action) BeforeInsert added in v0.9.13

func (a *Action) BeforeInsert()

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) GetIssueContent added in v0.7.19

func (a *Action) GetIssueContent() string

func (*Action) GetIssueInfos added in v0.5.0

func (a *Action) GetIssueInfos() []string

func (*Action) GetIssueTitle added in v0.7.19

func (a *Action) GetIssueTitle() string

func (*Action) GetOpType

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

func (*Action) GetRepoName

func (a *Action) GetRepoName() string

func (*Action) GetRepoPath added in v0.6.0

func (a *Action) GetRepoPath() string

func (*Action) GetRepoUserName added in v0.4.0

func (a *Action) GetRepoUserName() string

func (*Action) ShortActUserName added in v0.8.25

func (a *Action) ShortActUserName() string

func (*Action) ShortRepoName added in v0.8.25

func (a *Action) ShortRepoName() string

func (*Action) ShortRepoPath added in v0.8.25

func (a *Action) ShortRepoPath() string

func (*Action) ShortRepoUserName added in v0.8.25

func (a *Action) ShortRepoUserName() string

type ActionType added in v0.5.0

type ActionType int
const (
	ACTION_CREATE_REPO         ActionType = iota + 1 // 1
	ACTION_RENAME_REPO                               // 2
	ACTION_STAR_REPO                                 // 3
	ACTION_WATCH_REPO                                // 4
	ACTION_COMMIT_REPO                               // 5
	ACTION_CREATE_ISSUE                              // 6
	ACTION_CREATE_PULL_REQUEST                       // 7
	ACTION_TRANSFER_REPO                             // 8
	ACTION_PUSH_TAG                                  // 9
	ACTION_COMMENT_ISSUE                             // 10
	ACTION_MERGE_PULL_REQUEST                        // 11
	ACTION_CLOSE_ISSUE                               // 12
	ACTION_REOPEN_ISSUE                              // 13
	ACTION_CLOSE_PULL_REQUEST                        // 14
	ACTION_REOPEN_PULL_REQUEST                       // 15
	ACTION_CREATE_BRANCH                             // 16
	ACTION_DELETE_BRANCH                             // 17
	ACTION_DELETE_TAG                                // 18
	ACTION_FORK_REPO                                 // 19
	ACTION_MIRROR_SYNC_PUSH                          // 20
	ACTION_MIRROR_SYNC_CREATE                        // 21
	ACTION_MIRROR_SYNC_DELETE                        // 22
)

Note: To maintain backward compatibility only append to the end of list

type Attachment added in v0.5.0

type Attachment struct {
	ID        int64
	UUID      string `xorm:"uuid UNIQUE"`
	IssueID   int64  `xorm:"INDEX"`
	CommentID int64
	ReleaseID int64 `xorm:"INDEX"`
	Name      string

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
}

Attachment represent a attachment of issue/comment/release.

func GetAttachmentByUUID added in v0.6.5

func GetAttachmentByUUID(uuid string) (*Attachment, error)

GetAttachmentByUUID returns attachment by given UUID.

func GetAttachmentsByCommentID added in v0.6.5

func GetAttachmentsByCommentID(commentID int64) ([]*Attachment, error)

GetAttachmentsByCommentID returns all attachments of a comment.

func GetAttachmentsByIssueID added in v0.6.5

func GetAttachmentsByIssueID(issueID int64) ([]*Attachment, error)

GetAttachmentsByIssueID returns all attachments of an issue.

func GetAttachmentsByReleaseID added in v0.10.18

func GetAttachmentsByReleaseID(releaseID int64) ([]*Attachment, error)

GetAttachmentsByReleaseID returns all attachments of a release.

func NewAttachment added in v0.6.5

func NewAttachment(name string, buf []byte, file multipart.File) (_ *Attachment, err error)

NewAttachment creates a new attachment object.

func (*Attachment) AfterSet added in v0.9.13

func (a *Attachment) AfterSet(colName string, _ xorm.Cell)

func (*Attachment) BeforeInsert added in v0.9.13

func (a *Attachment) BeforeInsert()

func (*Attachment) LocalPath added in v0.6.5

func (attach *Attachment) LocalPath() string

LocalPath returns where attachment is stored in local file system.

type AuthSourceFile added in v0.11.53

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

AuthSourceFile contains information of an authentication source file.

func (*AuthSourceFile) Save added in v0.11.53

func (f *AuthSourceFile) Save() error

Save writes updates into file system.

func (*AuthSourceFile) SetConfig added in v0.11.53

func (f *AuthSourceFile) SetConfig(cfg core.Conversion) error

SetConfig sets new values to the "config" section.

func (*AuthSourceFile) SetGeneral added in v0.11.53

func (f *AuthSourceFile) SetGeneral(name, value string)

SetGeneral sets new value to the given key in the general (default) section.

type Branch added in v0.8.43

type Branch struct {
	RepoPath string
	Name     string

	IsProtected bool
	Commit      *git.Commit
}

func GetBranchesByPath added in v0.8.43

func GetBranchesByPath(path string) ([]*Branch, error)

func (*Branch) GetCommit added in v0.8.43

func (br *Branch) GetCommit() (*git.Commit, error)
type CloneLink struct {
	SSH   string
	HTTPS string
	Git   string
}

CloneLink represents different types of clone URLs of repository.

type Collaboration added in v0.6.0

type Collaboration struct {
	ID     int64
	RepoID int64      `xorm:"UNIQUE(s) INDEX NOT NULL"`
	UserID int64      `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Mode   AccessMode `xorm:"DEFAULT 2 NOT NULL"`
}

Collaboration represent the relation between an individual and a repository.

func (*Collaboration) ModeI18nKey added in v0.9.46

func (c *Collaboration) ModeI18nKey() string

type Collaborator added in v0.9.0

type Collaborator struct {
	*User
	Collaboration *Collaboration
}

Collaborator represents a user with collaboration details.

func (*Collaborator) APIFormat added in v0.10.1

func (c *Collaborator) APIFormat() *api.Collaborator

type Comment

type Comment struct {
	ID              int64
	Type            CommentType
	PosterID        int64
	Poster          *User  `xorm:"-" json:"-"`
	IssueID         int64  `xorm:"INDEX"`
	Issue           *Issue `xorm:"-" json:"-"`
	CommitID        int64
	Line            int64
	Content         string `xorm:"TEXT"`
	RenderedContent string `xorm:"-" json:"-"`

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
	Updated     time.Time `xorm:"-" json:"-"`
	UpdatedUnix int64

	// Reference issue in commit message
	CommitSHA string `xorm:"VARCHAR(40)"`

	Attachments []*Attachment `xorm:"-" json:"-"`

	// For view issue page.
	ShowTag CommentTag `xorm:"-" json:"-"`
}

Comment represents a comment in commit and issue page.

func CreateComment

func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error)

CreateComment creates comment of issue or commit.

func CreateIssueComment added in v0.6.5

func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error)

CreateIssueComment creates a plain issue comment.

func GetCommentByID added in v0.6.9

func GetCommentByID(id int64) (*Comment, error)

GetCommentByID returns the comment by given ID.

func GetCommentsByIssueID added in v0.6.5

func GetCommentsByIssueID(issueID int64) ([]*Comment, error)

GetCommentsByIssueID returns all comments of an issue.

func GetCommentsByIssueIDSince added in v0.9.97

func GetCommentsByIssueIDSince(issueID, since int64) ([]*Comment, error)

GetCommentsByIssueIDSince returns a list of comments of an issue since a given time point.

func GetCommentsByRepoIDSince added in v0.9.113

func GetCommentsByRepoIDSince(repoID, since int64) ([]*Comment, error)

GetCommentsByRepoIDSince returns a list of comments for all issues in a repo since a given time point.

func (*Comment) APIFormat added in v0.9.97

func (c *Comment) APIFormat() *api.Comment

This method assumes following fields have been assigned with valid values: Required - Poster, Issue

func (*Comment) AfterSet added in v0.6.5

func (c *Comment) AfterSet(colName string, _ xorm.Cell)

func (*Comment) BeforeInsert added in v0.9.13

func (c *Comment) BeforeInsert()

func (*Comment) BeforeUpdate added in v0.9.97

func (c *Comment) BeforeUpdate()

func (*Comment) EventTag added in v0.6.5

func (c *Comment) EventTag() string

EventTag returns unique event hash tag for comment.

func (*Comment) HTMLURL added in v0.9.113

func (c *Comment) HTMLURL() string

func (*Comment) HashTag added in v0.6.5

func (c *Comment) HashTag() string

HashTag returns unique hash tag for comment.

func (*Comment) LoadAttributes added in v0.9.113

func (c *Comment) LoadAttributes() error

type CommentTag added in v0.6.5

type CommentTag int
const (
	COMMENT_TAG_NONE CommentTag = iota
	COMMENT_TAG_POSTER
	COMMENT_TAG_WRITER
	COMMENT_TAG_OWNER
)

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 (LineNum > 0)
	COMMENT_TYPE_COMMENT CommentType = iota
	COMMENT_TYPE_REOPEN
	COMMENT_TYPE_CLOSE

	// References.
	COMMENT_TYPE_ISSUE_REF
	// Reference from a commit (not part of a pull request)
	COMMENT_TYPE_COMMIT_REF
	// Reference from a comment
	COMMENT_TYPE_COMMENT_REF
	// Reference from a pull request
	COMMENT_TYPE_PULL_REF
)

type CommitRepoActionOptions added in v0.9.97

type CommitRepoActionOptions struct {
	PusherName  string
	RepoOwnerID int64
	RepoName    string
	RefFullName string
	OldCommitID string
	NewCommitID string
	Commits     *PushCommits
}

type ComposeHookEnvsOptions added in v0.11.66

type ComposeHookEnvsOptions struct {
	AuthUser  *User
	OwnerName string
	OwnerSalt string
	RepoID    int64
	RepoName  string
	RepoPath  string
}

type CreateCommentOptions added in v0.9.0

type CreateCommentOptions struct {
	Type  CommentType
	Doer  *User
	Repo  *Repository
	Issue *Issue

	CommitID    int64
	CommitSHA   string
	LineNum     int64
	Content     string
	Attachments []string // UUIDs of attachments
}

type CreateRepoOptions added in v0.6.9

type CreateRepoOptions struct {
	Name        string
	Description string
	Gitignores  string
	License     string
	Readme      string
	IsPrivate   bool
	IsMirror    bool
	AutoInit    bool
}

type DeleteRepoFileOptions added in v0.9.97

type DeleteRepoFileOptions struct {
	LastCommitID string
	OldBranch    string
	NewBranch    string
	TreePath     string
	Message      string
}

type DeployKey added in v0.6.5

type DeployKey struct {
	ID          int64
	KeyID       int64 `xorm:"UNIQUE(s) INDEX"`
	RepoID      int64 `xorm:"UNIQUE(s) INDEX"`
	Name        string
	Fingerprint string
	Content     string `xorm:"-" json:"-"`

	Created           time.Time `xorm:"-" json:"-"`
	CreatedUnix       int64
	Updated           time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
	UpdatedUnix       int64
	HasRecentActivity bool `xorm:"-" json:"-"`
	HasUsed           bool `xorm:"-" json:"-"`
}

DeployKey represents deploy key information and its relation with repository.

func AddDeployKey added in v0.6.5

func AddDeployKey(repoID int64, name, content string) (*DeployKey, error)

AddDeployKey add new deploy key to database and authorized_keys file.

func GetDeployKeyByID added in v0.7.19

func GetDeployKeyByID(id int64) (*DeployKey, error)

GetDeployKeyByID returns deploy key by given ID.

func GetDeployKeyByRepo added in v0.6.5

func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error)

GetDeployKeyByRepo returns deploy key by given public key ID and repository ID.

func ListDeployKeys added in v0.6.5

func ListDeployKeys(repoID int64) ([]*DeployKey, error)

ListDeployKeys returns all deploy keys by given repository ID.

func (*DeployKey) AfterSet added in v0.6.5

func (k *DeployKey) AfterSet(colName string, _ xorm.Cell)

func (*DeployKey) BeforeInsert added in v0.9.13

func (k *DeployKey) BeforeInsert()

func (*DeployKey) BeforeUpdate added in v0.9.13

func (k *DeployKey) BeforeUpdate()

func (*DeployKey) GetContent added in v0.7.19

func (k *DeployKey) GetContent() error

GetContent gets associated public key content.

type Diff

type Diff struct {
	*git.Diff
	Files []*DiffFile
}

func GetDiffCommit added in v0.5.0

func GetDiffCommit(repoPath, commitID string, maxLines, maxLineCharacteres, maxFiles int) (*Diff, error)

func GetDiffRange added in v0.5.0

func GetDiffRange(repoPath, beforeCommitID, afterCommitID string, maxLines, maxLineCharacteres, maxFiles int) (*Diff, error)

func NewDiff added in v0.11.4

func NewDiff(gitDiff *git.Diff) *Diff

func ParsePatch

func ParsePatch(maxLines, maxLineCharacteres, maxFiles int, reader io.Reader) (*Diff, error)

type DiffFile

type DiffFile struct {
	*git.DiffFile
	Sections []*DiffSection
}

func (*DiffFile) HighlightClass added in v0.11.4

func (diffFile *DiffFile) HighlightClass() string

type DiffSection

type DiffSection struct {
	*git.DiffSection
}

func (*DiffSection) ComputedInlineDiffFor added in v0.11.4

func (diffSection *DiffSection) ComputedInlineDiffFor(diffLine *git.DiffLine) template.HTML

ComputedInlineDiffFor computes inline diff for the given line.

type DingtalkActionCard added in v0.11.33

type DingtalkActionCard struct {
	Title          string `json:"title"`
	Text           string `json:"text"`
	HideAvatar     string `json:"hideAvatar"`
	BtnOrientation string `json:"btnOrientation"`
	SingleTitle    string `json:"singleTitle"`
	SingleURL      string `json:"singleURL"`
}

Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1

func NewDingtalkActionCard added in v0.11.33

func NewDingtalkActionCard(singleTitle, singleURL string) DingtalkActionCard

type DingtalkAtObject added in v0.11.33

type DingtalkAtObject struct {
	AtMobiles []string `json:"atMobiles"`
	IsAtAll   bool     `json:"isAtAll"`
}

Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1

type DingtalkPayload added in v0.11.33

type DingtalkPayload struct {
	MsgType    string             `json:"msgtype"`
	At         DingtalkAtObject   `json:"at"`
	ActionCard DingtalkActionCard `json:"actionCard"`
}

Refer: https://open-doc.dingtalk.com/docs/doc.htm?treeId=257&articleId=105735&docType=1

func GetDingtalkPayload added in v0.11.33

func GetDingtalkPayload(p api.Payloader, event HookEventType) (payload *DingtalkPayload, err error)

TODO: add content

func (*DingtalkPayload) JSONPayload added in v0.11.33

func (p *DingtalkPayload) JSONPayload() ([]byte, error)

type DiscordEmbedAuthorObject added in v0.10.1

type DiscordEmbedAuthorObject struct {
	Name    string `json:"name"`
	URL     string `json:"url"`
	IconURL string `json:"icon_url"`
}

type DiscordEmbedFieldObject added in v0.10.1

type DiscordEmbedFieldObject struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type DiscordEmbedFooterObject added in v0.10.1

type DiscordEmbedFooterObject struct {
	Text string `json:"text"`
}

type DiscordEmbedObject added in v0.10.1

type DiscordEmbedObject struct {
	Title       string                     `json:"title"`
	Description string                     `json:"description"`
	URL         string                     `json:"url"`
	Color       int                        `json:"color"`
	Footer      *DiscordEmbedFooterObject  `json:"footer"`
	Author      *DiscordEmbedAuthorObject  `json:"author"`
	Fields      []*DiscordEmbedFieldObject `json:"fields"`
}

type DiscordPayload added in v0.10.1

type DiscordPayload struct {
	Content   string                `json:"content"`
	Username  string                `json:"username"`
	AvatarURL string                `json:"avatar_url"`
	Embeds    []*DiscordEmbedObject `json:"embeds"`
}

func GetDiscordPayload added in v0.10.1

func GetDiscordPayload(p api.Payloader, event HookEventType, meta string) (payload *DiscordPayload, err error)

func (*DiscordPayload) JSONPayload added in v0.10.1

func (p *DiscordPayload) JSONPayload() ([]byte, error)

type EmailAddress added in v0.5.11

type EmailAddress struct {
	ID          int64
	UID         int64  `xorm:"INDEX NOT NULL"`
	Email       string `xorm:"UNIQUE NOT NULL"`
	IsActivated bool
	IsPrimary   bool `xorm:"-" json:"-"`
}

EmailAdresses is the list of all email addresses of a user. Can contain the primary email address, but is not obligatory.

func GetEmailAddresses added in v0.5.11

func GetEmailAddresses(uid int64) ([]*EmailAddress, error)

GetEmailAddresses returns all email addresses belongs to given user.

func VerifyActiveEmailCode added in v0.5.11

func VerifyActiveEmailCode(code, email string) *EmailAddress

verify active code when active account

func (*EmailAddress) Activate added in v0.5.11

func (email *EmailAddress) Activate() error

type Engine added in v0.5.8

type Engine interface {
	Delete(interface{}) (int64, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Find(interface{}, ...interface{}) error
	Get(interface{}) (bool, error)
	ID(interface{}) *xorm.Session
	In(string, ...interface{}) *xorm.Session
	Insert(...interface{}) (int64, error)
	InsertOne(interface{}) (int64, error)
	Iterate(interface{}, xorm.IterFunc) error
	Sql(string, ...interface{}) *xorm.Session
	Table(interface{}) *xorm.Session
	Where(interface{}, ...interface{}) *xorm.Session
}

Engine represents a XORM engine or session.

type ErrAccessTokenEmpty added in v0.9.46

type ErrAccessTokenEmpty struct {
}

func (ErrAccessTokenEmpty) Error added in v0.9.46

func (err ErrAccessTokenEmpty) Error() string

type ErrAccessTokenNotExist added in v0.5.8

type ErrAccessTokenNotExist struct {
	SHA string
}

func (ErrAccessTokenNotExist) Error added in v0.6.9

func (err ErrAccessTokenNotExist) Error() string

type ErrAttachmentNotExist added in v0.5.0

type ErrAttachmentNotExist struct {
	ID   int64
	UUID string
}

func (ErrAttachmentNotExist) Error added in v0.6.5

func (err ErrAttachmentNotExist) Error() string

type ErrCommentNotExist added in v0.6.9

type ErrCommentNotExist struct {
	ID      int64
	IssueID int64
}

func (ErrCommentNotExist) Error added in v0.6.9

func (err ErrCommentNotExist) Error() string

type ErrDeployKeyAlreadyExist added in v0.6.5

type ErrDeployKeyAlreadyExist struct {
	KeyID  int64
	RepoID int64
}

func (ErrDeployKeyAlreadyExist) Error added in v0.6.5

func (err ErrDeployKeyAlreadyExist) Error() string

type ErrDeployKeyNameAlreadyUsed added in v0.6.5

type ErrDeployKeyNameAlreadyUsed struct {
	RepoID int64
	Name   string
}

func (ErrDeployKeyNameAlreadyUsed) Error added in v0.6.5

func (err ErrDeployKeyNameAlreadyUsed) Error() string

type ErrDeployKeyNotExist added in v0.7.19

type ErrDeployKeyNotExist struct {
	ID     int64
	KeyID  int64
	RepoID int64
}

func (ErrDeployKeyNotExist) Error added in v0.7.19

func (err ErrDeployKeyNotExist) Error() string

type ErrEmailAlreadyUsed

type ErrEmailAlreadyUsed struct {
	Email string
}

func (ErrEmailAlreadyUsed) Error added in v0.6.3

func (err ErrEmailAlreadyUsed) Error() string

type ErrInvalidCloneAddr added in v0.7.0

type ErrInvalidCloneAddr struct {
	IsURLError         bool
	IsInvalidPath      bool
	IsPermissionDenied bool
}

func (ErrInvalidCloneAddr) Error added in v0.7.0

func (err ErrInvalidCloneAddr) Error() string

type ErrInvalidTagName added in v0.9.60

type ErrInvalidTagName struct {
	TagName string
}

func (ErrInvalidTagName) Error added in v0.9.60

func (err ErrInvalidTagName) Error() string

type ErrKeyAccessDenied added in v0.7.33

type ErrKeyAccessDenied struct {
	UserID int64
	KeyID  int64
	Note   string
}

func (ErrKeyAccessDenied) Error added in v0.7.33

func (err ErrKeyAccessDenied) Error() string

type ErrKeyAlreadyExist

type ErrKeyAlreadyExist struct {
	OwnerID int64
	Content string
}

func (ErrKeyAlreadyExist) Error added in v0.6.5

func (err ErrKeyAlreadyExist) Error() string

type ErrKeyNameAlreadyUsed added in v0.6.5

type ErrKeyNameAlreadyUsed struct {
	OwnerID int64
	Name    string
}

func (ErrKeyNameAlreadyUsed) Error added in v0.6.5

func (err ErrKeyNameAlreadyUsed) Error() string

type ErrKeyNotExist

type ErrKeyNotExist struct {
	ID int64
}

func (ErrKeyNotExist) Error added in v0.6.5

func (err ErrKeyNotExist) Error() string

type ErrKeyUnableVerify added in v0.5.8

type ErrKeyUnableVerify struct {
	Result string
}

func (ErrKeyUnableVerify) Error added in v0.7.19

func (err ErrKeyUnableVerify) Error() string

type ErrLabelNotExist added in v0.4.0

type ErrLabelNotExist struct {
	LabelID int64
	RepoID  int64
}

func (ErrLabelNotExist) Error added in v0.6.5

func (err ErrLabelNotExist) Error() string

type ErrLastOrgOwner added in v0.5.0

type ErrLastOrgOwner struct {
	UID int64
}

func (ErrLastOrgOwner) Error added in v0.6.0

func (err ErrLastOrgOwner) Error() string

type ErrLoginSourceAlreadyExist added in v0.9.97

type ErrLoginSourceAlreadyExist struct {
	Name string
}

func (ErrLoginSourceAlreadyExist) Error added in v0.9.97

func (err ErrLoginSourceAlreadyExist) Error() string

type ErrLoginSourceInUse added in v0.9.97

type ErrLoginSourceInUse struct {
	ID int64
}

func (ErrLoginSourceInUse) Error added in v0.9.97

func (err ErrLoginSourceInUse) Error() string

type ErrMilestoneNotExist added in v0.4.0

type ErrMilestoneNotExist struct {
	ID     int64
	RepoID int64
}

func (ErrMilestoneNotExist) Error added in v0.6.5

func (err ErrMilestoneNotExist) Error() string

type ErrNamePatternNotAllowed added in v0.6.3

type ErrNamePatternNotAllowed struct {
	Pattern string
}

func (ErrNamePatternNotAllowed) Error added in v0.6.3

func (err ErrNamePatternNotAllowed) Error() string

type ErrNameReserved added in v0.6.3

type ErrNameReserved struct {
	Name string
}

func (ErrNameReserved) Error added in v0.6.3

func (err ErrNameReserved) Error() string

type ErrPullRequestNotExist added in v0.6.9

type ErrPullRequestNotExist struct {
	ID         int64
	IssueID    int64
	HeadRepoID int64
	BaseRepoID int64
	HeadBarcnh string
	BaseBranch string
}

func (ErrPullRequestNotExist) Error added in v0.6.9

func (err ErrPullRequestNotExist) Error() string

type ErrReleaseAlreadyExist added in v0.3.0

type ErrReleaseAlreadyExist struct {
	TagName string
}

func (ErrReleaseAlreadyExist) Error added in v0.7.19

func (err ErrReleaseAlreadyExist) Error() string

type ErrReleaseNotExist added in v0.5.0

type ErrReleaseNotExist struct {
	ID      int64
	TagName string
}

func (ErrReleaseNotExist) Error added in v0.7.19

func (err ErrReleaseNotExist) Error() string

type ErrRepoAlreadyExist

type ErrRepoAlreadyExist struct {
	Uname string
	Name  string
}

func (ErrRepoAlreadyExist) Error added in v0.6.5

func (err ErrRepoAlreadyExist) Error() string

type ErrRepoFileAlreadyExist added in v0.9.97

type ErrRepoFileAlreadyExist struct {
	FileName string
}

func (ErrRepoFileAlreadyExist) Error added in v0.9.97

func (err ErrRepoFileAlreadyExist) Error() string

type ErrTeamAlreadyExist added in v0.5.0

type ErrTeamAlreadyExist struct {
	OrgID int64
	Name  string
}

func (ErrTeamAlreadyExist) Error added in v0.8.25

func (err ErrTeamAlreadyExist) Error() string

type ErrUpdateTaskNotExist added in v0.7.0

type ErrUpdateTaskNotExist struct {
	UUID string
}

func (ErrUpdateTaskNotExist) Error added in v0.7.0

func (err ErrUpdateTaskNotExist) Error() string

type ErrUploadNotExist added in v0.9.97

type ErrUploadNotExist struct {
	ID   int64
	UUID string
}

func (ErrUploadNotExist) Error added in v0.9.97

func (err ErrUploadNotExist) Error() string

type ErrUserAlreadyExist

type ErrUserAlreadyExist struct {
	Name string
}

func (ErrUserAlreadyExist) Error added in v0.6.3

func (err ErrUserAlreadyExist) Error() string

type ErrUserHasOrgs added in v0.5.0

type ErrUserHasOrgs struct {
	UID int64
}

func (ErrUserHasOrgs) Error added in v0.6.0

func (err ErrUserHasOrgs) Error() string

type ErrUserOwnRepos

type ErrUserOwnRepos struct {
	UID int64
}

func (ErrUserOwnRepos) Error added in v0.6.0

func (err ErrUserOwnRepos) Error() string

type ErrWikiAlreadyExist added in v0.7.33

type ErrWikiAlreadyExist struct {
	Title string
}

func (ErrWikiAlreadyExist) Error added in v0.7.33

func (err ErrWikiAlreadyExist) Error() string

type FilterMode added in v0.9.128

type FilterMode string
const (
	FILTER_MODE_YOUR_REPOS FilterMode = "your_repositories"
	FILTER_MODE_ASSIGN     FilterMode = "assigned"
	FILTER_MODE_CREATE     FilterMode = "created_by"
	FILTER_MODE_MENTION    FilterMode = "mentioned"
)

type Follow

type Follow struct {
	ID       int64
	UserID   int64 `xorm:"UNIQUE(follow)"`
	FollowID int64 `xorm:"UNIQUE(follow)"`
}

Follow represents relations of user and his/her followers.

type HookContentType added in v0.5.0

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

func ToHookContentType added in v0.5.8

func ToHookContentType(name string) HookContentType

ToHookContentType returns HookContentType by given name.

func (HookContentType) Name added in v0.5.8

func (t HookContentType) Name() string

type HookEvent added in v0.4.0

type HookEvent struct {
	PushOnly       bool `json:"push_only"`
	SendEverything bool `json:"send_everything"`
	ChooseEvents   bool `json:"choose_events"`

	HookEvents `json:"events"`
}

HookEvent represents events that will delivery hook.

type HookEventType added in v0.5.0

type HookEventType string
const (
	HOOK_EVENT_CREATE        HookEventType = "create"
	HOOK_EVENT_DELETE        HookEventType = "delete"
	HOOK_EVENT_FORK          HookEventType = "fork"
	HOOK_EVENT_PUSH          HookEventType = "push"
	HOOK_EVENT_ISSUES        HookEventType = "issues"
	HOOK_EVENT_PULL_REQUEST  HookEventType = "pull_request"
	HOOK_EVENT_ISSUE_COMMENT HookEventType = "issue_comment"
	HOOK_EVENT_RELEASE       HookEventType = "release"
)

type HookEvents added in v0.6.9

type HookEvents struct {
	Create       bool `json:"create"`
	Delete       bool `json:"delete"`
	Fork         bool `json:"fork"`
	Push         bool `json:"push"`
	Issues       bool `json:"issues"`
	PullRequest  bool `json:"pull_request"`
	IssueComment bool `json:"issue_comment"`
	Release      bool `json:"release"`
}

type HookRequest added in v0.6.9

type HookRequest struct {
	Headers map[string]string `json:"headers"`
}

HookRequest represents hook task request information.

type HookResponse added in v0.6.9

type HookResponse struct {
	Status  int               `json:"status"`
	Headers map[string]string `json:"headers"`
	Body    string            `json:"body"`
}

HookResponse represents hook task response information.

type HookStatus added in v0.6.9

type HookStatus int

type HookTask added in v0.5.0

type HookTask struct {
	ID              int64
	RepoID          int64 `xorm:"INDEX"`
	HookID          int64
	UUID            string
	Type            HookTaskType
	URL             string `xorm:"TEXT"`
	Signature       string `xorm:"TEXT"`
	api.Payloader   `xorm:"-" json:"-"`
	PayloadContent  string `xorm:"TEXT"`
	ContentType     HookContentType
	EventType       HookEventType
	IsSSL           bool
	IsDelivered     bool
	Delivered       int64
	DeliveredString string `xorm:"-" json:"-"`

	// History info.
	IsSucceed       bool
	RequestContent  string        `xorm:"TEXT"`
	RequestInfo     *HookRequest  `xorm:"-" json:"-"`
	ResponseContent string        `xorm:"TEXT"`
	ResponseInfo    *HookResponse `xorm:"-" json:"-"`
}

HookTask represents a hook task.

func GetHookTaskOfWebhookByUUID added in v0.11.4

func GetHookTaskOfWebhookByUUID(webhookID int64, uuid string) (*HookTask, error)

GetHookTaskOfWebhookByUUID returns hook task of given webhook by UUID.

func HookTasks added in v0.6.9

func HookTasks(hookID int64, page int) ([]*HookTask, error)

HookTasks returns a list of hook tasks by given conditions.

func (*HookTask) AfterSet added in v0.6.9

func (t *HookTask) AfterSet(colName string, _ xorm.Cell)

func (*HookTask) BeforeUpdate added in v0.6.9

func (t *HookTask) BeforeUpdate()

func (*HookTask) MarshalJSON added in v0.6.9

func (t *HookTask) MarshalJSON(v interface{}) string

type HookTaskType added in v0.5.0

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

func ToHookTaskType added in v0.5.8

func ToHookTaskType(name string) HookTaskType

ToHookTaskType returns HookTaskType by given name.

func (HookTaskType) Name added in v0.5.8

func (t HookTaskType) Name() string

type Issue

type Issue struct {
	ID              int64
	RepoID          int64       `xorm:"INDEX UNIQUE(repo_index)"`
	Repo            *Repository `xorm:"-" json:"-"`
	Index           int64       `xorm:"UNIQUE(repo_index)"` // Index in one repository.
	PosterID        int64
	Poster          *User    `xorm:"-" json:"-"`
	Title           string   `xorm:"name"`
	Content         string   `xorm:"TEXT"`
	RenderedContent string   `xorm:"-" json:"-"`
	Labels          []*Label `xorm:"-" json:"-"`
	MilestoneID     int64
	Milestone       *Milestone `xorm:"-" json:"-"`
	Priority        int
	AssigneeID      int64
	Assignee        *User `xorm:"-" json:"-"`
	IsClosed        bool
	IsRead          bool         `xorm:"-" json:"-"`
	IsPull          bool         // Indicates whether is a pull request or not.
	PullRequest     *PullRequest `xorm:"-" json:"-"`
	NumComments     int

	Deadline     time.Time `xorm:"-" json:"-"`
	DeadlineUnix int64
	Created      time.Time `xorm:"-" json:"-"`
	CreatedUnix  int64
	Updated      time.Time `xorm:"-" json:"-"`
	UpdatedUnix  int64

	Attachments []*Attachment `xorm:"-" json:"-"`
	Comments    []*Comment    `xorm:"-" json:"-"`
}

Issue represents an issue or pull request of repository.

func GetIssueByID added in v0.6.5

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

GetIssueByID returns an issue by given ID.

func GetIssueByIndex

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

GetIssueByIndex returns issue by index in a repository.

func GetIssueByRef added in v0.5.0

func GetIssueByRef(ref string) (*Issue, 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 GetRawIssueByIndex added in v0.9.97

func GetRawIssueByIndex(repoID, index int64) (*Issue, error)

GetIssueByIndex returns raw issue without loading attributes by index in a repository.

func Issues added in v0.6.5

func Issues(opts *IssuesOptions) ([]*Issue, error)

Issues returns a list of issues by given conditions.

func (*Issue) APIFormat added in v0.9.97

func (issue *Issue) APIFormat() *api.Issue

This method assumes some fields assigned with values: Required - Poster, Labels, Optional - Milestone, Assignee, PullRequest

func (*Issue) AddLabel added in v0.6.5

func (issue *Issue) AddLabel(doer *User, label *Label) error

AddLabel adds a new label to the issue.

func (*Issue) AddLabels added in v0.9.60

func (issue *Issue) AddLabels(doer *User, labels []*Label) error

AddLabels adds a list of new labels to the issue.

func (*Issue) AfterSet added in v0.6.5

func (issue *Issue) AfterSet(colName string, _ xorm.Cell)

func (*Issue) BeforeInsert added in v0.9.13

func (issue *Issue) BeforeInsert()

func (*Issue) BeforeUpdate added in v0.9.13

func (issue *Issue) BeforeUpdate()

func (*Issue) ChangeAssignee added in v0.9.97

func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error)

func (*Issue) ChangeContent added in v0.9.97

func (issue *Issue) ChangeContent(doer *User, content string) (err error)

func (*Issue) ChangeStatus added in v0.6.5

func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (err error)

ChangeStatus changes issue status to open or closed.

func (*Issue) ChangeTitle added in v0.9.97

func (issue *Issue) ChangeTitle(doer *User, title string) (err error)

func (*Issue) ClearLabels added in v0.6.5

func (issue *Issue) ClearLabels(doer *User) (err error)

func (*Issue) GetAssignee added in v0.4.0

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

func (*Issue) HTMLURL added in v0.9.97

func (issue *Issue) HTMLURL() string

func (*Issue) HasLabel added in v0.6.5

func (issue *Issue) HasLabel(labelID int64) bool

HasLabel returns true if issue has been labeled by given ID.

func (*Issue) HashTag added in v0.6.5

func (issue *Issue) HashTag() string

HashTag returns unique hash tag for issue.

func (*Issue) IsPoster added in v0.6.5

func (issue *Issue) IsPoster(uid int64) bool

IsPoster returns true if given user by ID is the poster.

func (*Issue) LoadAttributes added in v0.9.48

func (issue *Issue) LoadAttributes() error

func (*Issue) MailParticipants added in v0.9.46

func (issue *Issue) MailParticipants() (err error)

MailParticipants sends new issue thread created emails to repository watchers and mentioned people.

func (*Issue) MailSubject added in v0.9.46

func (issue *Issue) MailSubject() string

func (*Issue) ReadBy added in v0.6.5

func (issue *Issue) ReadBy(uid int64) error

ReadBy sets issue to be read by given user.

func (*Issue) RemoveLabel added in v0.6.5

func (issue *Issue) RemoveLabel(doer *User, label *Label) error

RemoveLabel removes a label from issue by given ID.

func (*Issue) ReplaceLabels added in v0.9.60

func (issue *Issue) ReplaceLabels(labels []*Label) (err error)

ReplaceLabels removes all current labels and add new labels to the issue.

func (*Issue) State added in v0.9.13

func (issue *Issue) State() api.StateType

State returns string representation of issue status.

type IssueLabel added in v0.6.5

type IssueLabel struct {
	ID      int64
	IssueID int64 `xorm:"UNIQUE(s)"`
	LabelID int64 `xorm:"UNIQUE(s)"`
}

IssueLabel represetns an issue-lable relation.

func GetIssueLabels added in v0.6.5

func GetIssueLabels(issueID int64) ([]*IssueLabel, error)

GetIssueLabels returns all issue-label relations of given issue by ID.

type IssueStats added in v0.4.0

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

IssueStats represents issue statistic information.

func GetIssueStats added in v0.4.0

func GetIssueStats(opts *IssueStatsOptions) *IssueStats

GetIssueStats returns issue statistic information by given conditions.

func GetUserIssueStats added in v0.4.0

func GetUserIssueStats(repoID, userID int64, repoIDs []int64, filterMode FilterMode, isPull bool) *IssueStats

GetUserIssueStats returns issue statistic information for dashboard by given conditions.

type IssueStatsOptions added in v0.6.9

type IssueStatsOptions struct {
	RepoID      int64
	UserID      int64
	Labels      string
	MilestoneID int64
	AssigneeID  int64
	FilterMode  FilterMode
	IsPull      bool
}

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

func GetIssueUserPairsByMode(userID, repoID int64, filterMode FilterMode, isClosed bool, page 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.

func GetIssueUsers added in v0.6.5

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

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

type IssuesOptions added in v0.6.9

type IssuesOptions struct {
	UserID      int64
	AssigneeID  int64
	RepoID      int64
	PosterID    int64
	MilestoneID int64
	RepoIDs     []int64
	Page        int
	IsClosed    bool
	IsMention   bool
	IsPull      bool
	Labels      string
	SortType    string
}

type KeyType added in v0.6.5

type KeyType int

type LDAPConfig added in v0.4.0

type LDAPConfig struct {
	*ldap.Source `ini:"config"`
}

func (*LDAPConfig) FromDB added in v0.4.0

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

func (*LDAPConfig) SecurityProtocolName added in v0.9.46

func (cfg *LDAPConfig) SecurityProtocolName() string

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:"-" json:"-"`
	IsChecked       bool `xorm:"-" json:"-"`
}

Label represents a label of repository for issues.

func GetLabelByID added in v0.6.5

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

GetLabelByID returns a label by given ID.

func GetLabelOfRepoByID added in v0.9.113

func GetLabelOfRepoByID(repoID, labelID int64) (*Label, error)

GetLabelOfRepoByID returns a label by ID in given repository.

func GetLabelOfRepoByName added in v0.11.19

func GetLabelOfRepoByName(repoID int64, labelName string) (*Label, error)

GetLabelOfRepoByName returns a label by name in given repository.

func GetLabelsByIssueID added in v0.6.5

func GetLabelsByIssueID(issueID int64) ([]*Label, error)

GetLabelsByIssueID returns all labels that belong to given issue by ID.

func GetLabelsByRepoID added in v0.6.5

func GetLabelsByRepoID(repoID int64) ([]*Label, error)

GetLabelsByRepoID returns all labels that belong to given repository by ID.

func GetLabelsInRepoByIDs added in v0.9.60

func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error)

GetLabelsInRepoByIDs returns a list of labels by IDs in given repository, it silently ignores label IDs that are not belong to the repository.

func (*Label) APIFormat added in v0.9.97

func (label *Label) APIFormat() *api.Label

func (*Label) CalOpenIssues added in v0.4.0

func (label *Label) CalOpenIssues()

CalOpenIssues calculates the open issues of label.

func (*Label) ForegroundColor added in v0.9.0

func (l *Label) ForegroundColor() template.CSS

ForegroundColor calculates the text color for labels based on their background color.

type LocalLoginSources added in v0.11.53

type LocalLoginSources struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LocalLoginSources contains authentication sources configured and loaded from local files. Calling its methods is thread-safe; otherwise, please maintain the mutex accordingly.

func (*LocalLoginSources) ActivatedList added in v0.11.53

func (s *LocalLoginSources) ActivatedList() []*LoginSource

ActivatedList returns clone of activated login sources.

func (*LocalLoginSources) GetLoginSourceByID added in v0.11.53

func (s *LocalLoginSources) GetLoginSourceByID(id int64) (*LoginSource, error)

GetLoginSourceByID returns a clone of login source by given ID.

func (*LocalLoginSources) Len added in v0.11.53

func (s *LocalLoginSources) Len() int

func (*LocalLoginSources) List added in v0.11.53

func (s *LocalLoginSources) List() []*LoginSource

List returns full clone of login sources.

func (*LocalLoginSources) UpdateLoginSource added in v0.11.53

func (s *LocalLoginSources) UpdateLoginSource(source *LoginSource)

UpdateLoginSource updates in-memory copy of the authentication source.

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"`
	IsDefault bool            `xorm:"DEFAULT false"`
	Cfg       core.Conversion `xorm:"TEXT"`

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
	Updated     time.Time `xorm:"-" json:"-"`
	UpdatedUnix int64

	LocalFile *AuthSourceFile `xorm:"-" json:"-"`
}

LoginSource represents an external way for authorizing users.

func ActivatedLoginSources added in v0.11.53

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

ActivatedLoginSources returns login sources that are currently activated.

func GetLoginSourceByID added in v0.6.9

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

GetLoginSourceByID returns login source by given ID.

func LoginSources added in v0.6.15

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

LoginSources returns all login sources defined.

func (*LoginSource) AfterSet added in v0.9.13

func (s *LoginSource) AfterSet(colName string, _ xorm.Cell)

func (*LoginSource) BeforeInsert added in v0.9.13

func (s *LoginSource) BeforeInsert()

func (*LoginSource) BeforeSet added in v0.4.0

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

func (*LoginSource) BeforeUpdate added in v0.9.13

func (s *LoginSource) BeforeUpdate()

func (*LoginSource) HasTLS added in v0.9.46

func (s *LoginSource) HasTLS() bool

func (*LoginSource) IsDLDAP added in v0.6.15

func (s *LoginSource) IsDLDAP() bool

func (*LoginSource) IsLDAP added in v0.6.15

func (s *LoginSource) IsLDAP() bool

func (*LoginSource) IsPAM added in v0.6.15

func (s *LoginSource) IsPAM() bool

func (*LoginSource) IsSMTP added in v0.6.15

func (s *LoginSource) IsSMTP() bool

func (*LoginSource) LDAP added in v0.4.0

func (s *LoginSource) LDAP() *LDAPConfig

func (*LoginSource) PAM added in v0.6.3

func (s *LoginSource) PAM() *PAMConfig

func (*LoginSource) SMTP added in v0.4.0

func (s *LoginSource) SMTP() *SMTPConfig

func (*LoginSource) SkipVerify added in v0.6.15

func (s *LoginSource) SkipVerify() bool

func (*LoginSource) TypeName added in v0.6.15

func (s *LoginSource) TypeName() string

func (*LoginSource) UseTLS added in v0.6.15

func (s *LoginSource) UseTLS() bool

type LoginType added in v0.5.0

type LoginType int
const (
	LOGIN_NOTYPE LoginType = iota
	LOGIN_PLAIN            // 1
	LOGIN_LDAP             // 2
	LOGIN_SMTP             // 3
	LOGIN_PAM              // 4
	LOGIN_DLDAP            // 5
)

Note: new type must append to the end of list to maintain compatibility.

type MergeStyle added in v0.11.33

type MergeStyle string

MergeStyle represents the approach to merge commits into base branch.

const (
	MERGE_STYLE_REGULAR MergeStyle = "create_merge_commit"
	MERGE_STYLE_REBASE  MergeStyle = "rebase_before_merging"
)

type MigrateRepoOptions added in v0.7.0

type MigrateRepoOptions struct {
	Name        string
	Description string
	IsPrivate   bool
	IsMirror    bool
	RemoteAddr  string
}

type Milestone

type Milestone struct {
	ID              int64
	RepoID          int64 `xorm:"INDEX"`
	Name            string
	Content         string `xorm:"TEXT"`
	RenderedContent string `xorm:"-" json:"-"`
	IsClosed        bool
	NumIssues       int
	NumClosedIssues int
	NumOpenIssues   int  `xorm:"-" json:"-"`
	Completeness    int  // Percentage(1-100).
	IsOverDue       bool `xorm:"-" json:"-"`

	DeadlineString string    `xorm:"-" json:"-"`
	Deadline       time.Time `xorm:"-" json:"-"`
	DeadlineUnix   int64
	ClosedDate     time.Time `xorm:"-" json:"-"`
	ClosedDateUnix int64
}

Milestone represents a milestone of repository.

func GetMilestoneByRepoID added in v0.9.97

func GetMilestoneByRepoID(repoID, id int64) (*Milestone, error)

GetWebhookByRepoID returns the milestone in a repository.

func GetMilestones added in v0.4.0

func GetMilestones(repoID int64, page int, isClosed bool) ([]*Milestone, error)

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

func GetMilestonesByRepoID added in v0.9.97

func GetMilestonesByRepoID(repoID int64) ([]*Milestone, error)

GetMilestonesByRepoID returns all milestones of a repository.

func (*Milestone) APIFormat added in v0.9.97

func (m *Milestone) APIFormat() *api.Milestone

func (*Milestone) AfterSet added in v0.6.5

func (m *Milestone) AfterSet(colName string, _ xorm.Cell)

func (*Milestone) BeforeInsert added in v0.9.13

func (m *Milestone) BeforeInsert()

func (*Milestone) BeforeUpdate added in v0.6.5

func (m *Milestone) BeforeUpdate()

func (*Milestone) ChangeStatus added in v0.9.141

func (m *Milestone) ChangeStatus(isClosed bool) error

func (*Milestone) CountIssues added in v0.11.4

func (m *Milestone) CountIssues(isClosed, includePulls bool) int64

func (*Milestone) State added in v0.9.13

func (m *Milestone) State() api.StateType

State returns string representation of milestone status.

type Mirror added in v0.3.0

type Mirror struct {
	ID          int64
	RepoID      int64
	Repo        *Repository `xorm:"-" json:"-"`
	Interval    int         // Hour.
	EnablePrune bool        `xorm:"NOT NULL DEFAULT true"`

	// Last and next sync time of Git data from upstream
	LastSync     time.Time `xorm:"-" json:"-"`
	LastSyncUnix int64     `xorm:"updated_unix"`
	NextSync     time.Time `xorm:"-" json:"-"`
	NextSyncUnix int64     `xorm:"next_update_unix"`
	// contains filtered or unexported fields
}

Mirror represents mirror information of a repository.

func GetMirrorByRepoID added in v0.9.97

func GetMirrorByRepoID(repoID int64) (*Mirror, error)

GetMirrorByRepoID returns mirror information of a repository.

func (*Mirror) Address added in v0.8.0

func (m *Mirror) Address() string

Address returns mirror address from Git repository config without credentials.

func (*Mirror) AfterSet added in v0.6.9

func (m *Mirror) AfterSet(colName string, _ xorm.Cell)

func (*Mirror) BeforeInsert added in v0.9.13

func (m *Mirror) BeforeInsert()

func (*Mirror) BeforeUpdate added in v0.9.13

func (m *Mirror) BeforeUpdate()

func (*Mirror) FullAddress added in v0.8.0

func (m *Mirror) FullAddress() string

FullAddress returns mirror address from Git repository config with unescaped credentials.

func (*Mirror) MosaicsAddress added in v0.9.141

func (m *Mirror) MosaicsAddress() string

MosaicsAddress returns mirror address from Git repository config with credentials under mosaics.

func (*Mirror) RawAddress added in v0.11.4

func (m *Mirror) RawAddress() string

RawAddress returns raw mirror address directly from Git repository config.

func (*Mirror) SaveAddress added in v0.8.0

func (m *Mirror) SaveAddress(addr string) error

SaveAddress writes new address to Git repository config.

func (*Mirror) ScheduleNextSync added in v0.11.53

func (m *Mirror) ScheduleNextSync()

ScheduleNextSync calculates and sets next sync time based on repostiroy mirror setting.

type MirrorRepositoryList added in v0.9.60

type MirrorRepositoryList []*Repository

func (MirrorRepositoryList) LoadAttributes added in v0.9.60

func (repos MirrorRepositoryList) LoadAttributes() error

type MirrorSyncPushActionOptions added in v0.11.53

type MirrorSyncPushActionOptions struct {
	RefName     string
	OldCommitID string
	NewCommitID string
	Commits     *PushCommits
}

type NewIssueOptions added in v0.9.97

type NewIssueOptions struct {
	Repo        *Repository
	Issue       *Issue
	LableIDs    []int64
	Attachments []string // In UUID format.
	IsPull      bool
}

type Notice added in v0.5.5

type Notice struct {
	ID          int64
	Type        NoticeType
	Description string    `xorm:"TEXT"`
	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
}

Notice represents a system notice for admin.

func Notices added in v0.6.15

func Notices(page, pageSize int) ([]*Notice, error)

Notices returns number of notices in given page.

func (*Notice) AfterSet added in v0.9.13

func (n *Notice) AfterSet(colName string, _ xorm.Cell)

func (*Notice) BeforeInsert added in v0.9.13

func (n *Notice) BeforeInsert()

func (*Notice) TrStr added in v0.5.5

func (n *Notice) TrStr() string

TrStr returns a translation format string.

type NoticeType added in v0.5.5

type NoticeType int
const (
	NOTICE_REPOSITORY NoticeType = iota + 1
)

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

func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error)

GetOrgUsersByOrgID returns all organization-user relations by organization ID.

type PAMConfig added in v0.6.3

type PAMConfig struct {
	ServiceName string // PAM service (e.g. system-auth)
}

func (*PAMConfig) FromDB added in v0.6.3

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

func (*PAMConfig) ToDB added in v0.6.3

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

type ProtectBranch added in v0.10.1

type ProtectBranch struct {
	ID                 int64
	RepoID             int64  `xorm:"UNIQUE(protect_branch)"`
	Name               string `xorm:"UNIQUE(protect_branch)"`
	Protected          bool
	RequirePullRequest bool
	EnableWhitelist    bool
	WhitelistUserIDs   string `xorm:"TEXT"`
	WhitelistTeamIDs   string `xorm:"TEXT"`
}

ProtectBranch contains options of a protected branch.

func GetProtectBranchOfRepoByName added in v0.10.1

func GetProtectBranchOfRepoByName(repoID int64, name string) (*ProtectBranch, error)

GetProtectBranchOfRepoByName returns *ProtectBranch by branch name in given repostiory.

func GetProtectBranchesByRepoID added in v0.10.1

func GetProtectBranchesByRepoID(repoID int64) ([]*ProtectBranch, error)

GetProtectBranchesByRepoID returns a list of *ProtectBranch in given repostiory.

type ProtectBranchWhitelist added in v0.10.1

type ProtectBranchWhitelist struct {
	ID              int64
	ProtectBranchID int64
	RepoID          int64  `xorm:"UNIQUE(protect_branch_whitelist)"`
	Name            string `xorm:"UNIQUE(protect_branch_whitelist)"`
	UserID          int64  `xorm:"UNIQUE(protect_branch_whitelist)"`
}

type PublicKey

type PublicKey struct {
	ID          int64
	OwnerID     int64      `xorm:"INDEX NOT NULL"`
	Name        string     `xorm:"NOT NULL"`
	Fingerprint string     `xorm:"NOT NULL"`
	Content     string     `xorm:"TEXT NOT NULL"`
	Mode        AccessMode `xorm:"NOT NULL DEFAULT 2"`
	Type        KeyType    `xorm:"NOT NULL DEFAULT 1"`

	Created           time.Time `xorm:"-" json:"-"`
	CreatedUnix       int64
	Updated           time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
	UpdatedUnix       int64
	HasRecentActivity bool `xorm:"-" json:"-"`
	HasUsed           bool `xorm:"-" json:"-"`
}

PublicKey represents a user or deploy SSH public key.

func AddPublicKey

func AddPublicKey(ownerID int64, name, content string) (*PublicKey, error)

AddPublicKey adds new public key to database and authorized_keys file.

func GetPublicKeyByID added in v0.6.5

func GetPublicKeyByID(keyID int64) (*PublicKey, error)

GetPublicKeyByID returns public key by given ID.

func ListPublicKeys added in v0.5.8

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

ListPublicKeys returns a list of public keys belongs to given user.

func SearchPublicKeyByContent added in v0.7.6

func SearchPublicKeyByContent(content string) (*PublicKey, error)

SearchPublicKeyByContent searches content as prefix (leak e-mail part) and returns public key found.

func (*PublicKey) AfterSet added in v0.6.5

func (k *PublicKey) AfterSet(colName string, _ xorm.Cell)

func (*PublicKey) AuthorizedString added in v0.9.60

func (k *PublicKey) AuthorizedString() string

AuthorizedString returns formatted public key string for authorized_keys file.

func (*PublicKey) BeforeInsert added in v0.9.13

func (k *PublicKey) BeforeInsert()

func (*PublicKey) BeforeUpdate added in v0.9.13

func (k *PublicKey) BeforeUpdate()

func (*PublicKey) IsDeployKey added in v0.9.141

func (k *PublicKey) IsDeployKey() bool

IsDeployKey returns true if the public key is used as deploy key.

func (*PublicKey) OmitEmail added in v0.5.9

func (k *PublicKey) OmitEmail() string

OmitEmail returns content of public key without email address.

type PullRequest added in v0.6.9

type PullRequest struct {
	ID     int64
	Type   PullRequestType
	Status PullRequestStatus

	IssueID int64  `xorm:"INDEX"`
	Issue   *Issue `xorm:"-" json:"-"`
	Index   int64

	HeadRepoID   int64
	HeadRepo     *Repository `xorm:"-" json:"-"`
	BaseRepoID   int64
	BaseRepo     *Repository `xorm:"-" json:"-"`
	HeadUserName string
	HeadBranch   string
	BaseBranch   string
	MergeBase    string `xorm:"VARCHAR(40)"`

	HasMerged      bool
	MergedCommitID string `xorm:"VARCHAR(40)"`
	MergerID       int64
	Merger         *User     `xorm:"-" json:"-"`
	Merged         time.Time `xorm:"-" json:"-"`
	MergedUnix     int64
}

PullRequest represents relation between pull request and repositories.

func GetPullRequestByID added in v0.7.0

func GetPullRequestByID(id int64) (*PullRequest, error)

GetPullRequestByID returns a pull request by given ID.

func GetPullRequestByIssueID added in v0.7.0

func GetPullRequestByIssueID(issueID int64) (*PullRequest, error)

GetPullRequestByIssueID returns pull request by given issue ID.

func GetUnmergedPullRequest added in v0.6.9

func GetUnmergedPullRequest(headRepoID, baseRepoID int64, headBranch, baseBranch string) (*PullRequest, error)

GetUnmergedPullRequest returnss a pull request that is open and has not been merged by given head/base and repo/branch.

func GetUnmergedPullRequestsByBaseInfo added in v0.7.0

func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequest, error)

GetUnmergedPullRequestsByBaseInfo returnss all pull requests that are open and has not been merged by given base information (repo and branch).

func GetUnmergedPullRequestsByHeadInfo added in v0.7.0

func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequest, error)

GetUnmergedPullRequestsByHeadInfo returnss all pull requests that are open and has not been merged by given head information (repo and branch).

func (*PullRequest) APIFormat added in v0.9.97

func (pr *PullRequest) APIFormat() *api.PullRequest

This method assumes following fields have been assigned with valid values: Required - Issue, BaseRepo Optional - HeadRepo, Merger

func (*PullRequest) AddToTaskQueue added in v0.7.0

func (pr *PullRequest) AddToTaskQueue()

AddToTaskQueue adds itself to pull request test task queue.

func (*PullRequest) AfterSet added in v0.6.9

func (pr *PullRequest) AfterSet(colName string, _ xorm.Cell)

Note: don't try to get Issue because will end up recursive querying.

func (*PullRequest) BeforeUpdate added in v0.9.13

func (pr *PullRequest) BeforeUpdate()

func (*PullRequest) CanAutoMerge added in v0.6.9

func (pr *PullRequest) CanAutoMerge() bool

CanAutoMerge returns true if this pull request can be merged automatically.

func (*PullRequest) IsChecking added in v0.7.0

func (pr *PullRequest) IsChecking() bool

IsChecking returns true if this pull request is still checking conflict.

func (*PullRequest) LoadAttributes added in v0.9.97

func (pr *PullRequest) LoadAttributes() error

func (*PullRequest) LoadIssue added in v0.9.97

func (pr *PullRequest) LoadIssue() (err error)

func (*PullRequest) Merge added in v0.6.9

func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle, commitDescription string) (err error)

Merge merges pull request to base repository. FIXME: add repoWorkingPull make sure two merges does not happen at same time.

func (*PullRequest) PushToBaseRepo added in v0.8.43

func (pr *PullRequest) PushToBaseRepo() (err error)

PushToBaseRepo pushes commits from branches of head repository to corresponding branches of base repository. FIXME: Only push branches that are actually updates?

func (*PullRequest) Update added in v0.7.0

func (pr *PullRequest) Update() error

Update updates all fields of pull request.

func (*PullRequest) UpdateCols added in v0.7.0

func (pr *PullRequest) UpdateCols(cols ...string) error

Update updates specific fields of pull request.

func (*PullRequest) UpdatePatch added in v0.7.0

func (pr *PullRequest) UpdatePatch() (err error)

UpdatePatch generates and saves a new patch.

type PullRequestList added in v0.9.97

type PullRequestList []*PullRequest

func (PullRequestList) LoadAttributes added in v0.9.97

func (prs PullRequestList) LoadAttributes() error

type PullRequestStatus added in v0.7.0

type PullRequestStatus int
const (
	PULL_REQUEST_STATUS_CONFLICT PullRequestStatus = iota
	PULL_REQUEST_STATUS_CHECKING
	PULL_REQUEST_STATUS_MERGEABLE
)

type PullRequestType added in v0.6.9

type PullRequestType int
const (
	PULL_REQUEST_GOGS PullRequestType = iota
	PLLL_ERQUEST_GIT
)

type PushCommit added in v0.7.19

type PushCommit struct {
	Sha1           string
	Message        string
	AuthorEmail    string
	AuthorName     string
	CommitterEmail string
	CommitterName  string
	Timestamp      time.Time
}

func CommitToPushCommit added in v0.9.97

func CommitToPushCommit(commit *git.Commit) *PushCommit

CommitToPushCommit transforms a git.Commit to PushCommit type.

type PushCommits added in v0.7.19

type PushCommits struct {
	Len        int
	Commits    []*PushCommit
	CompareURL string
	// contains filtered or unexported fields
}

func ListToPushCommits added in v0.8.0

func ListToPushCommits(l *list.List) *PushCommits

func NewPushCommits added in v0.7.19

func NewPushCommits() *PushCommits
func (push *PushCommits) AvatarLink(email string) string

AvatarLink tries to match user in database with e-mail in order to show custom avatar, and falls back to general avatar link.

func (*PushCommits) ToApiPayloadCommits added in v0.8.0

func (pc *PushCommits) ToApiPayloadCommits(repoPath, repoURL string) ([]*api.PayloadCommit, error)

type PushUpdateOptions added in v0.8.43

type PushUpdateOptions struct {
	OldCommitID  string
	NewCommitID  string
	RefFullName  string
	PusherID     int64
	PusherName   string
	RepoUserName string
	RepoName     string
}

type Release added in v0.3.0

type Release struct {
	ID               int64
	RepoID           int64
	Repo             *Repository `xorm:"-" json:"-"`
	PublisherID      int64
	Publisher        *User `xorm:"-" json:"-"`
	TagName          string
	LowerTagName     string
	Target           string
	Title            string
	Sha1             string `xorm:"VARCHAR(40)"`
	NumCommits       int64
	NumCommitsBehind int64  `xorm:"-" json:"-"`
	Note             string `xorm:"TEXT"`
	IsDraft          bool   `xorm:"NOT NULL DEFAULT false"`
	IsPrerelease     bool

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64

	Attachments []*Attachment `xorm:"-" json:"-"`
}

Release represents a release of repository.

func GetDraftReleasesByRepoID added in v0.10.18

func GetDraftReleasesByRepoID(repoID int64) ([]*Release, error)

GetDraftReleasesByRepoID returns all draft releases of repository.

func GetPublishedReleasesByRepoID added in v0.10.18

func GetPublishedReleasesByRepoID(repoID int64, matches ...string) ([]*Release, error)

GetPublishedReleasesByRepoID returns a list of published releases of repository. If matches is not empty, only published releases in matches will be returned. In any case, drafts won't be returned by this function.

func GetRelease added in v0.5.0

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

GetRelease returns release by given ID.

func GetReleaseByID added in v0.7.19

func GetReleaseByID(id int64) (*Release, error)

GetReleaseByID returns release with given ID.

func (*Release) APIFormat added in v0.10.18

func (r *Release) APIFormat() *api.Release

This method assumes some fields assigned with values: Required - Publisher

func (*Release) AfterSet added in v0.6.9

func (r *Release) AfterSet(colName string, _ xorm.Cell)

func (*Release) BeforeInsert added in v0.9.13

func (r *Release) BeforeInsert()

func (*Release) LoadAttributes added in v0.10.18

func (r *Release) LoadAttributes() error

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:"-" json:"-"`
	LowerName       string `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name            string `xorm:"INDEX NOT NULL"`
	Description     string `xorm:"VARCHAR(512)"`
	Website         string
	DefaultBranch   string
	Size            int64 `xorm:"NOT NULL DEFAULT 0"`
	UseCustomAvatar bool

	// Counters
	NumWatches          int
	NumStars            int
	NumForks            int
	NumIssues           int
	NumClosedIssues     int
	NumOpenIssues       int `xorm:"-" json:"-"`
	NumPulls            int
	NumClosedPulls      int
	NumOpenPulls        int `xorm:"-" json:"-"`
	NumMilestones       int `xorm:"NOT NULL DEFAULT 0"`
	NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
	NumOpenMilestones   int `xorm:"-" json:"-"`
	NumTags             int `xorm:"-" json:"-"`

	IsPrivate bool
	IsBare    bool

	IsMirror bool
	*Mirror  `xorm:"-" json:"-"`

	// Advanced settings
	EnableWiki            bool `xorm:"NOT NULL DEFAULT true"`
	AllowPublicWiki       bool
	EnableExternalWiki    bool
	ExternalWikiURL       string
	EnableIssues          bool `xorm:"NOT NULL DEFAULT true"`
	AllowPublicIssues     bool
	EnableExternalTracker bool
	ExternalTrackerURL    string
	ExternalTrackerFormat string
	ExternalTrackerStyle  string
	ExternalMetas         map[string]string `xorm:"-" json:"-"`
	EnablePulls           bool              `xorm:"NOT NULL DEFAULT true"`
	PullsIgnoreWhitespace bool              `xorm:"NOT NULL DEFAULT false"`
	PullsAllowRebase      bool              `xorm:"NOT NULL DEFAULT false"`

	IsFork   bool `xorm:"NOT NULL DEFAULT false"`
	ForkID   int64
	BaseRepo *Repository `xorm:"-" json:"-"`

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
	Updated     time.Time `xorm:"-" json:"-"`
	UpdatedUnix int64
}

Repository contains information of a repository.

func CleanUpMigrateInfo added in v0.8.43

func CleanUpMigrateInfo(repo *Repository) (*Repository, error)

Finish migrating repository and/or wiki with things that don't need to be done for mirrors.

func CreateRepository

func CreateRepository(doer, owner *User, opts CreateRepoOptions) (_ *Repository, err error)

CreateRepository creates a repository for given user or organization.

func ForkRepository

func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string) (_ *Repository, err error)

ForkRepository creates a fork of target repository under another user domain.

func GetRecentUpdatedRepositories added in v0.3.0

func GetRecentUpdatedRepositories(page, pageSize int) (repos []*Repository, err error)

GetRecentUpdatedRepositories returns the list of repositories that are recently updated.

func GetRepositoriesByForkID added in v0.6.9

func GetRepositoriesByForkID(forkID int64) ([]*Repository, error)

GetRepositoriesByForkID returns all repositories with given fork ID.

func GetRepositoryByID added in v0.6.5

func GetRepositoryByID(id int64) (*Repository, error)

GetRepositoryByID returns the repository by given id if exists.

func GetRepositoryByName

func GetRepositoryByName(ownerID int64, name 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 GetUserAndCollaborativeRepositories added in v0.11.4

func GetUserAndCollaborativeRepositories(userID int64) ([]*Repository, error)

GetUserAndCollaborativeRepositories returns list of repositories the user owns and collaborates.

func GetUserMirrorRepositories added in v0.9.60

func GetUserMirrorRepositories(userID int64) ([]*Repository, error)

GetUserRepositories returns a list of mirror repositories of given user.

func GetUserRepositories added in v0.9.60

func GetUserRepositories(opts *UserRepoOptions) ([]*Repository, error)

GetUserRepositories returns a list of repositories of given user.

func HasForkedRepo added in v0.6.5

func HasForkedRepo(ownerID, repoID int64) (*Repository, bool, error)

HasForkedRepo checks if given user has already forked a repository. When user has already forked, it returns true along with the repository.

func MigrateRepository added in v0.3.0

func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository, error)

MigrateRepository migrates a existing repository from other project hosting.

func Repositories added in v0.9.13

func Repositories(page, pageSize int) (_ []*Repository, err error)

func RepositoriesWithUsers added in v0.6.15

func RepositoriesWithUsers(page, pageSize int) (_ []*Repository, err error)

RepositoriesWithUsers returns number of repos in given page.

func SearchRepositoryByName added in v0.5.0

func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, count int64, err error)

SearchRepositoryByName takes keyword and part of repository name to search, it returns results in given range and number of total results.

func (*Repository) APIFormat added in v0.9.97

func (repo *Repository) APIFormat(permission *api.Permission, user ...*User) *api.Repository

This method assumes following fields have been assigned with valid values: Required - BaseRepo (if fork) Arguments that are allowed to be nil: permission

func (*Repository) AddCollaborator added in v0.6.0

func (repo *Repository) AddCollaborator(u *User) error

AddCollaborator adds new collaboration to a repository with default access mode.

func (*Repository) AddWikiPage added in v0.7.33

func (repo *Repository) AddWikiPage(doer *User, title, content, message string) error

func (*Repository) AfterSet added in v0.6.9

func (repo *Repository) AfterSet(colName string, _ xorm.Cell)

func (*Repository) AllowsPulls added in v0.8.43

func (repo *Repository) AllowsPulls() bool

AllowPulls returns true if repository meets the requirements of accepting pulls and has them enabled.

func (repo *Repository) AvatarLink() string

AvatarLink returns repository avatar absolute link.

func (*Repository) BeforeInsert added in v0.9.13

func (repo *Repository) BeforeInsert()

func (*Repository) BeforeUpdate added in v0.9.13

func (repo *Repository) BeforeUpdate()

func (*Repository) CanBeForked added in v0.6.15

func (repo *Repository) CanBeForked() bool

CanBeForked returns true if repository meets the requirements of being forked.

func (*Repository) CanEnableEditor added in v0.9.97

func (repo *Repository) CanEnableEditor() bool

CanEnableEditor returns true if repository meets the requirements of web editor.

func (*Repository) CanEnablePulls added in v0.8.43

func (repo *Repository) CanEnablePulls() bool

CanEnablePulls returns true if repository meets the requirements of accepting pulls.

func (*Repository) CanGuestViewIssues added in v0.11.4

func (repo *Repository) CanGuestViewIssues() bool

func (*Repository) CanGuestViewWiki added in v0.11.4

func (repo *Repository) CanGuestViewWiki() bool

func (*Repository) ChangeCollaborationAccessMode added in v0.9.0

func (repo *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessMode) error

ChangeCollaborationAccessMode sets new access mode for the collaboration.

func (*Repository) CheckoutNewBranch added in v0.9.97

func (repo *Repository) CheckoutNewBranch(oldBranch, newBranch string) error
func (repo *Repository) CloneLink() (cl *CloneLink)

CloneLink returns clone URLs of repository.

func (*Repository) ComposeCompareURL added in v0.8.0

func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string

func (*Repository) ComposeMetas added in v0.7.33

func (repo *Repository) ComposeMetas() map[string]string

ComposeMetas composes a map of metas for rendering external issue tracker URL.

func (*Repository) CreateNewBranch added in v0.9.97

func (repo *Repository) CreateNewBranch(doer *User, oldBranchName, branchName string) (err error)

func (*Repository) CustomAvatarPath added in v0.11.66

func (repo *Repository) CustomAvatarPath() string

CustomAvatarPath returns repository custom avatar file path.

func (*Repository) DeleteAvatar added in v0.11.66

func (repo *Repository) DeleteAvatar() error

DeleteAvatar deletes the repository custom avatar.

func (*Repository) DeleteCollaboration added in v0.9.0

func (repo *Repository) DeleteCollaboration(userID int64) error

func (*Repository) DeleteRepoFile added in v0.9.97

func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (err error)

func (*Repository) DeleteWiki added in v0.9.0

func (repo *Repository) DeleteWiki()

DeleteWiki removes the actual and local copy of repository wiki.

func (*Repository) DeleteWikiPage added in v0.9.0

func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error)

func (*Repository) DiscardLocalRepoBranchChanges added in v0.9.97

func (repo *Repository) DiscardLocalRepoBranchChanges(branch string) error

func (*Repository) EditWikiPage added in v0.7.33

func (repo *Repository) EditWikiPage(doer *User, oldTitle, title, content, message string) error

func (*Repository) FullName added in v0.9.97

func (repo *Repository) FullName() string

func (*Repository) GetAssigneeByID added in v0.6.5

func (repo *Repository) GetAssigneeByID(userID int64) (*User, error)

GetAssigneeByID returns the user that has write access of repository by given ID.

func (*Repository) GetAssignees added in v0.6.5

func (repo *Repository) GetAssignees() (_ []*User, err error)

GetAssignees returns all users that have read access and can be assigned to issues of the repository,

func (*Repository) GetBranch added in v0.8.43

func (repo *Repository) GetBranch(br string) (*Branch, error)

func (*Repository) GetBranches added in v0.8.43

func (repo *Repository) GetBranches() ([]*Branch, error)

func (*Repository) GetCollaborators added in v0.6.0

func (repo *Repository) GetCollaborators() ([]*Collaborator, error)

GetCollaborators returns the collaborators for a repository

func (*Repository) GetDiffPreview added in v0.9.97

func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *Diff, err error)

GetDiffPreview produces and returns diff result of a file which is not yet committed.

func (*Repository) GetForks added in v0.7.0

func (repo *Repository) GetForks() ([]*Repository, error)

func (*Repository) GetMilestoneByID added in v0.6.5

func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error)

GetMilestoneByID returns the milestone belongs to repository by given ID.

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() error

func (*Repository) GetStargazers added in v0.7.19

func (repo *Repository) GetStargazers(page int) ([]*User, error)

func (*Repository) GetWatchers added in v0.7.0

func (repo *Repository) GetWatchers(page int) ([]*User, error)

Repository.GetWatchers returns range of users watching given repository.

func (*Repository) GetWriters added in v0.10.1

func (repo *Repository) GetWriters() (_ []*User, err error)

GetWriters returns all users that have write access to the repository.

func (*Repository) GitConfigPath added in v0.8.0

func (repo *Repository) GitConfigPath() string

func (*Repository) HTMLURL added in v0.9.97

func (repo *Repository) HTMLURL() string

func (*Repository) HasAccess added in v0.5.5

func (repo *Repository) HasAccess(userID int64) bool

func (*Repository) HasWiki added in v0.7.33

func (repo *Repository) HasWiki() bool

HasWiki returns true if repository has wiki.

func (*Repository) InitWiki added in v0.7.33

func (repo *Repository) InitWiki() error

InitWiki initializes a wiki for repository, it does nothing when repository already has wiki.

func (*Repository) IsBranchRequirePullRequest added in v0.10.1

func (repo *Repository) IsBranchRequirePullRequest(name string) bool

func (*Repository) IsCollaborator added in v0.10.1

func (repo *Repository) IsCollaborator(userID int64) bool

func (*Repository) IsOwnedBy added in v0.5.8

func (repo *Repository) IsOwnedBy(userID int64) bool

func (*Repository) IsPartialPublic added in v0.11.4

func (repo *Repository) IsPartialPublic() bool

IsPartialPublic returns true if repository is public or allow public access to wiki or issues.

func (*Repository) IssueStats added in v0.6.9

func (repo *Repository) IssueStats(userID int64, filterMode FilterMode, isPull bool) (int64, int64)

IssueStats returns number of open and closed repository issues by given filter mode.

func (repo *Repository) Link() string

func (*Repository) LoadAttributes added in v0.11.4

func (repo *Repository) LoadAttributes() error

func (*Repository) LocalCopyPath added in v0.7.0

func (repo *Repository) LocalCopyPath() string

func (*Repository) LocalWikiPath added in v0.7.33

func (repo *Repository) LocalWikiPath() string

func (*Repository) MustOwner added in v0.7.33

func (repo *Repository) MustOwner() *User

MustOwner always returns a valid *User object to avoid conceptually impossible error handling. It creates a fake object that contains error deftail when error occurs.

func (*Repository) NextIssueIndex added in v0.6.9

func (repo *Repository) NextIssueIndex() int64

FIXME: should have a mutex to prevent producing same index for two issues that are created closely enough.

func (*Repository) PatchPath added in v0.7.0

func (repo *Repository) PatchPath(index int64) (string, error)

PatchPath returns corresponding patch file path of repository by given issue ID.

func (*Repository) RecalculateAccesses added in v0.6.0

func (repo *Repository) RecalculateAccesses() error

RecalculateAccesses recalculates all accesses for repository.

func (repo *Repository) RelAvatarLink() string

RelAvatarLink returns relative avatar link to the site domain, which includes app sub-url as prefix. Since Gravatar support not needed here - just check for image path.

func (repo *Repository) RelLink() string

func (*Repository) RepoPath added in v0.5.8

func (repo *Repository) RepoPath() string

func (*Repository) SavePatch added in v0.7.0

func (repo *Repository) SavePatch(index int64, patch []byte) error

SavePatch saves patch data to corresponding location by given issue ID.

func (*Repository) UpdateLocalCopyBranch added in v0.9.97

func (repo *Repository) UpdateLocalCopyBranch(branch string) error

UpdateLocalCopyBranch makes sure local copy of repository in given branch is up-to-date.

func (*Repository) UpdateLocalWiki added in v0.7.33

func (repo *Repository) UpdateLocalWiki() error

UpdateLocalWiki makes sure the local copy of repository wiki is up-to-date.

func (*Repository) UpdateRepoFile added in v0.9.97

func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error)

UpdateRepoFile adds or updates a file in repository.

func (*Repository) UpdateSize added in v0.10.18

func (repo *Repository) UpdateSize() error

func (*Repository) UploadAvatar added in v0.11.66

func (repo *Repository) UploadAvatar(data []byte) error

UploadAvatar saves custom avatar for repository. FIXME: split uploads to different subdirs in case we have massive number of repositories.

func (*Repository) UploadRepoFiles added in v0.9.97

func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions) (err error)
func (repo *Repository) WikiCloneLink() (cl *CloneLink)

WikiCloneLink returns clone URLs of repository wiki.

func (*Repository) WikiPath added in v0.7.33

func (repo *Repository) WikiPath() string

type RepositoryList added in v0.9.60

type RepositoryList []*Repository

func (RepositoryList) LoadAttributes added in v0.9.60

func (repos RepositoryList) LoadAttributes() error

type SMTPConfig added in v0.4.0

type SMTPConfig struct {
	Auth           string
	Host           string
	Port           int
	AllowedDomains string `xorm:"TEXT"`
	TLS            bool   `ini:"tls"`
	SkipVerify     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 SearchRepoOptions added in v0.9.13

type SearchRepoOptions struct {
	Keyword  string
	OwnerID  int64
	UserID   int64 // When set results will contain all public/private repositories user has access to
	OrderBy  string
	Private  bool // Include private repositories in results
	Page     int
	PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
}

type SearchUserOptions added in v0.9.13

type SearchUserOptions struct {
	Keyword  string
	Type     UserType
	OrderBy  string
	Page     int
	PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
}

type SlackAttachment added in v0.5.0

type SlackAttachment struct {
	Fallback string `json:"fallback"`
	Color    string `json:"color"`
	Title    string `json:"title"`
	Text     string `json:"text"`
}

type SlackMeta added in v0.6.9

type SlackMeta struct {
	Channel  string `json:"channel"`
	Username string `json:"username"`
	IconURL  string `json:"icon_url"`
	Color    string `json:"color"`
}

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 api.Payloader, event HookEventType, meta string) (payload *SlackPayload, err error)

func (*SlackPayload) JSONPayload added in v0.6.9

func (p *SlackPayload) JSONPayload() ([]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   AccessMode
	Repos       []*Repository `xorm:"-" json:"-"`
	Members     []*User       `xorm:"-" json:"-"`
	NumRepos    int
	NumMembers  int
}

Team represents a organization team.

func GetTeamByID added in v0.9.46

func GetTeamByID(teamID int64) (*Team, error)

GetTeamByID returns team by given ID.

func GetTeamOfOrgByName added in v0.10.1

func GetTeamOfOrgByName(orgID int64, name string) (*Team, error)

GetTeamOfOrgByName returns team by given team name and organization.

func GetTeamsByOrgID added in v0.10.1

func GetTeamsByOrgID(orgID int64) ([]*Team, error)

GetTeamsByOrgID returns all teams belong to given organization.

func GetTeamsHaveAccessToRepo added in v0.10.1

func GetTeamsHaveAccessToRepo(orgID, repoID int64, mode AccessMode) ([]*Team, error)

GetTeamsHaveAccessToRepo returns all teams in an organization that have given access level to the repository.

func GetUserTeams added in v0.5.0

func GetUserTeams(orgID, userID int64) ([]*Team, error)

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

func (*Team) AddMember added in v0.5.0

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

AddMember adds new membership of the team to the organization, the user will have membership to the organization automatically when needed.

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) AfterSet added in v0.9.141

func (t *Team) AfterSet(colName string, _ xorm.Cell)

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) HasRepository added in v0.6.0

func (t *Team) HasRepository(repoID int64) bool

HasRepository returns true if given repository belong to team.

func (*Team) HasWriteAccess added in v0.10.1

func (t *Team) HasWriteAccess() bool

HasWriteAccess returns true if team has at least write level access mode.

func (*Team) IsMember added in v0.5.0

func (t *Team) IsMember(userID 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 TeamRepo added in v0.6.0

type TeamRepo struct {
	ID     int64
	OrgID  int64 `xorm:"INDEX"`
	TeamID int64 `xorm:"UNIQUE(s)"`
	RepoID int64 `xorm:"UNIQUE(s)"`
}

TeamRepo represents an team-repository relation.

type TeamUser added in v0.5.0

type TeamUser struct {
	ID     int64
	OrgID  int64 `xorm:"INDEX"`
	TeamID int64 `xorm:"UNIQUE(s)"`
	UID    int64 `xorm:"UNIQUE(s)"`
}

TeamUser represents an team-user relation.

type TwoFactor added in v0.11.19

type TwoFactor struct {
	ID          int64
	UserID      int64 `xorm:"UNIQUE"`
	Secret      string
	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
}

TwoFactor represents a two-factor authentication token.

func GetTwoFactorByUserID added in v0.11.19

func GetTwoFactorByUserID(userID int64) (*TwoFactor, error)

GetTwoFactorByUserID returns two-factor authentication token of given user.

func (*TwoFactor) AfterSet added in v0.11.19

func (t *TwoFactor) AfterSet(colName string, _ xorm.Cell)

func (*TwoFactor) BeforeInsert added in v0.11.19

func (t *TwoFactor) BeforeInsert()

func (*TwoFactor) ValidateTOTP added in v0.11.19

func (t *TwoFactor) ValidateTOTP(passcode string) (bool, error)

ValidateTOTP returns true if given passcode is valid for two-factor authentication token. It also returns possible validation error.

type TwoFactorRecoveryCode added in v0.11.19

type TwoFactorRecoveryCode struct {
	ID     int64
	UserID int64
	Code   string `xorm:"VARCHAR(11)"`
	IsUsed bool
}

TwoFactorRecoveryCode represents a two-factor authentication recovery code.

func GetRecoveryCodesByUserID added in v0.11.19

func GetRecoveryCodesByUserID(userID int64) ([]*TwoFactorRecoveryCode, error)

GetRecoveryCodesByUserID returns all recovery codes of given user.

type UpdateRepoFileOptions added in v0.9.97

type UpdateRepoFileOptions struct {
	LastCommitID string
	OldBranch    string
	NewBranch    string
	OldTreeName  string
	NewTreeName  string
	Message      string
	Content      string
	IsNewFile    bool
}

type Upload added in v0.9.97

type Upload struct {
	ID   int64
	UUID string `xorm:"uuid UNIQUE"`
	Name string
}

Upload represent a uploaded file to a repo to be deleted when moved

func GetUploadByUUID added in v0.9.97

func GetUploadByUUID(uuid string) (*Upload, error)

func GetUploadsByUUIDs added in v0.9.97

func GetUploadsByUUIDs(uuids []string) ([]*Upload, error)

func NewUpload added in v0.9.97

func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err error)

NewUpload creates a new upload object.

func (*Upload) LocalPath added in v0.9.97

func (upload *Upload) LocalPath() string

LocalPath returns where uploads are temporarily stored in local file system.

type UploadRepoFileOptions added in v0.9.97

type UploadRepoFileOptions struct {
	LastCommitID string
	OldBranch    string
	NewBranch    string
	TreePath     string
	Message      string
	Files        []string // In UUID format
}

type User

type User struct {
	ID        int64
	LowerName string `xorm:"UNIQUE NOT NULL"`
	Name      string `xorm:"UNIQUE NOT NULL"`
	FullName  string
	// Email is the primary email address (to be used for communication)
	Email       string `xorm:"NOT NULL"`
	Passwd      string `xorm:"NOT NULL"`
	LoginType   LoginType
	LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
	LoginName   string
	Type        UserType
	OwnedOrgs   []*User       `xorm:"-" json:"-"`
	Orgs        []*User       `xorm:"-" json:"-"`
	Repos       []*Repository `xorm:"-" json:"-"`
	Location    string
	Website     string
	Rands       string `xorm:"VARCHAR(10)"`
	Salt        string `xorm:"VARCHAR(10)"`

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
	Updated     time.Time `xorm:"-" json:"-"`
	UpdatedUnix int64

	// Remember visibility choice for convenience, true for private
	LastRepoVisibility bool
	// Maximum repository creation limit, -1 means use gloabl default
	MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"`

	// Permissions
	IsActive         bool // Activate primary email
	IsAdmin          bool
	AllowGitHook     bool
	AllowImportLocal bool // Allow migrate repository by local path
	ProhibitLogin    bool

	// Avatar
	Avatar          string `xorm:"VARCHAR(2048) NOT NULL"`
	AvatarEmail     string `xorm:"NOT NULL"`
	UseCustomAvatar bool

	// Counters
	NumFollowers int
	NumFollowing int `xorm:"NOT NULL DEFAULT 0"`
	NumStars     int
	NumRepos     int

	// For organization
	Description string
	NumTeams    int
	NumMembers  int
	Teams       []*Team `xorm:"-" json:"-"`
	Members     []*User `xorm:"-" json:"-"`
}

User represents the object of individual and member of organization.

func GetAssigneeByID added in v0.6.5

func GetAssigneeByID(repo *Repository, userID int64) (*User, error)

GetAssigneeByID returns the user with write access of repository by given ID.

func GetOrgByName added in v0.5.9

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

GetOrgByName returns organization by given name.

func GetOrgsByUserID added in v0.8.43

func GetOrgsByUserID(userID int64, showAll bool) ([]*User, error)

GetOrgsByUserID returns a list of organizations that the given user ID has joined.

func GetOrgsByUserIDDesc added in v0.8.43

func GetOrgsByUserIDDesc(userID int64, desc string, showAll bool) ([]*User, error)

GetOrgsByUserIDDesc returns a list of organizations that the given user ID has joined, ordered descending by the given condition.

func GetOwnedOrgsByUserID added in v0.6.15

func GetOwnedOrgsByUserID(userID int64) ([]*User, error)

GetOwnedOrgsByUserID returns a list of organizations are owned by given user ID.

func GetOwnedOrgsByUserIDDesc added in v0.6.15

func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error)

GetOwnedOrganizationsByUserIDDesc returns a list of organizations are owned by given user ID, ordered descending by the given condition.

func GetParticipantsByIssueID added in v0.10.18

func GetParticipantsByIssueID(issueID int64) ([]*User, error)

GetParticipantsByIssueID returns all users who are participated in comments of an issue.

func GetTeamMembers added in v0.5.0

func GetTeamMembers(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 added in v0.6.5

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

GetUserByID returns the user object by given ID if exists.

func GetUserByKeyID added in v0.7.0

func GetUserByKeyID(keyID int64) (*User, error)

func GetUserByName

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

GetUserByName returns a user by given name.

func LoginViaLDAP added in v0.9.97

func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoRegister bool) (*User, error)

LoginViaLDAP queries if login/password is valid against the LDAP directory pool, and create a local user if success when enabled.

func LoginViaPAM added in v0.9.97

func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error)

LoginViaPAM queries if login/password is valid against the PAM, and create a local user if success when enabled.

func LoginViaSMTP added in v0.9.97

func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPConfig, autoRegister bool) (*User, error)

LoginViaSMTP queries if login/password is valid against the SMTP, and create a local user if success when enabled.

func NewGhostUser added in v0.9.97

func NewGhostUser() *User

NewGhostUser creates and returns a fake user for someone who has deleted his/her account.

func Organizations added in v0.6.15

func Organizations(page, pageSize int) ([]*User, error)

Organizations returns number of organizations in given page.

func SearchUserByName added in v0.4.0

func SearchUserByName(opts *SearchUserOptions) (users []*User, _ int64, _ error)

SearchUserByName takes keyword and part of user name to search, it returns results in given range and number of total results.

func UserLogin added in v0.11.53

func UserLogin(username, password string, loginSourceID int64) (*User, error)

UserLogin validates user name and password via given login source ID. If the loginSourceID is negative, it will abort login process if user is not found.

func Users added in v0.6.15

func Users(page, pageSize int) ([]*User, error)

Users returns number of users in given page.

func ValidateCommitWithEmail added in v0.5.5

func ValidateCommitWithEmail(c *git.Commit) *User

ValidateCommitWithEmail chceck if author's e-mail of commit is corresponsind to a user.

func VerifyUserActiveCode

func VerifyUserActiveCode(code string) (user *User)

verify active code when active account

func (*User) APIFormat added in v0.9.97

func (u *User) APIFormat() *api.User

func (*User) AddMember added in v0.5.0

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

AddMember adds new member to organization.

func (*User) AfterSet added in v0.6.9

func (u *User) AfterSet(colName string, _ xorm.Cell)
func (u *User) AvatarLink() string

AvatarLink returns user avatar absolute link.

func (*User) BeforeInsert added in v0.9.13

func (u *User) BeforeInsert()

func (*User) BeforeUpdate added in v0.8.0

func (u *User) BeforeUpdate()

func (*User) CanCreateOrganization added in v0.9.141

func (u *User) CanCreateOrganization() bool

func (*User) CanCreateRepo added in v0.8.0

func (u *User) CanCreateRepo() bool

func (*User) CanEditGitHook added in v0.7.0

func (u *User) CanEditGitHook() bool

CanEditGitHook returns true if user can edit Git hooks.

func (*User) CanImportLocal added in v0.7.0

func (u *User) CanImportLocal() bool

CanImportLocal returns true if user can migrate repository by local path.

func (*User) CustomAvatarPath added in v0.5.9

func (u *User) CustomAvatarPath() string

CustomAvatarPath returns user custom avatar file path.

func (u *User) DashboardLink() string

DashboardLink returns the user dashboard page link.

func (*User) DeleteAvatar added in v0.9.0

func (u *User) DeleteAvatar() error

DeleteAvatar deletes the user's custom avatar.

func (*User) DisplayName added in v0.6.9

func (u *User) DisplayName() string

DisplayName returns full name if it's not empty, returns username otherwise.

func (*User) EncodePasswd

func (u *User) EncodePasswd()

EncodePasswd encodes password to safe format.

func (*User) GenerateActivateCode added in v0.6.15

func (u *User) GenerateActivateCode() string

GenerateActivateCode generates an activate code based on user information.

func (*User) GenerateEmailActivateCode added in v0.6.15

func (u *User) GenerateEmailActivateCode(email string) string

GenerateEmailActivateCode generates an activate code based on user information and given e-mail.

func (*User) GenerateRandomAvatar added in v0.6.15

func (u *User) GenerateRandomAvatar() error

GenerateRandomAvatar generates a random avatar for user.

func (*User) GetAccessibleRepositories added in v0.6.0

func (user *User) GetAccessibleRepositories(limit int) (repos []*Repository, _ error)

GetAccessibleRepositories finds repositories which the user has access but does not own. If limit is smaller than 1 means returns all found results.

func (*User) GetFollowers added in v0.8.25

func (u *User) GetFollowers(page int) ([]*User, error)

User.GetFollwoers returns range of user's followers.

func (*User) GetFollowing added in v0.8.25

func (u *User) GetFollowing(page int) ([]*User, error)

GetFollowing returns range of user's following.

func (*User) GetMembers added in v0.5.0

func (org *User) GetMembers() error

GetMembers returns all members of organization.

func (*User) GetMirrorRepositories added in v0.9.60

func (u *User) GetMirrorRepositories() ([]*Repository, error)

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

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(showPrivate bool) error

GetOrganizations returns all organizations that user belongs to.

func (*User) GetOwnedOrganizations added in v0.6.15

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

GetOwnedOrganizations returns all organizations that user owns.

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(page, pageSize int) (err error)

GetRepositories returns repositories that user owns, including private repositories.

func (*User) GetRepositoryAccesses added in v0.7.19

func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error)

GetRepositoryAccesses finds all repositories with their access mode where a user has access but does not own.

func (*User) GetTeam added in v0.5.0

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

GetTeamOfOrgByName 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 (*User) GetUserMirrorRepositories added in v0.9.60

func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)

GetUserMirrorRepositories returns mirror repositories of the organization which the user has access to.

func (*User) GetUserRepositories added in v0.8.43

func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repository, int64, error)

GetUserRepositories returns a range of repositories in organization which the user has access to, and total number of records based on given condition.

func (*User) GetUserTeamIDs added in v0.9.60

func (org *User) GetUserTeamIDs(userID int64) ([]int64, error)

GetUserTeamIDs returns of all team IDs of the organization that user is memeber of.

func (*User) GetUserTeams added in v0.8.43

func (org *User) GetUserTeams(userID int64) ([]*Team, error)

GetTeams returns all teams that belong to organization, and that the user has joined.

func (*User) HTMLURL added in v0.9.141

func (u *User) HTMLURL() string

func (*User) HasForkedRepo added in v0.7.19

func (u *User) HasForkedRepo(repoID int64) bool

HasForkedRepo checks if user has already forked a repository with given ID.

func (u *User) HomeLink() string

HomeLink returns the user or organization home page link.

func (*User) IDStr added in v0.11.53

func (u *User) IDStr() string

IDStr returns string representation of user's ID.

func (*User) IsAdminOfRepo added in v0.6.5

func (u *User) IsAdminOfRepo(repo *Repository) bool

IsAdminOfRepo returns true if user has admin or higher access of repository.

func (*User) IsEnabledTwoFactor added in v0.11.19

func (u *User) IsEnabledTwoFactor() bool

IsEnabledTwoFactor returns true if user has enabled two-factor authentication.

func (*User) IsFollowing added in v0.8.25

func (u *User) IsFollowing(followID int64) bool

func (*User) IsLocal added in v0.8.0

func (u *User) IsLocal() bool

returns true if user login type is LOGIN_PLAIN.

func (*User) IsMailable added in v0.9.128

func (u *User) IsMailable() bool

IsMailable checks if a user is elegible to receive emails.

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

func (u *User) IsOrganization() bool

IsOrganization returns true if user is actually a organization.

func (*User) IsOwnedBy added in v0.5.9

func (org *User) IsOwnedBy(userID int64) bool

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

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) IsWriterOfRepo added in v0.9.0

func (u *User) IsWriterOfRepo(repo *Repository) bool

IsWriterOfRepo returns true if user has write access to given repository.

func (*User) MailResendCacheKey added in v0.11.53

func (u *User) MailResendCacheKey() string

MailResendCacheKey returns key used for cache mail resend.

func (*User) NewGitSig

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

NewGitSig generates and returns the signature of given user.

func (u *User) RelAvatarLink() string

RelAvatarLink returns relative avatar link to the site domain, which includes app sub-url as prefix. However, it is possible to return full URL if user enables Gravatar-like service.

func (*User) RemoveMember added in v0.5.0

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

RemoveMember removes member from organization.

func (*User) RemoveOrgRepo added in v0.6.0

func (org *User) RemoveOrgRepo(repoID int64) error

RemoveOrgRepo removes all team-repository relations of organization.

func (*User) RepoCreationNum added in v0.8.0

func (u *User) RepoCreationNum() int

func (*User) ShortName added in v0.7.19

func (u *User) ShortName(length int) string

func (*User) TeamsHaveAccessToRepo added in v0.10.1

func (org *User) TeamsHaveAccessToRepo(repoID int64, mode AccessMode) ([]*Team, error)

TeamsHaveAccessToRepo returns all teamsthat have given access level to the repository.

func (*User) TwoFactorCacheKey added in v0.11.53

func (u *User) TwoFactorCacheKey(passcode string) string

TwoFactorCacheKey returns key used for cache two factor passcode. e.g. TwoFactor_1_012664

func (*User) UploadAvatar added in v0.5.9

func (u *User) UploadAvatar(data []byte) error

UploadAvatar saves custom avatar for user. FIXME: split uploads to different subdirs in case we have massive number of users.

func (*User) ValidatePassword added in v0.6.3

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

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

type UserCommit added in v0.5.5

type UserCommit struct {
	User *User
	*git.Commit
}

UserCommit represents a commit with validation of user.

type UserRepoOptions added in v0.9.128

type UserRepoOptions struct {
	UserID   int64
	Private  bool
	Page     int
	PageSize int
}

type UserType added in v0.5.0

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

type Version added in v0.10.8

type Version struct {
	ID      int64
	Version int64
}

The version table. Should have only one row with id==1

type Watch

type Watch struct {
	ID     int64
	UserID int64 `xorm:"UNIQUE(watch)"`
	RepoID int64 `xorm:"UNIQUE(watch)"`
}

Watch is connection request for receiving repository notification.

func GetWatchers added in v0.4.0

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

GetWatchers returns all watchers of given repository.

type Webhook added in v0.4.0

type Webhook struct {
	ID           int64
	RepoID       int64
	OrgID        int64
	URL          string `xorm:"url TEXT"`
	ContentType  HookContentType
	Secret       string     `xorm:"TEXT"`
	Events       string     `xorm:"TEXT"`
	*HookEvent   `xorm:"-"` // LEGACY [1.0]: Cannot ignore JSON here, it breaks old backup archive
	IsSSL        bool       `xorm:"is_ssl"`
	IsActive     bool
	HookTaskType HookTaskType
	Meta         string     `xorm:"TEXT"` // store hook-specific attributes
	LastStatus   HookStatus // Last delivery status

	Created     time.Time `xorm:"-" json:"-"`
	CreatedUnix int64
	Updated     time.Time `xorm:"-" json:"-"`
	UpdatedUnix int64
}

Webhook represents a web hook object.

func GetWebhookByID added in v0.6.9

func GetWebhookByID(id int64) (*Webhook, error)

GetWebhookByID returns webhook by given ID. Use this function with caution of accessing unauthorized webhook, which means should only be used in non-user interactive functions.

func GetWebhookByOrgID added in v0.9.46

func GetWebhookByOrgID(orgID, id int64) (*Webhook, error)

GetWebhookByOrgID returns webhook of organization by given ID.

func GetWebhookOfRepoByID added in v0.10.1

func GetWebhookOfRepoByID(repoID, id int64) (*Webhook, error)

GetWebhookOfRepoByID returns webhook of repository by given ID.

func GetWebhooksByOrgID added in v0.9.46

func GetWebhooksByOrgID(orgID int64) (ws []*Webhook, err error)

GetWebhooksByOrgID returns all webhooks for an organization.

func GetWebhooksByRepoID added in v0.7.19

func GetWebhooksByRepoID(repoID int64) ([]*Webhook, error)

GetWebhooksByRepoID returns all webhooks of a repository.

func (*Webhook) AfterSet added in v0.6.9

func (w *Webhook) AfterSet(colName string, _ xorm.Cell)

func (*Webhook) BeforeInsert added in v0.9.13

func (w *Webhook) BeforeInsert()

func (*Webhook) BeforeUpdate added in v0.9.13

func (w *Webhook) BeforeUpdate()

func (*Webhook) EventsArray added in v0.6.9

func (w *Webhook) EventsArray() []string

func (*Webhook) GetSlackHook added in v0.5.0

func (w *Webhook) GetSlackHook() *SlackMeta

func (*Webhook) HasCreateEvent added in v0.6.9

func (w *Webhook) HasCreateEvent() bool

HasCreateEvent returns true if hook enabled create event.

func (*Webhook) HasDeleteEvent added in v0.10.8

func (w *Webhook) HasDeleteEvent() bool

HasDeleteEvent returns true if hook enabled delete event.

func (*Webhook) HasForkEvent added in v0.10.8

func (w *Webhook) HasForkEvent() bool

HasForkEvent returns true if hook enabled fork event.

func (*Webhook) HasIssueCommentEvent added in v0.10.18

func (w *Webhook) HasIssueCommentEvent() bool

HasIssueCommentEvent returns true if hook enabled issue comment event.

func (*Webhook) HasIssuesEvent added in v0.10.18

func (w *Webhook) HasIssuesEvent() bool

HasIssuesEvent returns true if hook enabled issues event.

func (*Webhook) HasPullRequestEvent added in v0.9.97

func (w *Webhook) HasPullRequestEvent() bool

HasPullRequestEvent returns true if hook enabled pull request event.

func (*Webhook) HasPushEvent added in v0.4.0

func (w *Webhook) HasPushEvent() bool

HasPushEvent returns true if hook enabled push event.

func (*Webhook) HasReleaseEvent added in v0.10.18

func (w *Webhook) HasReleaseEvent() bool

HasReleaseEvent returns true if hook enabled release event.

func (*Webhook) History added in v0.6.9

func (w *Webhook) History(page int) ([]*HookTask, error)

History returns history of webhook by given conditions.

func (*Webhook) UpdateEvent added in v0.5.0

func (w *Webhook) UpdateEvent() error

UpdateEvent handles conversion from HookEvent to Events.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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