models

package
v1.5.0-dev Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: MIT Imports: 96 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterModeAll = iota
	FilterModeAssign
	FilterModeCreate
	FilterModeMention
)

Filter modes.

View Source
const (
	// LFSMetaFileIdentifier is the string appearing at the first line of LFS pointer files.
	// https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md
	LFSMetaFileIdentifier = "version https://git-lfs.github.com/spec/v1"

	// LFSMetaFileOidPrefix appears in LFS pointer files on a line before the sha256 hash.
	LFSMetaFileOidPrefix = "oid sha256:"
)
View Source
const (
	SMTPPlain = "PLAIN"
	SMTPLogin = "LOGIN"
)

SMTP authentication type names.

View Source
const (
	SearchOrderByAlphabetically        SearchOrderBy = "name ASC"
	SearchOrderByAlphabeticallyReverse               = "name DESC"
	SearchOrderByLeastUpdated                        = "updated_unix ASC"
	SearchOrderByRecentUpdated                       = "updated_unix DESC"
	SearchOrderByOldest                              = "created_unix ASC"
	SearchOrderByNewest                              = "created_unix DESC"
	SearchOrderBySize                                = "size ASC"
	SearchOrderBySizeReverse                         = "size DESC"
	SearchOrderByID                                  = "id ASC"
	SearchOrderByIDReverse                           = "id DESC"
	SearchOrderByStars                               = "num_stars ASC"
	SearchOrderByStarsReverse                        = "num_stars DESC"
	SearchOrderByForks                               = "num_forks ASC"
	SearchOrderByForksReverse                        = "num_forks DESC"
)

Strings for sorting result

View Source
const (
	// KeyTypeUser specifies the user key
	KeyTypeUser = iota + 1
	// KeyTypeDeploy specifies the deploy key
	KeyTypeDeploy
)
View Source
const (
	EnvRepoName     = "GITEA_REPO_NAME"
	EnvRepoUsername = "GITEA_REPO_USER_NAME"
	EnvRepoIsWiki   = "GITEA_REPO_IS_WIKI"
	EnvPusherName   = "GITEA_PUSHER_NAME"
	EnvPusherID     = "GITEA_PUSHER_ID"
)

env keys for git hooks need

View Source
const (
	HookStatusNone = iota
	HookStatusSucceed
	HookStatusFail
)

Possible statuses of a web hook

View Source
const NonexistentID = 9223372036854775807

NonexistentID an ID that will never exist

View Source
const (
	// ProtectedBranchRepoID protected Repo ID
	ProtectedBranchRepoID = "GITEA_REPO_ID"
)
View Source
const RepositoryListDefaultPageSize = 64

RepositoryListDefaultPageSize is the default number of repositories to load in memory when running administrative tasks on all (or almost all) of them. The number should be low enough to avoid filling up all RAM with repository data...

Variables

View Source
var (

	// HasEngine specifies if we have a xorm.Engine
	HasEngine bool

	// DbCfg holds the database settings
	DbCfg struct {
		Type, Host, Name, User, Passwd, Path, SSLMode string
		Timeout                                       int
	}

	// EnableSQLite3 use SQLite3
	EnableSQLite3 bool

	// EnableTiDB enable TiDB
	EnableTiDB bool
)
View Source
var (
	// ErrMirrorNotExist mirror does not exist error
	ErrMirrorNotExist = errors.New("Mirror does not exist")

	// ErrNameEmpty name is empty error
	ErrNameEmpty = errors.New("Name is empty")
)
View Source
var (
	// Gitignores contains the gitiginore files
	Gitignores []string

	// Licenses contains the license files
	Licenses []string

	// Readmes contains the readme files
	Readmes []string

	// LabelTemplates contains the label template files
	LabelTemplates []string

	// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
	ItemsPerPage = 40
)
View Source
var (
	UnitCode = Unit{
		UnitTypeCode,
		"repo.code",
		"/",
		"repo.code.desc",
		0,
	}

	UnitIssues = Unit{
		UnitTypeIssues,
		"repo.issues",
		"/issues",
		"repo.issues.desc",
		1,
	}

	UnitExternalTracker = Unit{
		UnitTypeExternalTracker,
		"repo.ext_issues",
		"/issues",
		"repo.ext_issues.desc",
		1,
	}

	UnitPullRequests = Unit{
		UnitTypePullRequests,
		"repo.pulls",
		"/pulls",
		"repo.pulls.desc",
		2,
	}

	UnitReleases = Unit{
		UnitTypeReleases,
		"repo.releases",
		"/releases",
		"repo.releases.desc",
		3,
	}

	UnitWiki = Unit{
		UnitTypeWiki,
		"repo.wiki",
		"/wiki",
		"repo.wiki.desc",
		4,
	}

	UnitExternalWiki = Unit{
		UnitTypeExternalWiki,
		"repo.ext_wiki",
		"/wiki",
		"repo.ext_wiki.desc",
		4,
	}

	// Units contains all the units
	Units = map[UnitType]Unit{
		UnitTypeCode:            UnitCode,
		UnitTypeIssues:          UnitIssues,
		UnitTypeExternalTracker: UnitExternalTracker,
		UnitTypePullRequests:    UnitPullRequests,
		UnitTypeReleases:        UnitReleases,
		UnitTypeWiki:            UnitWiki,
		UnitTypeExternalWiki:    UnitExternalWiki,
	}
)

Enumerate all the units

View Source
var (
	// ErrUserNotKeyOwner user does not own this key error
	ErrUserNotKeyOwner = errors.New("User does not own this public key")

	// ErrEmailNotExist e-mail does not exist error
	ErrEmailNotExist = errors.New("E-mail does not exist")

	// ErrEmailNotActivated e-mail address has not been activated error
	ErrEmailNotActivated = errors.New("E-mail address has not been activated")

	// ErrUserNameIllegal user name contains illegal characters error
	ErrUserNameIllegal = errors.New("User name contains illegal characters")

	// ErrLoginSourceNotActived login source is not actived error
	ErrLoginSourceNotActived = errors.New("Login source is not actived")

	// ErrUnsupportedLoginType login source is unknown error
	ErrUnsupportedLoginType = errors.New("Login source is unknown")
)
View Source
var (
	// ErrEmailAddressNotExist email address not exist
	ErrEmailAddressNotExist = errors.New("Email address does not exist")
)
View Source
var (
	// ErrLFSObjectNotExist is returned from lfs models functions in order
	// to differentiate between database and missing object errors.
	ErrLFSObjectNotExist = errors.New("LFS Meta object does not exist")
)
View Source
var (
	// ErrOpenIDNotExist openid is not known
	ErrOpenIDNotExist = errors.New("OpenID is unknown")
)
View Source
var (
	// ErrTeamNotExist team does not exist
	ErrTeamNotExist = errors.New("Team does not exist")
)
View Source
var (
	// ErrUnitNotExist organization does not exist
	ErrUnitNotExist = errors.New("Unit does not exist")
)
View Source
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)

HookQueue is a global queue of web hooks

View Source
var LoginNames = map[LoginType]string{
	LoginLDAP:   "LDAP (via BindDN)",
	LoginDLDAP:  "LDAP (simple auth)",
	LoginSMTP:   "SMTP",
	LoginPAM:    "PAM",
	LoginOAuth2: "OAuth2",
}

LoginNames contains the name of LoginType values.

View Source
var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)

MirrorQueue holds an UniqueQueue object of the mirror

View Source
var (

	// MustRepoUnits contains the units could not be disabled currently
	MustRepoUnits = []UnitType{
		UnitTypeCode,
		UnitTypeReleases,
	}
)
View Source
var OAuth2DefaultCustomURLMappings = map[string]*oauth2.CustomURLMapping{
	"github": OAuth2Providers["github"].CustomURLMapping,
	"gitlab": OAuth2Providers["gitlab"].CustomURLMapping,
}

OAuth2DefaultCustomURLMappings contains the map of default URL's for OAuth2 providers that are allowed to have custom urls key is used to map the OAuth2Provider value is the mapping as defined for the OAuth2Provider

View Source
var OAuth2Providers = map[string]OAuth2Provider{
	"bitbucket": {Name: "bitbucket", DisplayName: "Bitbucket", Image: "/img/auth/bitbucket.png"},
	"dropbox":   {Name: "dropbox", DisplayName: "Dropbox", Image: "/img/auth/dropbox.png"},
	"facebook":  {Name: "facebook", DisplayName: "Facebook", Image: "/img/auth/facebook.png"},
	"github": {Name: "github", DisplayName: "GitHub", Image: "/img/auth/github.png",
		CustomURLMapping: &oauth2.CustomURLMapping{
			TokenURL:   oauth2.GetDefaultTokenURL("github"),
			AuthURL:    oauth2.GetDefaultAuthURL("github"),
			ProfileURL: oauth2.GetDefaultProfileURL("github"),
			EmailURL:   oauth2.GetDefaultEmailURL("github"),
		},
	},
	"gitlab": {Name: "gitlab", DisplayName: "GitLab", Image: "/img/auth/gitlab.png",
		CustomURLMapping: &oauth2.CustomURLMapping{
			TokenURL:   oauth2.GetDefaultTokenURL("gitlab"),
			AuthURL:    oauth2.GetDefaultAuthURL("gitlab"),
			ProfileURL: oauth2.GetDefaultProfileURL("gitlab"),
		},
	},
	"gplus":         {Name: "gplus", DisplayName: "Google+", Image: "/img/auth/google_plus.png"},
	"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/img/auth/openid_connect.png"},
	"twitter":       {Name: "twitter", DisplayName: "Twitter", Image: "/img/auth/twitter.png"},
}

OAuth2Providers contains the map of registered OAuth2 providers in Gitea (based on goth) key is used to map the OAuth2Provider with the goth provider type (also in LoginSource.OAuth2Config.Provider) value is used to store display data

View Source
var SMTPAuths = []string{SMTPPlain, SMTPLogin}

SMTPAuths contains available SMTP authentication type names.

View Source
var SecurityProtocolNames = map[ldap.SecurityProtocol]string{
	ldap.SecurityProtocolUnencrypted: "Unencrypted",
	ldap.SecurityProtocolLDAPS:       "LDAPS",
	ldap.SecurityProtocolStartTLS:    "StartTLS",
}

SecurityProtocolNames contains the name of SecurityProtocol values.

Functions

func AddAssigneeIfNotAssigned added in v1.5.0

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

AddAssigneeIfNotAssigned adds an assignee only if he isn't aleady assigned to the issue

func AddDeletePRBranchComment added in v1.1.0

func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branchName string) error

AddDeletePRBranchComment adds delete branch comment for pull request issue

func AddEmailAddress

func AddEmailAddress(email *EmailAddress) error

AddEmailAddress adds an email address to given user.

func AddEmailAddresses

func AddEmailAddresses(emails []*EmailAddress) error

AddEmailAddresses adds an email address to given user.

func AddOrgUser

func AddOrgUser(orgID, uid int64) error

AddOrgUser adds new user to given organization.

func AddTeamMember

func AddTeamMember(team *Team, 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 AddTestPullRequestTask

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 AddUserOpenID added in v1.2.0

func AddUserOpenID(openid *UserOpenID) error

AddUserOpenID adds an pre-verified/normalized OpenID URI to given user.

func AssertCount added in v1.2.0

func AssertCount(t testing.TB, bean interface{}, expected interface{})

AssertCount assert the count of a bean

func AssertExistsAndLoadBean added in v1.2.0

func AssertExistsAndLoadBean(t testing.TB, bean interface{}, conditions ...interface{}) interface{}

AssertExistsAndLoadBean assert that a bean exists and load it from the test database

func AssertExistsIf added in v1.4.0

func AssertExistsIf(t *testing.T, expected bool, bean interface{}, conditions ...interface{})

AssertExistsIf asserts that a bean exists or does not exist, depending on what is expected.

func AssertInt64InRange added in v1.2.0

func AssertInt64InRange(t testing.TB, low, high, value int64)

AssertInt64InRange assert value is in range [low, high]

func AssertNotExistsBean added in v1.2.0

func AssertNotExistsBean(t testing.TB, bean interface{}, conditions ...interface{})

AssertNotExistsBean assert that a bean does not exist in the test database

func AssertSuccessfulInsert added in v1.2.0

func AssertSuccessfulInsert(t testing.TB, beans ...interface{})

AssertSuccessfulInsert assert that beans is successfully inserted

func AttachmentLocalPath

func AttachmentLocalPath(uuid string) string

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

func BeanExists added in v1.2.0

func BeanExists(t testing.TB, bean interface{}, conditions ...interface{}) bool

BeanExists for testing, check if a bean exists

func CancelStopwatch added in v1.3.0

func CancelStopwatch(user *User, issue *Issue) error

CancelStopwatch removes the given stopwatch and logs it into issue's timeline.

func Cell2Int64

func Cell2Int64(val xorm.Cell) int64

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

func ChangeMilestoneAssign

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

ChangeMilestoneAssign changes assignment of milestone for issue.

func ChangeMilestoneStatus

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

ChangeMilestoneStatus changes the milestone open/closed status.

func ChangeOrgUserStatus

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

ChangeOrgUserStatus changes public or private membership status.

func ChangeRepositoryName

func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)

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

func ChangeUserName

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

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

func ChangeUsernameInPullRequests

func ChangeUsernameInPullRequests(oldUserName, newUserName string) error

ChangeUsernameInPullRequests changes the name of head_user_name

func CheckConsistencyFor added in v1.2.0

func CheckConsistencyFor(t *testing.T, beansToCheck ...interface{})

CheckConsistencyFor test that all matching database entries are consistent

func CheckConsistencyForAll added in v1.2.0

func CheckConsistencyForAll(t *testing.T)

CheckConsistencyForAll test that the entire database is consistent

func CheckLFSAccessForRepo added in v1.4.0

func CheckLFSAccessForRepo(u *User, repo *Repository, mode AccessMode) error

CheckLFSAccessForRepo check needed access mode base on action

func CheckPublicKeyString

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

func CheckRepoStats()

CheckRepoStats checks the repository stats

func CommentHashTag added in v1.5.0

func CommentHashTag(id int64) string

CommentHashTag returns unique hash tag for comment id.

func CommitRepoAction

func CommitRepoAction(opts CommitRepoActionOptions) error

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

func ComposeHTTPSCloneURL

func ComposeHTTPSCloneURL(owner, repo string) string

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

func Cond added in v1.2.0

func Cond(query interface{}, args ...interface{}) interface{}

Cond create a condition with arguments for a test

func CountIssuesByRepo added in v1.2.0

func CountIssuesByRepo(opts *IssuesOptions) (map[int64]int64, error)

CountIssuesByRepo map from repoID to number of issues matching the options

func CountLoginSources

func CountLoginSources() int64

CountLoginSources returns number of login sources.

func CountNotices

func CountNotices() int64

CountNotices returns number of notices.

func CountOrganizations

func CountOrganizations() int64

CountOrganizations returns number of organizations.

func CountRepoClosedMilestones

func CountRepoClosedMilestones(repoID int64) (int64, error)

CountRepoClosedMilestones returns number of closed milestones in given repository.

func CountRepositories

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

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

func CountUsers() int64

CountUsers returns number of users.

func CreateHookTask

func CreateHookTask(t *HookTask) error

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

func CreateLoginSource

func CreateLoginSource(source *LoginSource) error

CreateLoginSource inserts a LoginSource in the DB if not already existing with the given name.

func CreateNotice

func CreateNotice(tp NoticeType, desc string) error

CreateNotice creates new system notice.

func CreateOrStopIssueStopwatch added in v1.3.0

func CreateOrStopIssueStopwatch(user *User, issue *Issue) error

CreateOrStopIssueStopwatch will create or remove a stopwatch and will log it into issue's timeline.

func CreateOrUpdateIssueNotifications added in v1.1.0

func CreateOrUpdateIssueNotifications(issue *Issue, notificationAuthorID int64) error

CreateOrUpdateIssueNotifications creates an issue notification for each watcher, or updates it if already exists

func CreateOrUpdateIssueWatch added in v1.2.0

func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error

CreateOrUpdateIssueWatch set watching for a user and issue

func CreateOrganization

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

CreateOrganization creates record of a new organization.

func CreateRefComment

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

CreateRefComment creates a commit reference comment to issue.

func CreateRelease

func CreateRelease(gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) error

CreateRelease creates a new release of repository.

func CreateRepositoryNotice

func CreateRepositoryNotice(desc string) error

CreateRepositoryNotice creates new system notice with type NoticeRepository.

func CreateUser

func CreateUser(u *User) (err error)

CreateUser creates record of a new user.

func CreateWebhook

func CreateWebhook(w *Webhook) error

CreateWebhook creates a new web hook.

func DeleteAccessTokenByID

func DeleteAccessTokenByID(id, userID int64) error

DeleteAccessTokenByID deletes access token by given ID.

func DeleteAttachment

func DeleteAttachment(a *Attachment, remove bool) error

DeleteAttachment deletes the given attachment and optionally the associated file.

func DeleteAttachments

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

DeleteAttachments deletes the given attachments and optionally the associated files.

func DeleteAttachmentsByComment

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

DeleteAttachmentsByComment deletes all attachments associated with the given comment.

func DeleteAttachmentsByIssue

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

DeleteAttachmentsByIssue deletes all attachments associated with the given issue.

func DeleteComment added in v1.1.0

func DeleteComment(doer *User, comment *Comment) error

DeleteComment deletes the comment

func DeleteCommentReaction added in v1.4.0

func DeleteCommentReaction(doer *User, issue *Issue, comment *Comment, content string) error

DeleteCommentReaction deletes a reaction on comment.

func DeleteDeployKey

func DeleteDeployKey(doer *User, id int64) error

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

func DeleteEmailAddress

func DeleteEmailAddress(email *EmailAddress) (err error)

DeleteEmailAddress deletes an email address of given user.

func DeleteEmailAddresses

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

DeleteEmailAddresses deletes multiple email addresses

func DeleteGPGKey added in v1.2.0

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

DeleteGPGKey deletes GPG key information in database.

func DeleteInactivateUsers

func DeleteInactivateUsers() (err error)

DeleteInactivateUsers deletes all inactivate users and email addresses.

func DeleteIssueLabel

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

DeleteIssueLabel deletes issue-label relation.

func DeleteIssueReaction added in v1.4.0

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

DeleteIssueReaction deletes a reaction on issue.

func DeleteLabel

func DeleteLabel(repoID, labelID int64) error

DeleteLabel delete a label of given repository.

func DeleteMilestoneByRepoID

func DeleteMilestoneByRepoID(repoID, id int64) error

DeleteMilestoneByRepoID deletes a milestone from a repository.

func DeleteMirrorByRepoID

func DeleteMirrorByRepoID(repoID int64) error

DeleteMirrorByRepoID deletes a mirror by repoID

func DeleteMissingRepositories

func DeleteMissingRepositories(doer *User) error

DeleteMissingRepositories deletes all repository records that lost Git files.

func DeleteNotPassedAssignee added in v1.5.0

func DeleteNotPassedAssignee(issue *Issue, doer *User, assignees []*User) (err error)

DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array

func DeleteNotice

func DeleteNotice(id int64) error

DeleteNotice deletes a system notice by given ID.

func DeleteNotices

func DeleteNotices(start, end int64) error

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

func DeleteNoticesByIDs

func DeleteNoticesByIDs(ids []int64) error

DeleteNoticesByIDs deletes notices by given IDs.

func DeleteOldRepositoryArchives added in v1.1.0

func DeleteOldRepositoryArchives()

DeleteOldRepositoryArchives deletes old repository archives.

func DeleteOrganization

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

func DeleteReaction(opts *ReactionOptions) error

DeleteReaction deletes reaction for issue or comment.

func DeleteRegistration added in v1.5.0

func DeleteRegistration(reg *U2FRegistration) error

DeleteRegistration will delete U2FRegistration

func DeleteReleaseByID

func DeleteReleaseByID(id int64, u *User, delTag bool) error

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

func DeleteRepoFromIndexer added in v1.3.0

func DeleteRepoFromIndexer(repo *Repository)

DeleteRepoFromIndexer remove all of a repository's entries from the indexer

func DeleteRepository

func DeleteRepository(doer *User, uid, repoID int64) error

DeleteRepository deletes a repository for a user or organization.

func DeleteRepositoryArchives

func DeleteRepositoryArchives() error

DeleteRepositoryArchives deletes all repositories' archives.

func DeleteSource

func DeleteSource(source *LoginSource) error

DeleteSource deletes a LoginSource record in DB.

func DeleteTeam

func DeleteTeam(t *Team) error

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

func DeleteTwoFactorByID added in v1.1.0

func DeleteTwoFactorByID(id, userID int64) error

DeleteTwoFactorByID deletes two-factor authentication token by given ID.

func DeleteUpload

func DeleteUpload(u *Upload) error

DeleteUpload delete a upload

func DeleteUploadByUUID

func DeleteUploadByUUID(uuid string) error

DeleteUploadByUUID deletes a upload by UUID

func DeleteUploads

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

DeleteUploads deletes multiple uploads

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 DeleteUserOpenID added in v1.2.0

func DeleteUserOpenID(openid *UserOpenID) (err error)

DeleteUserOpenID deletes an openid address of given user.

func DeleteWebhookByOrgID

func DeleteWebhookByOrgID(orgID, id int64) error

DeleteWebhookByOrgID deletes webhook of organization by given ID.

func DeleteWebhookByRepoID

func DeleteWebhookByRepoID(repoID, id int64) error

DeleteWebhookByRepoID deletes webhook of repository by given ID.

func DeliverHooks

func DeliverHooks()

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

func DumpDatabase

func DumpDatabase(filePath string, dbType string) error

DumpDatabase dumps all data from database according the special database SQL syntax to file system.

func FindUserAccessibleRepoIDs added in v1.5.0

func FindUserAccessibleRepoIDs(userID int64) ([]int64, error)

FindUserAccessibleRepoIDs find all accessible repositories' ID by user's id

func FollowUser

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

FollowUser marks someone be another's follower.

func GetActiveOAuth2Providers added in v1.1.0

func GetActiveOAuth2Providers() ([]string, map[string]OAuth2Provider, error)

GetActiveOAuth2Providers returns the map of configured active OAuth2 providers key is used as technical name (like in the callbackURL) values to display

func GetCount added in v1.2.0

func GetCount(t testing.TB, bean interface{}, conditions ...interface{}) int

GetCount get the count of a bean

func GetExternalLogin added in v1.1.0

func GetExternalLogin(externalLoginUser *ExternalLoginUser) (bool, error)

GetExternalLogin checks if a externalID in loginSourceID scope already exists

func GetLabelTemplateFile

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

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

func GetNotificationCount added in v1.1.0

func GetNotificationCount(user *User, status NotificationStatus) (int64, error)

GetNotificationCount returns the notification count for user

func GetPrivateRepositoryCount added in v1.1.0

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

GetPrivateRepositoryCount returns the total number of private repositories of user.

func GetPublicRepositoryCount added in v1.1.0

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

GetPublicRepositoryCount returns the total number of public repositories of user.

func GetRawDiff

func GetRawDiff(repoPath, commitID string, diffType RawDiffType, writer io.Writer) error

GetRawDiff dumps diff results of repository in given commit ID to io.Writer. TODO: move this function to gogits/git-module

func GetReleaseAttachments added in v1.1.0

func GetReleaseAttachments(rels ...*Release) (err error)

GetReleaseAttachments retrieves the attachments for releases

func GetReleaseCountByRepoID added in v1.2.0

func GetReleaseCountByRepoID(repoID int64, opts FindReleasesOptions) (int64, error)

GetReleaseCountByRepoID returns the count of releases of repository

func GetRepoIssueStats

func GetRepoIssueStats(repoID, uid int64, filterMode int, isPull bool) (numOpen int64, numClosed int64)

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

func GetRepositoriesMapByIDs added in v1.5.0

func GetRepositoriesMapByIDs(ids []int64) (map[int64]*Repository, error)

GetRepositoriesMapByIDs returns the repositories by given id slice.

func GetRepositoryCount

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

GetRepositoryCount returns the total number of repositories of user.

func GetUser added in v1.1.0

func GetUser(user *User) (bool, error)

GetUser checks if a user already exists

func GetUserEmailsByNames

func GetUserEmailsByNames(names []string) []string

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

func GetUserIDsByNames

func GetUserIDsByNames(names []string) []int64

GetUserIDsByNames returns a slice of ids corresponds to names.

func GetUserSalt

func GetUserSalt() (string, error)

GetUserSalt returns a random user salt token.

func GitConfigPath added in v1.3.1

func GitConfigPath(repoPath string) string

GitConfigPath returns the path to a repository's git config/ directory

func GitFsck

func GitFsck()

GitFsck calls 'git fsck' to check repository health.

func GitGcRepos

func GitGcRepos() error

GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository

func HasAccess

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

HasAccess returns true if user has access to repo

func HasDeployKey

func HasDeployKey(keyID, repoID int64) bool

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

func HasIssueLabel

func HasIssueLabel(issueID, labelID int64) bool

HasIssueLabel returns true if issue has been labeled.

func HasTeamRepo

func HasTeamRepo(orgID, teamID, repoID int64) bool

HasTeamRepo returns true if given repository belongs to team.

func InitDeliverHooks

func InitDeliverHooks()

InitDeliverHooks starts the hooks delivery thread

func InitFixtures added in v1.2.0

func InitFixtures(helper testfixtures.Helper, dir string) (err error)

InitFixtures initialize test fixtures for a test database

func InitIssueIndexer added in v1.1.0

func InitIssueIndexer()

InitIssueIndexer initialize issue indexer

func InitMailRender

func InitMailRender(tmpls *template.Template)

InitMailRender initializes the macaron mail renderer

func InitOAuth2 added in v1.1.0

func InitOAuth2() error

InitOAuth2 initialize the OAuth2 lib and register all active OAuth2 providers in the library

func InitRepoIndexer added in v1.3.0

func InitRepoIndexer()

InitRepoIndexer initialize the repo indexer

func InitSyncMirrors

func InitSyncMirrors()

InitSyncMirrors initializes a go routine to sync the mirrors

func InitTestPullRequests

func InitTestPullRequests()

InitTestPullRequests runs the task to test all the checking status pull requests

func IsEmailUsed

func IsEmailUsed(email string) (bool, error)

IsEmailUsed returns true if the email has been used.

func IsErrAccessTokenEmpty

func IsErrAccessTokenEmpty(err error) bool

IsErrAccessTokenEmpty checks if an error is a ErrAccessTokenEmpty.

func IsErrAccessTokenNotExist

func IsErrAccessTokenNotExist(err error) bool

IsErrAccessTokenNotExist checks if an error is a ErrAccessTokenNotExist.

func IsErrAttachmentNotExist

func IsErrAttachmentNotExist(err error) bool

IsErrAttachmentNotExist checks if an error is a ErrAttachmentNotExist.

func IsErrBranchAlreadyExists added in v1.3.0

func IsErrBranchAlreadyExists(err error) bool

IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.

func IsErrBranchNameConflict added in v1.3.0

func IsErrBranchNameConflict(err error) bool

IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.

func IsErrBranchNotExist

func IsErrBranchNotExist(err error) bool

IsErrBranchNotExist checks if an error is a ErrBranchNotExist.

func IsErrCommentNotExist

func IsErrCommentNotExist(err error) bool

IsErrCommentNotExist checks if an error is a ErrCommentNotExist.

func IsErrDeployKeyAlreadyExist

func IsErrDeployKeyAlreadyExist(err error) bool

IsErrDeployKeyAlreadyExist checks if an error is a ErrDeployKeyAlreadyExist.

func IsErrDeployKeyNameAlreadyUsed

func IsErrDeployKeyNameAlreadyUsed(err error) bool

IsErrDeployKeyNameAlreadyUsed checks if an error is a ErrDeployKeyNameAlreadyUsed.

func IsErrDeployKeyNotExist

func IsErrDeployKeyNotExist(err error) bool

IsErrDeployKeyNotExist checks if an error is a ErrDeployKeyNotExist.

func IsErrEmailAlreadyUsed

func IsErrEmailAlreadyUsed(err error) bool

IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.

func IsErrExternalLoginUserAlreadyExist added in v1.1.0

func IsErrExternalLoginUserAlreadyExist(err error) bool

IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.

func IsErrExternalLoginUserNotExist added in v1.1.0

func IsErrExternalLoginUserNotExist(err error) bool

IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.

func IsErrGPGKeyAccessDenied added in v1.2.0

func IsErrGPGKeyAccessDenied(err error) bool

IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied.

func IsErrGPGKeyIDAlreadyUsed added in v1.2.0

func IsErrGPGKeyIDAlreadyUsed(err error) bool

IsErrGPGKeyIDAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.

func IsErrGPGKeyNotExist added in v1.2.0

func IsErrGPGKeyNotExist(err error) bool

IsErrGPGKeyNotExist checks if an error is a ErrGPGKeyNotExist.

func IsErrGPGKeyParsing added in v1.2.0

func IsErrGPGKeyParsing(err error) bool

IsErrGPGKeyParsing checks if an error is a ErrGPGKeyParsing.

func IsErrGPGNoEmailFound added in v1.2.3

func IsErrGPGNoEmailFound(err error) bool

IsErrGPGNoEmailFound checks if an error is a ErrGPGNoEmailFound.

func IsErrInvalidCloneAddr

func IsErrInvalidCloneAddr(err error) bool

IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.

func IsErrInvalidMergeStyle added in v1.4.0

func IsErrInvalidMergeStyle(err error) bool

IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.

func IsErrInvalidTagName

func IsErrInvalidTagName(err error) bool

IsErrInvalidTagName checks if an error is a ErrInvalidTagName.

func IsErrIssueNotExist

func IsErrIssueNotExist(err error) bool

IsErrIssueNotExist checks if an error is a ErrIssueNotExist.

func IsErrKeyAccessDenied

func IsErrKeyAccessDenied(err error) bool

IsErrKeyAccessDenied checks if an error is a ErrKeyAccessDenied.

func IsErrKeyAlreadyExist

func IsErrKeyAlreadyExist(err error) bool

IsErrKeyAlreadyExist checks if an error is a ErrKeyAlreadyExist.

func IsErrKeyNameAlreadyUsed

func IsErrKeyNameAlreadyUsed(err error) bool

IsErrKeyNameAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed.

func IsErrKeyNotExist

func IsErrKeyNotExist(err error) bool

IsErrKeyNotExist checks if an error is a ErrKeyNotExist.

func IsErrKeyUnableVerify

func IsErrKeyUnableVerify(err error) bool

IsErrKeyUnableVerify checks if an error is a ErrKeyUnableVerify.

func IsErrLFSLockAlreadyExist added in v1.4.0

func IsErrLFSLockAlreadyExist(err error) bool

IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.

func IsErrLFSLockNotExist added in v1.4.0

func IsErrLFSLockNotExist(err error) bool

IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.

func IsErrLFSUnauthorizedAction added in v1.4.0

func IsErrLFSUnauthorizedAction(err error) bool

IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.

func IsErrLabelNotExist

func IsErrLabelNotExist(err error) bool

IsErrLabelNotExist checks if an error is a ErrLabelNotExist.

func IsErrLastOrgOwner

func IsErrLastOrgOwner(err error) bool

IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.

func IsErrLoginSourceAlreadyExist

func IsErrLoginSourceAlreadyExist(err error) bool

IsErrLoginSourceAlreadyExist checks if an error is a ErrLoginSourceAlreadyExist.

func IsErrLoginSourceInUse

func IsErrLoginSourceInUse(err error) bool

IsErrLoginSourceInUse checks if an error is a ErrLoginSourceInUse.

func IsErrLoginSourceNotExist

func IsErrLoginSourceNotExist(err error) bool

IsErrLoginSourceNotExist checks if an error is a ErrLoginSourceNotExist.

func IsErrMilestoneNotExist

func IsErrMilestoneNotExist(err error) bool

IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.

func IsErrNamePatternNotAllowed

func IsErrNamePatternNotAllowed(err error) bool

IsErrNamePatternNotAllowed checks if an error is an ErrNamePatternNotAllowed.

func IsErrNameReserved

func IsErrNameReserved(err error) bool

IsErrNameReserved checks if an error is a ErrNameReserved.

func IsErrNotAllowedToMerge added in v1.5.0

func IsErrNotAllowedToMerge(err error) bool

IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.

func IsErrOpenIDAlreadyUsed added in v1.2.0

func IsErrOpenIDAlreadyUsed(err error) bool

IsErrOpenIDAlreadyUsed checks if an error is a ErrOpenIDAlreadyUsed.

func IsErrOpenIDConnectInitialize added in v1.2.0

func IsErrOpenIDConnectInitialize(err error) bool

IsErrOpenIDConnectInitialize checks if an error is a ExternalLoginUserAlreadyExist.

func IsErrOrgNotExist added in v1.2.0

func IsErrOrgNotExist(err error) bool

IsErrOrgNotExist checks if an error is a ErrOrgNotExist.

func IsErrPullRequestAlreadyExists added in v1.0.0

func IsErrPullRequestAlreadyExists(err error) bool

IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.

func IsErrPullRequestNotExist

func IsErrPullRequestNotExist(err error) bool

IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.

func IsErrReachLimitOfRepo

func IsErrReachLimitOfRepo(err error) bool

IsErrReachLimitOfRepo checks if an error is a ErrReachLimitOfRepo.

func IsErrReleaseAlreadyExist

func IsErrReleaseAlreadyExist(err error) bool

IsErrReleaseAlreadyExist checks if an error is a ErrReleaseAlreadyExist.

func IsErrReleaseNotExist

func IsErrReleaseNotExist(err error) bool

IsErrReleaseNotExist checks if an error is a ErrReleaseNotExist.

func IsErrRepoAlreadyExist

func IsErrRepoAlreadyExist(err error) bool

IsErrRepoAlreadyExist checks if an error is a ErrRepoAlreadyExist.

func IsErrRepoFileAlreadyExist

func IsErrRepoFileAlreadyExist(err error) bool

IsErrRepoFileAlreadyExist checks if an error is a ErrRepoFileAlreadyExist.

func IsErrRepoNotExist

func IsErrRepoNotExist(err error) bool

IsErrRepoNotExist checks if an error is a ErrRepoNotExist.

func IsErrRepoRedirectNotExist added in v1.1.0

func IsErrRepoRedirectNotExist(err error) bool

IsErrRepoRedirectNotExist check if an error is an ErrRepoRedirectNotExist

func IsErrSSHDisabled added in v1.4.0

func IsErrSSHDisabled(err error) bool

IsErrSSHDisabled checks if an error is a ErrSSHDisabled.

func IsErrStopwatchNotExist added in v1.3.0

func IsErrStopwatchNotExist(err error) bool

IsErrStopwatchNotExist checks if an error is a ErrStopwatchNotExist.

func IsErrTagAlreadyExists added in v1.3.0

func IsErrTagAlreadyExists(err error) bool

IsErrTagAlreadyExists checks if an error is an ErrTagAlreadyExists.

func IsErrTeamAlreadyExist

func IsErrTeamAlreadyExist(err error) bool

IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.

func IsErrTopicNotExist added in v1.5.0

func IsErrTopicNotExist(err error) bool

IsErrTopicNotExist checks if an error is an ErrTopicNotExist.

func IsErrTrackedTimeNotExist added in v1.3.0

func IsErrTrackedTimeNotExist(err error) bool

IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.

func IsErrTwoFactorNotEnrolled added in v1.1.0

func IsErrTwoFactorNotEnrolled(err error) bool

IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled.

func IsErrU2FRegistrationNotExist added in v1.5.0

func IsErrU2FRegistrationNotExist(err error) bool

IsErrU2FRegistrationNotExist checks if an error is a ErrU2FRegistrationNotExist.

func IsErrUpdateTaskNotExist

func IsErrUpdateTaskNotExist(err error) bool

IsErrUpdateTaskNotExist checks if an error is a ErrUpdateTaskNotExist.

func IsErrUploadNotExist

func IsErrUploadNotExist(err error) bool

IsErrUploadNotExist checks if an error is a ErrUploadNotExist.

func IsErrUserAlreadyExist

func IsErrUserAlreadyExist(err error) bool

IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.

func IsErrUserDoesNotHaveAccessToRepo added in v1.5.0

func IsErrUserDoesNotHaveAccessToRepo(err error) bool

IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExist.

func IsErrUserHasOrgs

func IsErrUserHasOrgs(err error) bool

IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.

func IsErrUserNotAllowedCreateOrg added in v1.1.0

func IsErrUserNotAllowedCreateOrg(err error) bool

IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.

func IsErrUserNotExist

func IsErrUserNotExist(err error) bool

IsErrUserNotExist checks if an error is a ErrUserNotExist.

func IsErrUserOwnRepos

func IsErrUserOwnRepos(err error) bool

IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.

func IsErrWebhookNotExist

func IsErrWebhookNotExist(err error) bool

IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.

func IsErrWikiAlreadyExist

func IsErrWikiAlreadyExist(err error) bool

IsErrWikiAlreadyExist checks if an error is an ErrWikiAlreadyExist.

func IsErrWikiInvalidFileName added in v1.4.0

func IsErrWikiInvalidFileName(err error) bool

IsErrWikiInvalidFileName checks if an error is an ErrWikiInvalidFileName.

func IsErrWikiReservedName added in v1.4.0

func IsErrWikiReservedName(err error) bool

IsErrWikiReservedName checks if an error is an ErrWikiReservedName.

func IsFollowing

func IsFollowing(userID, followID int64) bool

IsFollowing returns true if user is following followID.

func IsOpenIDUsed added in v1.2.0

func IsOpenIDUsed(openid string) (bool, error)

IsOpenIDUsed returns true if the openid has been used.

func IsOrganizationMember

func IsOrganizationMember(orgID, uid int64) (bool, error)

IsOrganizationMember returns true if given user is member of organization.

func IsOrganizationOwner

func IsOrganizationOwner(orgID, uid int64) (bool, error)

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

func IsPublicMembership

func IsPublicMembership(orgID, uid int64) (bool, error)

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

func IsReleaseExist

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

func IsStaring(userID, repoID int64) bool

IsStaring checks if user has starred given repository.

func IsTeamMember

func IsTeamMember(orgID, teamID, userID int64) (bool, error)

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

func IsUsableRepoName

func IsUsableRepoName(name string) error

IsUsableRepoName returns true when repository is usable

func IsUsableTeamName added in v1.0.0

func IsUsableTeamName(name string) error

IsUsableTeamName tests if a name could be as team name

func IsUsableUsername

func IsUsableUsername(name string) error

IsUsableUsername returns an error when a username is reserved

func IsUserAssignedToIssue added in v1.5.0

func IsUserAssignedToIssue(issue *Issue, user *User) (isAssigned bool, err error)

IsUserAssignedToIssue returns true when the user is assigned to the issue

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

func IsUserInTeams(userID int64, teamIDs []int64) (bool, error)

IsUserInTeams returns if a user in some teams

func IsValidHookContentType

func IsValidHookContentType(name string) bool

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

func IsValidHookTaskType

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 LinkAccountToUser added in v1.1.0

func LinkAccountToUser(user *User, gothUser goth.User) error

LinkAccountToUser link the gothUser to the user

func LoadConfigs

func LoadConfigs()

LoadConfigs loads the database settings

func LoadFixtures added in v1.2.0

func LoadFixtures() error

LoadFixtures load fixtures for a test database

func LoadRepoConfig

func LoadRepoConfig()

LoadRepoConfig loads the repository config

func LocalCopyPath added in v1.4.0

func LocalCopyPath() string

LocalCopyPath returns the local repository copy path.

func LocalWikiPath added in v1.4.0

func LocalWikiPath() string

LocalWikiPath returns the local wiki repository copy path.

func LookupRepoRedirect added in v1.1.0

func LookupRepoRedirect(ownerID int64, repoName string) (int64, error)

LookupRepoRedirect look up if a repository has a redirect name

func MainTest added in v1.4.0

func MainTest(m *testing.M, pathToGiteaRoot string)

MainTest a reusable TestMain(..) function for unit tests that need to use a test database. Creates the test database, and sets necessary settings.

func MakeAssigneeList added in v1.5.0

func MakeAssigneeList(issue *Issue) (assigneeList string, err error)

MakeAssigneeList concats a string with all names of the assignees. Useful for logs.

func MakeEmailPrimary

func MakeEmailPrimary(email *EmailAddress) error

MakeEmailPrimary sets primary email address of given user.

func MakeIDsFromAPIAssigneesToAdd added in v1.5.0

func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string) (assigneeIDs []int64, err error)

MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs

func MergePullRequestAction

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

MergePullRequestAction adds new action for merging pull request.

func MilestoneStats

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

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

func MirrorUpdate

func MirrorUpdate()

MirrorUpdate checks and updates mirror repositories.

func NewAccessToken

func NewAccessToken(t *AccessToken) error

NewAccessToken creates new access token.

func NewCommitStatus added in v1.2.0

func NewCommitStatus(repo *Repository, creator *User, sha string, status *CommitStatus) error

NewCommitStatus creates a new CommitStatus given a bunch of parameters NOTE: All text-values will be trimmed from whitespaces. Requires: Repo, Creator, SHA

func NewEngine

func NewEngine(migrateFunc func(*xorm.Engine) error) (err error)

NewEngine initializes a new xorm.Engine

func NewIssue

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

NewIssue creates new issue with labels for repository.

func NewIssueLabel

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

NewIssueLabel creates a new issue-label relation.

func NewIssueLabels

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

NewIssueLabels creates a list of issue-label relations.

func NewLabel added in v1.2.0

func NewLabel(label *Label) error

NewLabel creates a new label for a repository

func NewLabels

func NewLabels(labels ...*Label) error

NewLabels creates new labels for a repository.

func NewMilestone

func NewMilestone(m *Milestone) (err error)

NewMilestone creates new milestone of repository.

func NewPullRequest

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

NewPullRequest creates new pull request with labels for repository.

func NewRepoAction

func NewRepoAction(u *User, repo *Repository) (err error)

NewRepoAction adds new action for creating repository.

func NewRepoContext

func NewRepoContext()

NewRepoContext creates a new repository context

func NewRepoRedirect added in v1.1.0

func NewRepoRedirect(ownerID, repoID int64, oldRepoName, newRepoName string) error

NewRepoRedirect create a new repo redirect

func NewTeam

func NewTeam(t *Team) (err 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)

NewTestEngine sets a new test xorm.Engine

func NewTwoFactor added in v1.1.0

func NewTwoFactor(t *TwoFactor) error

NewTwoFactor creates a new two-factor authentication token.

func NormalizeWikiName added in v1.4.0

func NormalizeWikiName(name string) string

NormalizeWikiName normalizes a wiki name

func NotifyWatchers

func NotifyWatchers(act *Action) error

NotifyWatchers creates batch of actions for every watcher.

func ParseCommitsWithSignature added in v1.2.0

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

ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.

func ParseCommitsWithStatus added in v1.2.0

func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List

ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state

func Ping

func Ping() error

Ping tests if database is alive

func PrepareTestDatabase added in v1.2.0

func PrepareTestDatabase() error

PrepareTestDatabase load test fixtures into test database

func PrepareTestEnv added in v1.4.0

func PrepareTestEnv(t testing.TB)

PrepareTestEnv prepares the environment for unit tests. Can only be called by tests that use the above MainTest(..) function.

func PrepareWebhook added in v1.3.0

func PrepareWebhook(w *Webhook, repo *Repository, event HookEventType, p api.Payloader) error

PrepareWebhook adds special webhook to task queue for given payload.

func PrepareWebhooks

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

PrepareWebhooks adds new webhooks to task queue for given payload.

func PushUpdate

func PushUpdate(branch string, opt PushUpdateOptions) error

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

func ReinitMissingRepositories

func ReinitMissingRepositories() error

ReinitMissingRepositories reinitializes all repository records that lost Git files.

func RemoveAccountLink(user *User, loginSourceID int64) (int64, error)

RemoveAccountLink will remove all external login sources for the given user

func RemoveAllWithNotice

func RemoveAllWithNotice(title, path string)

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

func RemoveOldDeletedBranches added in v1.3.0

func RemoveOldDeletedBranches()

RemoveOldDeletedBranches removes old deleted branches

func RemoveOrgUser

func RemoveOrgUser(orgID, userID int64) error

RemoveOrgUser removes user from given organization.

func RemoveTeamMember

func RemoveTeamMember(team *Team, userID int64) error

RemoveTeamMember removes member from given team of given organization.

func RenameRepoAction

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 RewriteAllPublicKeys

func RewriteAllPublicKeys() error

RewriteAllPublicKeys 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 outside any session scope independently.

func SMTPAuth

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

SMTPAuth performs an SMTP authentication.

func SSHKeyGenParsePublicKey

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

SSHKeyGenParsePublicKey extracts key type and length using ssh-keygen.

func SSHNativeParsePublicKey

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

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

func SaveTopics added in v1.5.0

func SaveTopics(repoID int64, topicNames ...string) error

SaveTopics save topics to a repository

func SecToTime added in v1.5.0

func SecToTime(duration int64) string

SecToTime converts an amount of seconds to a human-readable string (example: 66s -> 1min 6s)

func SendActivateAccountMail

func SendActivateAccountMail(c *macaron.Context, u *User)

SendActivateAccountMail sends an activation mail to the user (new user registration)

func SendActivateEmailMail

func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress)

SendActivateEmailMail sends confirmation email to confirm new email address

func SendCollaboratorMail

func SendCollaboratorMail(u, doer *User, repo *Repository)

SendCollaboratorMail sends mail notification to new collaborator.

func SendIssueCommentMail

func SendIssueCommentMail(issue *Issue, doer *User, content string, comment *Comment, tos []string)

SendIssueCommentMail composes and sends issue comment emails to target receivers.

func SendIssueMentionMail

func SendIssueMentionMail(issue *Issue, doer *User, content string, comment *Comment, tos []string)

SendIssueMentionMail composes and sends issue mention emails to target receivers.

func SendRegisterNotifyMail

func SendRegisterNotifyMail(c *macaron.Context, u *User)

SendRegisterNotifyMail triggers a notify e-mail by admin created a account.

func SendResetPasswordMail

func SendResetPasswordMail(c *macaron.Context, u *User)

SendResetPasswordMail sends a password reset mail to the user

func SendTestMail

func SendTestMail(email string) error

SendTestMail sends a test mail

func SendUserMail

func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject, info string)

SendUserMail sends a mail to the user

func SetEngine

func SetEngine() (err error)

SetEngine sets the xorm.Engine

func SetNotificationStatus added in v1.1.0

func SetNotificationStatus(notificationID int64, user *User, status NotificationStatus) error

SetNotificationStatus change the notification status

func SlackLinkFormatter

func SlackLinkFormatter(url string, text string) string

SlackLinkFormatter creates a link compatible with slack

func SlackLinkToRef added in v1.3.0

func SlackLinkToRef(repoURL, ref string) string

SlackLinkToRef slack-formatter link to a repo ref

func SlackShortTextFormatter

func SlackShortTextFormatter(s string) string

SlackShortTextFormatter replaces &, <, > with HTML characters

func SlackTextFormatter

func SlackTextFormatter(s string) string

SlackTextFormatter replaces &, <, > with HTML characters see: https://api.slack.com/docs/formatting

func SortReleases

func SortReleases(rels []*Release)

SortReleases sorts releases by number of commits and created time.

func StarRepo

func StarRepo(userID, repoID int64, star bool) error

StarRepo or unstar repository.

func StopwatchExists added in v1.3.0

func StopwatchExists(userID int64, issueID int64) bool

StopwatchExists returns true if the stopwatch exists

func SyncExternalUsers added in v1.2.0

func SyncExternalUsers()

SyncExternalUsers is used to synchronize users with external authorization source

func SyncMirrors

func SyncMirrors()

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

func SyncReleasesWithTags added in v1.2.0

func SyncReleasesWithTags(repo *Repository, gitRepo *git.Repository) error

SyncReleasesWithTags synchronizes release table with repository tags

func SyncRepositoryHooks added in v1.1.0

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

func TestPullRequests()

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

func ToggleUserOpenIDVisibility added in v1.2.0

func ToggleUserOpenIDVisibility(id int64) (err error)

ToggleUserOpenIDVisibility toggles visibility of an openid address of given user.

func TotalTimes added in v1.3.0

func TotalTimes(options FindTrackedTimesOptions) (map[*User]string, error)

TotalTimes returns the spent time for each user by an issue

func TransferOwnership

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

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

func TransferRepoAction

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

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

UnfollowUser unmarks someone as another's follower.

func UpdateAPIAssignee added in v1.5.0

func UpdateAPIAssignee(issue *Issue, oneAssignee string, multipleAssignees []string, doer *User) (err error)

UpdateAPIAssignee is a helper function to add or delete one or multiple issue assignee(s) Deleting is done the Github way (quote from their api documentation): https://developer.github.com/v3/issues/#edit-an-issue "assignees" (array): Logins for Users to assign to this issue. Pass one or more user logins to replace the set of assignees on this Issue. Send an empty array ([]) to clear all assignees from the Issue.

func UpdateAccessToken

func UpdateAccessToken(t *AccessToken) error

UpdateAccessToken updates information of access token.

func UpdateAssignee added in v1.5.0

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

UpdateAssignee deletes or adds an assignee to an issue

func UpdateAttachment added in v1.5.0

func UpdateAttachment(atta *Attachment) error

UpdateAttachment updates the given attachment in database

func UpdateComment

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

UpdateComment updates information of comment.

func UpdateDeployKey

func UpdateDeployKey(key *DeployKey) error

UpdateDeployKey updates deploy key information.

func UpdateDeployKeyCols added in v1.4.0

func UpdateDeployKeyCols(key *DeployKey, cols ...string) error

UpdateDeployKeyCols updates deploy key information in the specified columns.

func UpdateHookTask

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

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

UpdateIssueCols only updates values of specific columns for given issue.

func UpdateIssueDeadline added in v1.5.0

func UpdateIssueDeadline(issue *Issue, deadlineUnix util.TimeStamp, doer *User) (err error)

UpdateIssueDeadline updates an issue deadline and adds comments. Setting a deadline to 0 means deleting it.

func UpdateIssueIndexer added in v1.1.0

func UpdateIssueIndexer(issueID int64)

UpdateIssueIndexer add/update an issue to the issue indexer

func UpdateIssueIndexerCols added in v1.4.0

func UpdateIssueIndexerCols(issueID int64, cols ...string)

UpdateIssueIndexerCols update an issue in the issue indexer, given changes to the specified columns

func UpdateIssueMentions

func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error

UpdateIssueMentions extracts mentioned people from content and updates issue-user relations for them.

func UpdateIssueUserByRead

func UpdateIssueUserByRead(uid, issueID int64) error

UpdateIssueUserByRead updates issue-user relation for reading.

func UpdateIssueUsersByMentions

func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error

UpdateIssueUsersByMentions updates issue-user pairs by mentioning.

func UpdateIssuesCommit

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

UpdateIssuesCommit checks if issues are manipulated by commit message.

func UpdateLabel

func UpdateLabel(l *Label) error

UpdateLabel updates label information.

func UpdateLocalCopyBranch

func UpdateLocalCopyBranch(repoPath, localPath, branch string) error

UpdateLocalCopyBranch pulls latest changes of given branch from repoPath to localPath. It creates a new clone if local copy does not exist. This function checks out target branch by default, it is safe to assume subsequent operations are operating against target branch when caller has confidence for no race condition.

func UpdateMilestone

func UpdateMilestone(m *Milestone) error

UpdateMilestone updates information of given milestone.

func UpdateMirror

func UpdateMirror(m *Mirror) error

UpdateMirror updates the mirror

func UpdateNotificationStatuses added in v1.4.0

func UpdateNotificationStatuses(user *User, currentStatus NotificationStatus, desiredStatus NotificationStatus) error

UpdateNotificationStatuses updates the statuses of all of a user's notifications that are of the currentStatus type to the desiredStatus

func UpdateProtectBranch added in v1.3.0

func UpdateProtectBranch(repo *Repository, protectBranch *ProtectedBranch, whitelistUserIDs, whitelistTeamIDs, mergeWhitelistUserIDs, mergeWhitelistTeamIDs []int64) (err error)

UpdateProtectBranch saves branch protection options of 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 UpdatePublicKeyUpdated added in v1.2.0

func UpdatePublicKeyUpdated(id int64) error

UpdatePublicKeyUpdated updates public key use time.

func UpdateRelease

func UpdateRelease(doer *User, gitRepo *git.Repository, rel *Release, attachmentUUIDs []string) (err error)

UpdateRelease updates information of a release.

func UpdateRepoIndexer added in v1.3.0

func UpdateRepoIndexer(repo *Repository)

UpdateRepoIndexer update a repository's entries in the indexer

func UpdateRepository

func UpdateRepository(repo *Repository, visibilityChanged bool) (err error)

UpdateRepository updates a repository

func UpdateRepositoryUnits added in v1.1.0

func UpdateRepositoryUnits(repo *Repository, units []RepoUnit) (err error)

UpdateRepositoryUnits updates a repository's units

func UpdateSource

func UpdateSource(source *LoginSource) error

UpdateSource updates a LoginSource record in DB.

func UpdateTeam

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

UpdateTeam updates information of team.

func UpdateTeamUnits added in v1.5.0

func UpdateTeamUnits(team *Team, units []TeamUnit) (err error)

UpdateTeamUnits updates a teams's units

func UpdateTwoFactor added in v1.1.0

func UpdateTwoFactor(t *TwoFactor) error

UpdateTwoFactor updates a two-factor authentication token.

func UpdateUser

func UpdateUser(u *User) error

UpdateUser updates user's information.

func UpdateUserCols added in v1.2.0

func UpdateUserCols(u *User, cols ...string) error

UpdateUserCols update user according special columns

func UpdateUserSetting added in v1.1.0

func UpdateUserSetting(u *User) error

UpdateUserSetting updates user's settings.

func UpdateWebhook

func UpdateWebhook(w *Webhook) error

UpdateWebhook updates information of webhook.

func UpdateWebhookLastStatus added in v1.3.0

func UpdateWebhookLastStatus(w *Webhook) error

UpdateWebhookLastStatus updates last status of webhook.

func UploadLocalPath

func UploadLocalPath(uuid string) string

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

func UserPath

func UserPath(userName string) string

UserPath returns the path absolute path of user repositories.

func ValidateCommitsWithEmails

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

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

func ValidateTopic added in v1.5.0

func ValidateTopic(topic string) bool

ValidateTopic checks topics by length and match pattern rules

func WatchRepo

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

WatchRepo watch or unwatch repository.

func WikiFilenameToName added in v1.4.0

func WikiFilenameToName(filename string) (string, error)

WikiFilenameToName converts a wiki filename to its corresponding page name.

func WikiNameToFilename added in v1.4.0

func WikiNameToFilename(name string) string

WikiNameToFilename converts a wiki name to its corresponding filename.

func WikiNameToSubURL added in v1.4.0

func WikiNameToSubURL(name string) string

WikiNameToSubURL converts a wiki name to its corresponding sub-URL.

func WikiPath

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 `xorm:"pk autoincr"`
	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

type AccessMode int

AccessMode specifies the users access mode

const (
	// AccessModeNone no access
	AccessModeNone AccessMode = iota // 0
	// AccessModeRead read access
	AccessModeRead // 1
	// AccessModeWrite write access
	AccessModeWrite // 2
	// AccessModeAdmin admin access
	AccessModeAdmin // 3
	// AccessModeOwner owner access
	AccessModeOwner // 4
)

func AccessLevel

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

func ParseAccessMode(permission string) AccessMode

ParseAccessMode returns corresponding access mode to given permission string.

func (AccessMode) String

func (mode AccessMode) String() string

type AccessToken

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

	CreatedUnix       util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix       util.TimeStamp `xorm:"INDEX updated"`
	HasRecentActivity bool           `xorm:"-"`
	HasUsed           bool           `xorm:"-"`
}

AccessToken represents a personal access token.

func GetAccessTokenBySHA

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

GetAccessTokenBySHA returns access token by given sha1.

func ListAccessTokens

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

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

func (*AccessToken) AfterLoad added in v1.3.0

func (t *AccessToken) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

type AccessibleReposEnvironment added in v1.1.0

type AccessibleReposEnvironment interface {
	CountRepos() (int64, error)
	RepoIDs(page, pageSize int) ([]int64, error)
	Repos(page, pageSize int) ([]*Repository, error)
	MirrorRepos() ([]*Repository, error)
}

AccessibleReposEnvironment operations involving the repositories that are accessible to a particular user

type Action

type Action struct {
	ID          int64 `xorm:"pk autoincr"`
	UserID      int64 `xorm:"INDEX"` // Receiver user id.
	OpType      ActionType
	ActUserID   int64       `xorm:"INDEX"` // Action user id.
	ActUser     *User       `xorm:"-"`
	RepoID      int64       `xorm:"INDEX"`
	Repo        *Repository `xorm:"-"`
	CommentID   int64       `xorm:"INDEX"`
	Comment     *Comment    `xorm:"-"`
	IsDeleted   bool        `xorm:"INDEX NOT NULL DEFAULT false"`
	RefName     string
	IsPrivate   bool           `xorm:"INDEX NOT NULL DEFAULT false"`
	Content     string         `xorm:"TEXT"`
	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
}

Action represents user operation type and other information to repository. It implemented interface base.Actioner so that can be used in template render.

func GetFeeds

func GetFeeds(opts GetFeedsOptions) ([]*Action, error)

GetFeeds returns actions according to the provided options

func (*Action) GetActAvatar added in v1.2.0

func (a *Action) GetActAvatar() string

GetActAvatar the action's user's avatar link

func (*Action) GetActUserName

func (a *Action) GetActUserName() string

GetActUserName gets the action's user name.

func (*Action) GetBranch

func (a *Action) GetBranch() string

GetBranch returns the action's repository branch.

func (a *Action) GetCommentLink() string

GetCommentLink returns link to action comment.

func (*Action) GetContent

func (a *Action) GetContent() string

GetContent returns the action's content.

func (*Action) GetCreate

func (a *Action) GetCreate() time.Time

GetCreate returns the action creation time.

func (*Action) GetIssueContent

func (a *Action) GetIssueContent() string

GetIssueContent returns the content of first issue associated with this action.

func (*Action) GetIssueInfos

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

GetIssueInfos returns a list of issues associated with the action.

func (*Action) GetIssueTitle

func (a *Action) GetIssueTitle() string

GetIssueTitle returns the title of first issue associated with the action.

func (*Action) GetOpType

func (a *Action) GetOpType() ActionType

GetOpType gets the ActionType of this action.

func (a *Action) GetRepoLink() string

GetRepoLink returns relative link to action repository.

func (*Action) GetRepoName

func (a *Action) GetRepoName() string

GetRepoName returns the name of the action repository.

func (*Action) GetRepoPath

func (a *Action) GetRepoPath() string

GetRepoPath returns the virtual path to the action repository.

func (*Action) GetRepoUserName

func (a *Action) GetRepoUserName() string

GetRepoUserName returns the name of the action repository owner.

func (*Action) ShortActUserName

func (a *Action) ShortActUserName() string

ShortActUserName gets the action's user name trimmed to max 20 chars.

func (*Action) ShortRepoName

func (a *Action) ShortRepoName() string

ShortRepoName returns the name of the action repository trimmed to max 33 chars.

func (*Action) ShortRepoPath

func (a *Action) ShortRepoPath() string

ShortRepoPath returns the virtual path to the action repository trimmed to max 20 + 1 + 33 chars.

func (*Action) ShortRepoUserName

func (a *Action) ShortRepoUserName() string

ShortRepoUserName returns the name of the action repository owner trimmed to max 20 chars.

type ActionList added in v1.4.0

type ActionList []*Action

ActionList defines a list of actions

func (ActionList) LoadAttributes added in v1.4.0

func (actions ActionList) LoadAttributes() error

LoadAttributes loads attributes of the actions

func (ActionList) LoadRepositories added in v1.4.0

func (actions ActionList) LoadRepositories() ([]*Repository, error)

LoadRepositories loads actions' all repositories

func (ActionList) LoadUsers added in v1.4.0

func (actions ActionList) LoadUsers() ([]*User, error)

LoadUsers loads actions' all users

type ActionType

type ActionType int

ActionType represents the type of an action.

const (
	ActionCreateRepo        ActionType = iota + 1 // 1
	ActionRenameRepo                              // 2
	ActionStarRepo                                // 3
	ActionWatchRepo                               // 4
	ActionCommitRepo                              // 5
	ActionCreateIssue                             // 6
	ActionCreatePullRequest                       // 7
	ActionTransferRepo                            // 8
	ActionPushTag                                 // 9
	ActionCommentIssue                            // 10
	ActionMergePullRequest                        // 11
	ActionCloseIssue                              // 12
	ActionReopenIssue                             // 13
	ActionClosePullRequest                        // 14
	ActionReopenPullRequest                       // 15
	ActionDeleteTag                               // 16
	ActionDeleteBranch                            // 17
)

Possible action types.

type ActivityStats added in v1.3.0

type ActivityStats struct {
	OpenedPRs                   PullRequestList
	OpenedPRAuthorCount         int64
	MergedPRs                   PullRequestList
	MergedPRAuthorCount         int64
	OpenedIssues                IssueList
	OpenedIssueAuthorCount      int64
	ClosedIssues                IssueList
	ClosedIssueAuthorCount      int64
	UnresolvedIssues            IssueList
	PublishedReleases           []*Release
	PublishedReleaseAuthorCount int64
}

ActivityStats represets issue and pull request information.

func GetActivityStats added in v1.3.0

func GetActivityStats(repoID int64, timeFrom time.Time, releases, issues, prs bool) (*ActivityStats, error)

GetActivityStats return stats for repository at given time range

func (*ActivityStats) ActiveIssueCount added in v1.3.0

func (stats *ActivityStats) ActiveIssueCount() int

ActiveIssueCount returns total active issue count

func (*ActivityStats) ActivePRCount added in v1.3.0

func (stats *ActivityStats) ActivePRCount() int

ActivePRCount returns total active pull request count

func (*ActivityStats) ClosedIssueCount added in v1.3.0

func (stats *ActivityStats) ClosedIssueCount() int

ClosedIssueCount returns closed issue count

func (*ActivityStats) ClosedIssuePerc added in v1.3.0

func (stats *ActivityStats) ClosedIssuePerc() int

ClosedIssuePerc returns closed issue count percent from total active

func (*ActivityStats) FillIssues added in v1.3.0

func (stats *ActivityStats) FillIssues(repoID int64, fromTime time.Time) error

FillIssues returns issue information for activity page

func (*ActivityStats) FillPullRequests added in v1.3.0

func (stats *ActivityStats) FillPullRequests(repoID int64, fromTime time.Time) error

FillPullRequests returns pull request information for activity page

func (*ActivityStats) FillReleases added in v1.3.0

func (stats *ActivityStats) FillReleases(repoID int64, fromTime time.Time) error

FillReleases returns release information for activity page

func (*ActivityStats) FillUnresolvedIssues added in v1.3.0

func (stats *ActivityStats) FillUnresolvedIssues(repoID int64, fromTime time.Time, issues, prs bool) error

FillUnresolvedIssues returns unresolved issue and pull request information for activity page

func (*ActivityStats) MergedPRCount added in v1.3.0

func (stats *ActivityStats) MergedPRCount() int

MergedPRCount returns merged pull request count

func (*ActivityStats) MergedPRPerc added in v1.3.0

func (stats *ActivityStats) MergedPRPerc() int

MergedPRPerc returns merged pull request percent from total active

func (*ActivityStats) OpenedIssueCount added in v1.3.0

func (stats *ActivityStats) OpenedIssueCount() int

OpenedIssueCount returns open issue count

func (*ActivityStats) OpenedIssuePerc added in v1.3.0

func (stats *ActivityStats) OpenedIssuePerc() int

OpenedIssuePerc returns open issue count percent from total active

func (*ActivityStats) OpenedPRCount added in v1.3.0

func (stats *ActivityStats) OpenedPRCount() int

OpenedPRCount returns opened pull request count

func (*ActivityStats) OpenedPRPerc added in v1.3.0

func (stats *ActivityStats) OpenedPRPerc() int

OpenedPRPerc returns opened pull request percents from total active

func (*ActivityStats) PublishedReleaseCount added in v1.3.0

func (stats *ActivityStats) PublishedReleaseCount() int

PublishedReleaseCount returns published release count

func (*ActivityStats) UnresolvedIssueCount added in v1.3.0

func (stats *ActivityStats) UnresolvedIssueCount() int

UnresolvedIssueCount returns unresolved issue and pull request count

type Attachment

type Attachment struct {
	ID            int64  `xorm:"pk autoincr"`
	UUID          string `xorm:"uuid UNIQUE"`
	IssueID       int64  `xorm:"INDEX"`
	ReleaseID     int64  `xorm:"INDEX"`
	CommentID     int64
	Name          string
	DownloadCount int64          `xorm:"DEFAULT 0"`
	Size          int64          `xorm:"DEFAULT 0"`
	CreatedUnix   util.TimeStamp `xorm:"created"`
}

Attachment represent a attachment of issue/comment/release.

func GetAttachmentByID added in v1.5.0

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

GetAttachmentByID returns attachment by given id

func GetAttachmentByUUID

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

GetAttachmentByUUID returns attachment by given UUID.

func GetAttachmentsByCommentID

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

GetAttachmentsByCommentID returns all attachments if comment by given ID.

func GetAttachmentsByIssueID

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

GetAttachmentsByIssueID returns all attachments of an issue.

func NewAttachment

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

NewAttachment creates a new attachment object.

func (*Attachment) APIFormat added in v1.5.0

func (a *Attachment) APIFormat() *api.Attachment

APIFormat converts models.Attachment to api.Attachment

func (*Attachment) DownloadURL added in v1.5.0

func (a *Attachment) DownloadURL() string

DownloadURL returns the download url of the attached file

func (*Attachment) IncreaseDownloadCount added in v1.2.0

func (a *Attachment) IncreaseDownloadCount() error

IncreaseDownloadCount is update download count + 1

func (*Attachment) LocalPath

func (a *Attachment) LocalPath() string

LocalPath returns where attachment is stored in local file system.

type Branch

type Branch struct {
	Path string
	Name string
}

Branch holds the branch information

func GetBranchesByPath

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

GetBranchesByPath returns a branch by it's path

func (*Branch) GetCommit

func (branch *Branch) GetCommit() (*git.Commit, error)

GetCommit returns all the commits of a branch

type CloneLink struct {
	SSH   string
	HTTPS string
	Git   string
}

CloneLink represents different types of clone URLs of repository.

type Collaboration

type Collaboration struct {
	ID     int64      `xorm:"pk autoincr"`
	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

func (c *Collaboration) ModeI18nKey() string

ModeI18nKey returns the collaboration mode I18n Key

type Collaborator

type Collaborator struct {
	*User
	Collaboration *Collaboration
}

Collaborator represents a user with collaboration details.

type Comment

type Comment struct {
	ID              int64 `xorm:"pk autoincr"`
	Type            CommentType
	PosterID        int64  `xorm:"INDEX"`
	Poster          *User  `xorm:"-"`
	IssueID         int64  `xorm:"INDEX"`
	Issue           *Issue `xorm:"-"`
	LabelID         int64
	Label           *Label `xorm:"-"`
	OldMilestoneID  int64
	MilestoneID     int64
	OldMilestone    *Milestone `xorm:"-"`
	Milestone       *Milestone `xorm:"-"`
	AssigneeID      int64
	RemovedAssignee bool
	Assignee        *User `xorm:"-"`
	OldTitle        string
	NewTitle        string

	CommitID        int64
	Line            int64
	Content         string `xorm:"TEXT"`
	RenderedContent string `xorm:"-"`

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`

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

	Attachments []*Attachment `xorm:"-"`
	Reactions   ReactionList  `xorm:"-"`

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

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

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

CreateIssueComment creates a plain issue comment.

func FindComments added in v1.2.0

func FindComments(opts FindCommentsOptions) ([]*Comment, error)

FindComments returns all comments according options

func GetCommentByID

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

GetCommentByID returns the comment by given ID.

func GetCommentsByIssueID

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

GetCommentsByIssueID returns all comments of an issue.

func GetCommentsByIssueIDSince

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 v1.0.0

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

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

APIFormat converts a Comment to the api.Comment format

func (*Comment) AfterDelete

func (c *Comment) AfterDelete()

AfterDelete is invoked from XORM after the object is deleted.

func (*Comment) AfterLoad added in v1.3.0

func (c *Comment) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*Comment) EventTag

func (c *Comment) EventTag() string

EventTag returns unique event hash tag for comment.

func (*Comment) HTMLURL added in v1.0.0

func (c *Comment) HTMLURL() string

HTMLURL formats a URL-string to the issue-comment

func (*Comment) HashTag

func (c *Comment) HashTag() string

HashTag returns unique hash tag for comment.

func (*Comment) IssueURL added in v1.0.0

func (c *Comment) IssueURL() string

IssueURL formats a URL-string to the issue

func (*Comment) LoadAssigneeUser added in v1.5.0

func (c *Comment) LoadAssigneeUser() error

LoadAssigneeUser if comment.Type is CommentTypeAssignees, then load assignees

func (*Comment) LoadIssue added in v1.5.0

func (c *Comment) LoadIssue() (err error)

LoadIssue loads issue from database

func (*Comment) LoadLabel added in v1.1.0

func (c *Comment) LoadLabel() error

LoadLabel if comment.Type is CommentTypeLabel, then load Label

func (*Comment) LoadMilestone added in v1.1.0

func (c *Comment) LoadMilestone() error

LoadMilestone if comment.Type is CommentTypeMilestone, then load milestone

func (*Comment) LoadReactions added in v1.4.0

func (c *Comment) LoadReactions() error

LoadReactions loads comment reactions

func (*Comment) MailParticipants

func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error)

MailParticipants sends new comment emails to repository watchers and mentioned people.

func (*Comment) PRURL added in v1.0.0

func (c *Comment) PRURL() string

PRURL formats a URL-string to the pull-request

type CommentTag

type CommentTag int

CommentTag defines comment tag type

const (
	CommentTagNone CommentTag = iota
	CommentTagPoster
	CommentTagWriter
	CommentTagOwner
)

Enumerate all the comment tag types

type CommentType

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)
	CommentTypeComment CommentType = iota
	CommentTypeReopen
	CommentTypeClose

	// References.
	CommentTypeIssueRef
	// Reference from a commit (not part of a pull request)
	CommentTypeCommitRef
	// Reference from a comment
	CommentTypeCommentRef
	// Reference from a pull request
	CommentTypePullRef
	// Labels changed
	CommentTypeLabel
	// Milestone changed
	CommentTypeMilestone
	// Assignees changed
	CommentTypeAssignees
	// Change Title
	CommentTypeChangeTitle
	// Delete Branch
	CommentTypeDeleteBranch
	// Start a stopwatch for time tracking
	CommentTypeStartTracking
	// Stop a stopwatch for time tracking
	CommentTypeStopTracking
	// Add time manual for time tracking
	CommentTypeAddTimeManual
	// Cancel a stopwatch for time tracking
	CommentTypeCancelTracking
	// Added a due date
	CommentTypeAddedDeadline
	// Modified the due date
	CommentTypeModifiedDeadline
	// Removed a due date
	CommentTypeRemovedDeadline
)

Enumerate all the comment types

const (
	CommentTypeUnknown CommentType = -1
)

define unknown comment type

type CommitRepoActionOptions

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

CommitRepoActionOptions represent options of a new commit action.

type CommitStatus added in v1.2.0

type CommitStatus struct {
	ID          int64             `xorm:"pk autoincr"`
	Index       int64             `xorm:"INDEX UNIQUE(repo_sha_index)"`
	RepoID      int64             `xorm:"INDEX UNIQUE(repo_sha_index)"`
	Repo        *Repository       `xorm:"-"`
	State       CommitStatusState `xorm:"VARCHAR(7) NOT NULL"`
	SHA         string            `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"`
	TargetURL   string            `xorm:"TEXT"`
	Description string            `xorm:"TEXT"`
	Context     string            `xorm:"TEXT"`
	Creator     *User             `xorm:"-"`
	CreatorID   int64

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

CommitStatus holds a single Status of a single Commit

func CalcCommitStatus added in v1.3.0

func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus

CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc

func GetCommitStatus added in v1.2.0

func GetCommitStatus(repo *Repository, sha string, status *CommitStatus) (*CommitStatus, error)

GetCommitStatus populates a given status for a given commit. NOTE: If ID or Index isn't given, and only Context, TargetURL and/or Description

is given, the CommitStatus created _last_ will be returned.

func GetCommitStatuses added in v1.2.0

func GetCommitStatuses(repo *Repository, sha string, page int) ([]*CommitStatus, error)

GetCommitStatuses returns all statuses for a given commit.

func GetLatestCommitStatus added in v1.2.0

func GetLatestCommitStatus(repo *Repository, sha string, page int) ([]*CommitStatus, error)

GetLatestCommitStatus returns all statuses with a unique context for a given commit.

func (*CommitStatus) APIFormat added in v1.2.0

func (status *CommitStatus) APIFormat() *api.Status

APIFormat assumes some fields assigned with values: Required - Repo, Creator

func (*CommitStatus) APIURL added in v1.2.0

func (status *CommitStatus) APIURL() string

APIURL returns the absolute APIURL to this commit-status.

type CommitStatusState added in v1.2.0

type CommitStatusState string

CommitStatusState holds the state of a Status It can be "pending", "success", "error", "failure", and "warning"

const (
	// CommitStatusPending is for when the Status is Pending
	CommitStatusPending CommitStatusState = "pending"
	// CommitStatusSuccess is for when the Status is Success
	CommitStatusSuccess CommitStatusState = "success"
	// CommitStatusError is for when the Status is Error
	CommitStatusError CommitStatusState = "error"
	// CommitStatusFailure is for when the Status is Failure
	CommitStatusFailure CommitStatusState = "failure"
	// CommitStatusWarning is for when the Status is Warning
	CommitStatusWarning CommitStatusState = "warning"
)

func (CommitStatusState) IsWorseThan added in v1.2.0

func (css CommitStatusState) IsWorseThan(css2 CommitStatusState) bool

IsWorseThan returns true if this State is worse than the given State

type CommitVerification added in v1.2.0

type CommitVerification struct {
	Verified    bool
	Reason      string
	SigningUser *User
	SigningKey  *GPGKey
}

CommitVerification represents a commit validation of signature

func ParseCommitWithSignature added in v1.2.0

func ParseCommitWithSignature(c *git.Commit) *CommitVerification

ParseCommitWithSignature check if signature is good against keystore.

type CreateCommentOptions

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

	OldMilestoneID  int64
	MilestoneID     int64
	AssigneeID      int64
	RemovedAssignee bool
	OldTitle        string
	NewTitle        string
	CommitID        int64
	CommitSHA       string
	LineNum         int64
	Content         string
	Attachments     []string // UUIDs of attachments
}

CreateCommentOptions defines options for creating comment

type CreateRepoOptions

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

CreateRepoOptions contains the create repository options

type DeleteRepoFileOptions

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

DeleteRepoFileOptions holds the repository delete file options

type DeletedBranch added in v1.3.0

type DeletedBranch struct {
	ID          int64          `xorm:"pk autoincr"`
	RepoID      int64          `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name        string         `xorm:"UNIQUE(s) NOT NULL"`
	Commit      string         `xorm:"UNIQUE(s) NOT NULL"`
	DeletedByID int64          `xorm:"INDEX"`
	DeletedBy   *User          `xorm:"-"`
	DeletedUnix util.TimeStamp `xorm:"INDEX created"`
}

DeletedBranch struct

func (*DeletedBranch) LoadUser added in v1.3.0

func (deletedBranch *DeletedBranch) LoadUser()

LoadUser loads the user that deleted the branch When there's no user found it returns a NewGhostUser

type DeployKey

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

	Mode AccessMode `xorm:"NOT NULL DEFAULT 1"`

	CreatedUnix       util.TimeStamp `xorm:"created"`
	UpdatedUnix       util.TimeStamp `xorm:"updated"`
	HasRecentActivity bool           `xorm:"-"`
	HasUsed           bool           `xorm:"-"`
}

DeployKey represents deploy key information and its relation with repository.

func AddDeployKey

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

AddDeployKey add new deploy key to database and authorized_keys file.

func GetDeployKeyByID

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

GetDeployKeyByID returns deploy key by given ID.

func GetDeployKeyByRepo

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

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

func ListDeployKeys

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

ListDeployKeys returns all deploy keys by given repository ID.

func (*DeployKey) AfterLoad added in v1.3.0

func (key *DeployKey) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*DeployKey) GetContent

func (key *DeployKey) GetContent() error

GetContent gets associated public key content.

func (*DeployKey) IsReadOnly added in v1.4.0

func (key *DeployKey) IsReadOnly() bool

IsReadOnly checks if the key can only be used for read operations

type Diff

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

Diff represents a difference between two git trees.

func GetDiffCommit

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

GetDiffCommit builds a Diff representing the given commitID.

func GetDiffRange

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

GetDiffRange builds a Diff between two commits of a repository. passing the empty string as beforeCommitID returns a diff from the parent commit.

func ParsePatch

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

ParsePatch builds a Diff object from a io.Reader and some parameters. TODO: move this function to gogits/git-module

func (*Diff) NumFiles

func (diff *Diff) NumFiles() int

NumFiles returns number of files changes in a diff.

type DiffFile

type DiffFile struct {
	Name               string
	OldName            string
	Index              int
	Addition, Deletion int
	Type               DiffFileType
	IsCreated          bool
	IsDeleted          bool
	IsBin              bool
	IsLFSFile          bool
	IsRenamed          bool
	IsSubmodule        bool
	Sections           []*DiffSection
	IsIncomplete       bool
}

DiffFile represents a file diff.

func (*DiffFile) GetHighlightClass

func (diffFile *DiffFile) GetHighlightClass() string

GetHighlightClass returns highlight class for a filename.

func (*DiffFile) GetType

func (diffFile *DiffFile) GetType() int

GetType returns type of diff file.

type DiffFileType

type DiffFileType uint8

DiffFileType represents the type of a DiffFile.

const (
	DiffFileAdd DiffFileType = iota + 1
	DiffFileChange
	DiffFileDel
	DiffFileRename
)

DiffFileType possible values.

type DiffLine

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

DiffLine represents a line difference in a DiffSection.

func (*DiffLine) GetType

func (d *DiffLine) GetType() int

GetType returns the type of a DiffLine.

type DiffLineType

type DiffLineType uint8

DiffLineType represents the type of a DiffLine.

const (
	DiffLinePlain DiffLineType = iota + 1
	DiffLineAdd
	DiffLineDel
	DiffLineSection
)

DiffLineType possible values.

type DiffSection

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

DiffSection represents a section of a DiffFile.

func (*DiffSection) GetComputedInlineDiffFor

func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) template.HTML

GetComputedInlineDiffFor computes inline diff for the given line.

func (*DiffSection) GetLine

func (diffSection *DiffSection) GetLine(lineType DiffLineType, idx int) *DiffLine

GetLine gets a specific line by type (add or del) and file line number

type DingtalkPayload added in v1.4.0

type DingtalkPayload dingtalk.Payload

DingtalkPayload represents

func GetDingtalkPayload added in v1.4.0

func GetDingtalkPayload(p api.Payloader, event HookEventType, meta string) (*DingtalkPayload, error)

GetDingtalkPayload converts a ding talk webhook into a DingtalkPayload

func (*DingtalkPayload) JSONPayload added in v1.4.0

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

JSONPayload Marshals the DingtalkPayload to json

func (*DingtalkPayload) SetSecret added in v1.4.0

func (p *DingtalkPayload) SetSecret(_ string)

SetSecret sets the dingtalk secret

type DiscordEmbed added in v1.3.0

type DiscordEmbed struct {
	Title       string              `json:"title"`
	Description string              `json:"description"`
	URL         string              `json:"url"`
	Color       int                 `json:"color"`
	Footer      DiscordEmbedFooter  `json:"footer"`
	Author      DiscordEmbedAuthor  `json:"author"`
	Fields      []DiscordEmbedField `json:"fields"`
}

DiscordEmbed is for Embed Structure

type DiscordEmbedAuthor added in v1.3.0

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

DiscordEmbedAuthor for Embed Author Structure

type DiscordEmbedField added in v1.3.0

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

DiscordEmbedField for Embed Field Structure

type DiscordEmbedFooter added in v1.3.0

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

DiscordEmbedFooter for Embed Footer Structure.

type DiscordMeta added in v1.3.0

type DiscordMeta struct {
	Username string `json:"username"`
	IconURL  string `json:"icon_url"`
}

DiscordMeta contains the discord metadata

type DiscordPayload added in v1.3.0

type DiscordPayload struct {
	Wait      bool           `json:"wait"`
	Content   string         `json:"content"`
	Username  string         `json:"username"`
	AvatarURL string         `json:"avatar_url"`
	TTS       bool           `json:"tts"`
	Embeds    []DiscordEmbed `json:"embeds"`
}

DiscordPayload represents

func GetDiscordPayload added in v1.3.0

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

GetDiscordPayload converts a discord webhook into a DiscordPayload

func (*DiscordPayload) JSONPayload added in v1.3.0

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

JSONPayload Marshals the DiscordPayload to json

func (*DiscordPayload) SetSecret added in v1.3.0

func (p *DiscordPayload) SetSecret(_ string)

SetSecret sets the discord secret

type EmailAddress

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

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

func GetEmailAddresses

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

GetEmailAddresses returns all email addresses belongs to given user.

func VerifyActiveEmailCode

func VerifyActiveEmailCode(code, email string) *EmailAddress

VerifyActiveEmailCode verifies active email code when active account

func (*EmailAddress) Activate

func (email *EmailAddress) Activate() error

Activate activates the email address to given user.

type Engine

type Engine interface {
	Table(tableNameOrBean interface{}) *xorm.Session
	Count(...interface{}) (int64, error)
	Decr(column string, arg ...interface{}) *xorm.Session
	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
	Incr(column string, arg ...interface{}) *xorm.Session
	Insert(...interface{}) (int64, error)
	InsertOne(interface{}) (int64, error)
	Iterate(interface{}, xorm.IterFunc) error
	Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *xorm.Session
	SQL(interface{}, ...interface{}) *xorm.Session
	Where(interface{}, ...interface{}) *xorm.Session
}

Engine represents a xorm engine or session.

type ErrAccessTokenEmpty

type ErrAccessTokenEmpty struct {
}

ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.

func (ErrAccessTokenEmpty) Error

func (err ErrAccessTokenEmpty) Error() string

type ErrAccessTokenNotExist

type ErrAccessTokenNotExist struct {
	SHA string
}

ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.

func (ErrAccessTokenNotExist) Error

func (err ErrAccessTokenNotExist) Error() string

type ErrAttachmentNotExist

type ErrAttachmentNotExist struct {
	ID   int64
	UUID string
}

ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.

func (ErrAttachmentNotExist) Error

func (err ErrAttachmentNotExist) Error() string

type ErrBranchAlreadyExists added in v1.3.0

type ErrBranchAlreadyExists struct {
	BranchName string
}

ErrBranchAlreadyExists represents an error that branch with such name already exists

func (ErrBranchAlreadyExists) Error added in v1.3.0

func (err ErrBranchAlreadyExists) Error() string

type ErrBranchNameConflict added in v1.3.0

type ErrBranchNameConflict struct {
	BranchName string
}

ErrBranchNameConflict represents an error that branch name conflicts with other branch

func (ErrBranchNameConflict) Error added in v1.3.0

func (err ErrBranchNameConflict) Error() string

type ErrBranchNotExist

type ErrBranchNotExist struct {
	Name string
}

ErrBranchNotExist represents a "BranchNotExist" kind of error.

func (ErrBranchNotExist) Error

func (err ErrBranchNotExist) Error() string

type ErrCommentNotExist

type ErrCommentNotExist struct {
	ID      int64
	IssueID int64
}

ErrCommentNotExist represents a "CommentNotExist" kind of error.

func (ErrCommentNotExist) Error

func (err ErrCommentNotExist) Error() string

type ErrDeployKeyAlreadyExist

type ErrDeployKeyAlreadyExist struct {
	KeyID  int64
	RepoID int64
}

ErrDeployKeyAlreadyExist represents a "DeployKeyAlreadyExist" kind of error.

func (ErrDeployKeyAlreadyExist) Error

func (err ErrDeployKeyAlreadyExist) Error() string

type ErrDeployKeyNameAlreadyUsed

type ErrDeployKeyNameAlreadyUsed struct {
	RepoID int64
	Name   string
}

ErrDeployKeyNameAlreadyUsed represents a "DeployKeyNameAlreadyUsed" kind of error.

func (ErrDeployKeyNameAlreadyUsed) Error

func (err ErrDeployKeyNameAlreadyUsed) Error() string

type ErrDeployKeyNotExist

type ErrDeployKeyNotExist struct {
	ID     int64
	KeyID  int64
	RepoID int64
}

ErrDeployKeyNotExist represents a "DeployKeyNotExist" kind of error.

func (ErrDeployKeyNotExist) Error

func (err ErrDeployKeyNotExist) Error() string

type ErrEmailAlreadyUsed

type ErrEmailAlreadyUsed struct {
	Email string
}

ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.

func (ErrEmailAlreadyUsed) Error

func (err ErrEmailAlreadyUsed) Error() string

type ErrExternalLoginUserAlreadyExist added in v1.1.0

type ErrExternalLoginUserAlreadyExist struct {
	ExternalID    string
	UserID        int64
	LoginSourceID int64
}

ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.

func (ErrExternalLoginUserAlreadyExist) Error added in v1.1.0

type ErrExternalLoginUserNotExist added in v1.1.0

type ErrExternalLoginUserNotExist struct {
	UserID        int64
	LoginSourceID int64
}

ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.

func (ErrExternalLoginUserNotExist) Error added in v1.1.0

type ErrGPGKeyAccessDenied added in v1.2.0

type ErrGPGKeyAccessDenied struct {
	UserID int64
	KeyID  int64
}

ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error.

func (ErrGPGKeyAccessDenied) Error added in v1.2.0

func (err ErrGPGKeyAccessDenied) Error() string

Error pretty-prints an error of type ErrGPGKeyAccessDenied.

type ErrGPGKeyIDAlreadyUsed added in v1.2.0

type ErrGPGKeyIDAlreadyUsed struct {
	KeyID string
}

ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error.

func (ErrGPGKeyIDAlreadyUsed) Error added in v1.2.0

func (err ErrGPGKeyIDAlreadyUsed) Error() string

type ErrGPGKeyNotExist added in v1.2.0

type ErrGPGKeyNotExist struct {
	ID int64
}

ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error.

func (ErrGPGKeyNotExist) Error added in v1.2.0

func (err ErrGPGKeyNotExist) Error() string

type ErrGPGKeyParsing added in v1.2.0

type ErrGPGKeyParsing struct {
	ParseError error
}

ErrGPGKeyParsing represents a "ErrGPGKeyParsing" kind of error.

func (ErrGPGKeyParsing) Error added in v1.2.0

func (err ErrGPGKeyParsing) Error() string

type ErrGPGNoEmailFound added in v1.2.3

type ErrGPGNoEmailFound struct {
	FailedEmails []string
}

ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.

func (ErrGPGNoEmailFound) Error added in v1.2.3

func (err ErrGPGNoEmailFound) Error() string

type ErrInvalidCloneAddr

type ErrInvalidCloneAddr struct {
	IsURLError         bool
	IsInvalidPath      bool
	IsPermissionDenied bool
}

ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.

func (ErrInvalidCloneAddr) Error

func (err ErrInvalidCloneAddr) Error() string

type ErrInvalidMergeStyle added in v1.4.0

type ErrInvalidMergeStyle struct {
	ID    int64
	Style MergeStyle
}

ErrInvalidMergeStyle represents an error if merging with disabled merge strategy

func (ErrInvalidMergeStyle) Error added in v1.4.0

func (err ErrInvalidMergeStyle) Error() string

type ErrInvalidTagName

type ErrInvalidTagName struct {
	TagName string
}

ErrInvalidTagName represents a "InvalidTagName" kind of error.

func (ErrInvalidTagName) Error

func (err ErrInvalidTagName) Error() string

type ErrIssueNotExist

type ErrIssueNotExist struct {
	ID     int64
	RepoID int64
	Index  int64
}

ErrIssueNotExist represents a "IssueNotExist" kind of error.

func (ErrIssueNotExist) Error

func (err ErrIssueNotExist) Error() string

type ErrKeyAccessDenied

type ErrKeyAccessDenied struct {
	UserID int64
	KeyID  int64
	Note   string
}

ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error.

func (ErrKeyAccessDenied) Error

func (err ErrKeyAccessDenied) Error() string

type ErrKeyAlreadyExist

type ErrKeyAlreadyExist struct {
	OwnerID     int64
	Fingerprint string
	Content     string
}

ErrKeyAlreadyExist represents a "KeyAlreadyExist" kind of error.

func (ErrKeyAlreadyExist) Error

func (err ErrKeyAlreadyExist) Error() string

type ErrKeyNameAlreadyUsed

type ErrKeyNameAlreadyUsed struct {
	OwnerID int64
	Name    string
}

ErrKeyNameAlreadyUsed represents a "KeyNameAlreadyUsed" kind of error.

func (ErrKeyNameAlreadyUsed) Error

func (err ErrKeyNameAlreadyUsed) Error() string

type ErrKeyNotExist

type ErrKeyNotExist struct {
	ID int64
}

ErrKeyNotExist represents a "KeyNotExist" kind of error.

func (ErrKeyNotExist) Error

func (err ErrKeyNotExist) Error() string

type ErrKeyUnableVerify

type ErrKeyUnableVerify struct {
	Result string
}

ErrKeyUnableVerify represents a "KeyUnableVerify" kind of error.

func (ErrKeyUnableVerify) Error

func (err ErrKeyUnableVerify) Error() string

type ErrLFSLockAlreadyExist added in v1.4.0

type ErrLFSLockAlreadyExist struct {
	RepoID int64
	Path   string
}

ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.

func (ErrLFSLockAlreadyExist) Error added in v1.4.0

func (err ErrLFSLockAlreadyExist) Error() string

type ErrLFSLockNotExist added in v1.4.0

type ErrLFSLockNotExist struct {
	ID     int64
	RepoID int64
	Path   string
}

ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.

func (ErrLFSLockNotExist) Error added in v1.4.0

func (err ErrLFSLockNotExist) Error() string

type ErrLFSUnauthorizedAction added in v1.4.0

type ErrLFSUnauthorizedAction struct {
	RepoID   int64
	UserName string
	Mode     AccessMode
}

ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.

func (ErrLFSUnauthorizedAction) Error added in v1.4.0

func (err ErrLFSUnauthorizedAction) Error() string

type ErrLabelNotExist

type ErrLabelNotExist struct {
	LabelID int64
	RepoID  int64
}

ErrLabelNotExist represents a "LabelNotExist" kind of error.

func (ErrLabelNotExist) Error

func (err ErrLabelNotExist) Error() string

type ErrLastOrgOwner

type ErrLastOrgOwner struct {
	UID int64
}

ErrLastOrgOwner represents a "LastOrgOwner" kind of error.

func (ErrLastOrgOwner) Error

func (err ErrLastOrgOwner) Error() string

type ErrLoginSourceAlreadyExist

type ErrLoginSourceAlreadyExist struct {
	Name string
}

ErrLoginSourceAlreadyExist represents a "LoginSourceAlreadyExist" kind of error.

func (ErrLoginSourceAlreadyExist) Error

func (err ErrLoginSourceAlreadyExist) Error() string

type ErrLoginSourceInUse

type ErrLoginSourceInUse struct {
	ID int64
}

ErrLoginSourceInUse represents a "LoginSourceInUse" kind of error.

func (ErrLoginSourceInUse) Error

func (err ErrLoginSourceInUse) Error() string

type ErrLoginSourceNotExist

type ErrLoginSourceNotExist struct {
	ID int64
}

ErrLoginSourceNotExist represents a "LoginSourceNotExist" kind of error.

func (ErrLoginSourceNotExist) Error

func (err ErrLoginSourceNotExist) Error() string

type ErrMilestoneNotExist

type ErrMilestoneNotExist struct {
	ID     int64
	RepoID int64
}

ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.

func (ErrMilestoneNotExist) Error

func (err ErrMilestoneNotExist) Error() string

type ErrNamePatternNotAllowed

type ErrNamePatternNotAllowed struct {
	Pattern string
}

ErrNamePatternNotAllowed represents a "pattern not allowed" error.

func (ErrNamePatternNotAllowed) Error

func (err ErrNamePatternNotAllowed) Error() string

type ErrNameReserved

type ErrNameReserved struct {
	Name string
}

ErrNameReserved represents a "reserved name" error.

func (ErrNameReserved) Error

func (err ErrNameReserved) Error() string

type ErrNotAllowedToMerge added in v1.5.0

type ErrNotAllowedToMerge struct {
	Reason string
}

ErrNotAllowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it

func (ErrNotAllowedToMerge) Error added in v1.5.0

func (err ErrNotAllowedToMerge) Error() string

type ErrOpenIDAlreadyUsed added in v1.2.0

type ErrOpenIDAlreadyUsed struct {
	OpenID string
}

ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.

func (ErrOpenIDAlreadyUsed) Error added in v1.2.0

func (err ErrOpenIDAlreadyUsed) Error() string

type ErrOpenIDConnectInitialize added in v1.2.0

type ErrOpenIDConnectInitialize struct {
	OpenIDConnectAutoDiscoveryURL string
	ProviderName                  string
	Cause                         error
}

ErrOpenIDConnectInitialize represents a "OpenIDConnectInitialize" kind of error.

func (ErrOpenIDConnectInitialize) Error added in v1.2.0

func (err ErrOpenIDConnectInitialize) Error() string

type ErrOrgNotExist

type ErrOrgNotExist struct {
	ID   int64
	Name string
}

ErrOrgNotExist represents a "OrgNotExist" kind of error.

func (ErrOrgNotExist) Error added in v1.2.0

func (err ErrOrgNotExist) Error() string

type ErrPullRequestAlreadyExists added in v1.0.0

type ErrPullRequestAlreadyExists struct {
	ID         int64
	IssueID    int64
	HeadRepoID int64
	BaseRepoID int64
	HeadBranch string
	BaseBranch string
}

ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error

func (ErrPullRequestAlreadyExists) Error added in v1.0.0

func (err ErrPullRequestAlreadyExists) Error() string

Error does pretty-printing :D

type ErrPullRequestNotExist

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

ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.

func (ErrPullRequestNotExist) Error

func (err ErrPullRequestNotExist) Error() string

type ErrReachLimitOfRepo

type ErrReachLimitOfRepo struct {
	Limit int
}

ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.

func (ErrReachLimitOfRepo) Error

func (err ErrReachLimitOfRepo) Error() string

type ErrReleaseAlreadyExist

type ErrReleaseAlreadyExist struct {
	TagName string
}

ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.

func (ErrReleaseAlreadyExist) Error

func (err ErrReleaseAlreadyExist) Error() string

type ErrReleaseNotExist

type ErrReleaseNotExist struct {
	ID      int64
	TagName string
}

ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.

func (ErrReleaseNotExist) Error

func (err ErrReleaseNotExist) Error() string

type ErrRepoAlreadyExist

type ErrRepoAlreadyExist struct {
	Uname string
	Name  string
}

ErrRepoAlreadyExist represents a "RepoAlreadyExist" kind of error.

func (ErrRepoAlreadyExist) Error

func (err ErrRepoAlreadyExist) Error() string

type ErrRepoFileAlreadyExist

type ErrRepoFileAlreadyExist struct {
	FileName string
}

ErrRepoFileAlreadyExist represents a "RepoFileAlreadyExist" kind of error.

func (ErrRepoFileAlreadyExist) Error

func (err ErrRepoFileAlreadyExist) Error() string

type ErrRepoNotExist

type ErrRepoNotExist struct {
	ID        int64
	UID       int64
	OwnerName string
	Name      string
}

ErrRepoNotExist represents a "RepoNotExist" kind of error.

func (ErrRepoNotExist) Error

func (err ErrRepoNotExist) Error() string

type ErrRepoRedirectNotExist added in v1.1.0

type ErrRepoRedirectNotExist struct {
	OwnerID  int64
	RepoName string
}

ErrRepoRedirectNotExist represents a "RepoRedirectNotExist" kind of error.

func (ErrRepoRedirectNotExist) Error added in v1.1.0

func (err ErrRepoRedirectNotExist) Error() string

type ErrSSHDisabled added in v1.4.0

type ErrSSHDisabled struct {
}

ErrSSHDisabled represents an "SSH disabled" error.

func (ErrSSHDisabled) Error added in v1.4.0

func (err ErrSSHDisabled) Error() string

type ErrStopwatchNotExist added in v1.3.0

type ErrStopwatchNotExist struct {
	ID int64
}

ErrStopwatchNotExist represents a "Stopwatch Not Exist" kind of error.

func (ErrStopwatchNotExist) Error added in v1.3.0

func (err ErrStopwatchNotExist) Error() string

type ErrTagAlreadyExists added in v1.3.0

type ErrTagAlreadyExists struct {
	TagName string
}

ErrTagAlreadyExists represents an error that tag with such name already exists

func (ErrTagAlreadyExists) Error added in v1.3.0

func (err ErrTagAlreadyExists) Error() string

type ErrTeamAlreadyExist

type ErrTeamAlreadyExist struct {
	OrgID int64
	Name  string
}

ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.

func (ErrTeamAlreadyExist) Error

func (err ErrTeamAlreadyExist) Error() string

type ErrTopicNotExist added in v1.5.0

type ErrTopicNotExist struct {
	Name string
}

ErrTopicNotExist represents an error that a topic is not exist

func (ErrTopicNotExist) Error added in v1.5.0

func (err ErrTopicNotExist) Error() string

Error implements error interface

type ErrTrackedTimeNotExist added in v1.3.0

type ErrTrackedTimeNotExist struct {
	ID int64
}

ErrTrackedTimeNotExist represents a "TrackedTime Not Exist" kind of error.

func (ErrTrackedTimeNotExist) Error added in v1.3.0

func (err ErrTrackedTimeNotExist) Error() string

type ErrTwoFactorNotEnrolled added in v1.1.0

type ErrTwoFactorNotEnrolled struct {
	UID int64
}

ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication.

func (ErrTwoFactorNotEnrolled) Error added in v1.1.0

func (err ErrTwoFactorNotEnrolled) Error() string

type ErrU2FRegistrationNotExist added in v1.5.0

type ErrU2FRegistrationNotExist struct {
	ID int64
}

ErrU2FRegistrationNotExist represents a "ErrU2FRegistrationNotExist" kind of error.

func (ErrU2FRegistrationNotExist) Error added in v1.5.0

func (err ErrU2FRegistrationNotExist) Error() string

type ErrUpdateTaskNotExist

type ErrUpdateTaskNotExist struct {
	UUID string
}

ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.

func (ErrUpdateTaskNotExist) Error

func (err ErrUpdateTaskNotExist) Error() string

type ErrUploadNotExist

type ErrUploadNotExist struct {
	ID   int64
	UUID string
}

ErrUploadNotExist represents a "UploadNotExist" kind of error.

func (ErrUploadNotExist) Error

func (err ErrUploadNotExist) Error() string

type ErrUserAlreadyExist

type ErrUserAlreadyExist struct {
	Name string
}

ErrUserAlreadyExist represents a "user already exists" error.

func (ErrUserAlreadyExist) Error

func (err ErrUserAlreadyExist) Error() string

type ErrUserDoesNotHaveAccessToRepo added in v1.5.0

type ErrUserDoesNotHaveAccessToRepo struct {
	UserID   int64
	RepoName string
}

ErrUserDoesNotHaveAccessToRepo represets an error where the user doesn't has access to a given repo

func (ErrUserDoesNotHaveAccessToRepo) Error added in v1.5.0

type ErrUserHasOrgs

type ErrUserHasOrgs struct {
	UID int64
}

ErrUserHasOrgs represents a "UserHasOrgs" kind of error.

func (ErrUserHasOrgs) Error

func (err ErrUserHasOrgs) Error() string

type ErrUserNotAllowedCreateOrg added in v1.1.0

type ErrUserNotAllowedCreateOrg struct {
}

ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.

func (ErrUserNotAllowedCreateOrg) Error added in v1.1.0

func (err ErrUserNotAllowedCreateOrg) Error() string

type ErrUserNotExist

type ErrUserNotExist struct {
	UID   int64
	Name  string
	KeyID int64
}

ErrUserNotExist represents a "UserNotExist" kind of error.

func (ErrUserNotExist) Error

func (err ErrUserNotExist) Error() string

type ErrUserOwnRepos

type ErrUserOwnRepos struct {
	UID int64
}

ErrUserOwnRepos represents a "UserOwnRepos" kind of error.

func (ErrUserOwnRepos) Error

func (err ErrUserOwnRepos) Error() string

type ErrWebhookNotExist

type ErrWebhookNotExist struct {
	ID int64
}

ErrWebhookNotExist represents a "WebhookNotExist" kind of error.

func (ErrWebhookNotExist) Error

func (err ErrWebhookNotExist) Error() string

type ErrWikiAlreadyExist

type ErrWikiAlreadyExist struct {
	Title string
}

ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.

func (ErrWikiAlreadyExist) Error

func (err ErrWikiAlreadyExist) Error() string

type ErrWikiInvalidFileName added in v1.4.0

type ErrWikiInvalidFileName struct {
	FileName string
}

ErrWikiInvalidFileName represents an invalid wiki file name.

func (ErrWikiInvalidFileName) Error added in v1.4.0

func (err ErrWikiInvalidFileName) Error() string

type ErrWikiReservedName added in v1.4.0

type ErrWikiReservedName struct {
	Title string
}

ErrWikiReservedName represents a reserved name error.

func (ErrWikiReservedName) Error added in v1.4.0

func (err ErrWikiReservedName) Error() string

type ExternalLoginUser added in v1.1.0

type ExternalLoginUser struct {
	ExternalID    string `xorm:"pk NOT NULL"`
	UserID        int64  `xorm:"INDEX NOT NULL"`
	LoginSourceID int64  `xorm:"pk NOT NULL"`
}

ExternalLoginUser makes the connecting between some existing user and additional external login sources

func ListAccountLinks(user *User) ([]*ExternalLoginUser, error)

ListAccountLinks returns a map with the ExternalLoginUser and its LoginSource

type ExternalTrackerConfig added in v1.1.0

type ExternalTrackerConfig struct {
	ExternalTrackerURL    string
	ExternalTrackerFormat string
	ExternalTrackerStyle  string
}

ExternalTrackerConfig describes external tracker config

func (*ExternalTrackerConfig) FromDB added in v1.1.0

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

FromDB fills up a ExternalTrackerConfig from serialized format.

func (*ExternalTrackerConfig) ToDB added in v1.1.0

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

ToDB exports a ExternalTrackerConfig to a serialized format.

type ExternalWikiConfig added in v1.1.0

type ExternalWikiConfig struct {
	ExternalWikiURL string
}

ExternalWikiConfig describes external wiki config

func (*ExternalWikiConfig) FromDB added in v1.1.0

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

FromDB fills up a ExternalWikiConfig from serialized format.

func (*ExternalWikiConfig) ToDB added in v1.1.0

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

ToDB exports a ExternalWikiConfig to a serialized format.

type FindCommentsOptions added in v1.2.0

type FindCommentsOptions struct {
	RepoID  int64
	IssueID int64
	Since   int64
	Type    CommentType
}

FindCommentsOptions describes the conditions to Find comments

type FindReactionsOptions added in v1.4.0

type FindReactionsOptions struct {
	IssueID   int64
	CommentID int64
}

FindReactionsOptions describes the conditions to Find reactions

type FindReleasesOptions added in v1.2.0

type FindReleasesOptions struct {
	IncludeDrafts bool
	IncludeTags   bool
	TagNames      []string
}

FindReleasesOptions describes the conditions to Find releases

type FindTopicOptions added in v1.5.0

type FindTopicOptions struct {
	RepoID  int64
	Keyword string
	Limit   int
	Page    int
}

FindTopicOptions represents the options when fdin topics

type FindTrackedTimesOptions added in v1.3.0

type FindTrackedTimesOptions struct {
	IssueID      int64
	UserID       int64
	RepositoryID int64
	MilestoneID  int64
}

FindTrackedTimesOptions represent the filters for tracked times. If an ID is 0 it will be ignored.

func (*FindTrackedTimesOptions) ToCond added in v1.3.0

func (opts *FindTrackedTimesOptions) ToCond() builder.Cond

ToCond will convert each condition into a xorm-Cond

func (*FindTrackedTimesOptions) ToSession added in v1.5.0

func (opts *FindTrackedTimesOptions) ToSession(e Engine) *xorm.Session

ToSession will convert the given options to a xorm Session by using the conditions from ToCond and joining with issue table if required

type Follow

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

Follow represents relations of user and his/her followers.

type GPGKey added in v1.2.0

type GPGKey struct {
	ID                int64          `xorm:"pk autoincr"`
	OwnerID           int64          `xorm:"INDEX NOT NULL"`
	KeyID             string         `xorm:"INDEX CHAR(16) NOT NULL"`
	PrimaryKeyID      string         `xorm:"CHAR(16)"`
	Content           string         `xorm:"TEXT NOT NULL"`
	CreatedUnix       util.TimeStamp `xorm:"created"`
	ExpiredUnix       util.TimeStamp
	AddedUnix         util.TimeStamp
	SubsKey           []*GPGKey `xorm:"-"`
	Emails            []*EmailAddress
	CanSign           bool
	CanEncryptComms   bool
	CanEncryptStorage bool
	CanCertify        bool
}

GPGKey represents a GPG key.

func AddGPGKey added in v1.2.0

func AddGPGKey(ownerID int64, content string) (*GPGKey, error)

AddGPGKey adds new public key to database.

func GetGPGKeyByID added in v1.2.0

func GetGPGKeyByID(keyID int64) (*GPGKey, error)

GetGPGKeyByID returns public key by given ID.

func ListGPGKeys added in v1.2.0

func ListGPGKeys(uid int64) ([]*GPGKey, error)

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

func (*GPGKey) AfterLoad added in v1.3.0

func (key *GPGKey) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*GPGKey) BeforeInsert added in v1.2.0

func (key *GPGKey) BeforeInsert()

BeforeInsert will be invoked by XORM before inserting a record

type GetFeedsOptions added in v1.2.0

type GetFeedsOptions struct {
	RequestedUser    *User
	RequestingUserID int64
	IncludePrivate   bool // include private actions
	OnlyPerformedBy  bool // only actions performed by requested user
	IncludeDeleted   bool // include deleted actions
}

GetFeedsOptions options for retrieving feeds

type GraphItem added in v1.1.0

type GraphItem struct {
	GraphAcii    string
	Relation     string
	Branch       string
	Rev          string
	Date         string
	Author       string
	AuthorEmail  string
	ShortRev     string
	Subject      string
	OnlyRelation bool
}

GraphItem represent one commit, or one relation in timeline

type GraphItems added in v1.1.0

type GraphItems []GraphItem

GraphItems is a list of commits from all branches

func GetCommitGraph added in v1.1.0

func GetCommitGraph(r *git.Repository) (GraphItems, error)

GetCommitGraph return a list of commit (GraphItems) from all branches

type HookContentType

type HookContentType int

HookContentType is the content type of a web hook

const (
	// ContentTypeJSON is a JSON payload for web hooks
	ContentTypeJSON HookContentType = iota + 1
	// ContentTypeForm is an url-encoded form payload for web hook
	ContentTypeForm
)

func ToHookContentType

func ToHookContentType(name string) HookContentType

ToHookContentType returns HookContentType by given name.

func (HookContentType) Name

func (t HookContentType) Name() string

Name returns the name of a given web hook's content type

type HookEvent

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

type HookEventType string

HookEventType is the type of an hook event

const (
	HookEventCreate       HookEventType = "create"
	HookEventDelete       HookEventType = "delete"
	HookEventFork         HookEventType = "fork"
	HookEventPush         HookEventType = "push"
	HookEventIssues       HookEventType = "issues"
	HookEventIssueComment HookEventType = "issue_comment"
	HookEventPullRequest  HookEventType = "pull_request"
	HookEventRepository   HookEventType = "repository"
	HookEventRelease      HookEventType = "release"
)

Types of hook events

type HookEvents

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

HookEvents is a set of web hook events

type HookRequest

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

HookRequest represents hook task request information.

type HookResponse

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

type HookStatus int

HookStatus is the status of a web hook

type HookTask

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

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

HookTask represents a hook task.

func HookTasks

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

HookTasks returns a list of hook tasks by given conditions.

func (*HookTask) AfterLoad added in v1.3.0

func (t *HookTask) AfterLoad()

AfterLoad updates the webhook object upon setting a column

func (*HookTask) BeforeUpdate

func (t *HookTask) BeforeUpdate()

BeforeUpdate will be invoked by XORM before updating a record representing this object

type HookTaskType

type HookTaskType int

HookTaskType is the type of an hook task

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

Types of hook tasks

func ToHookTaskType

func ToHookTaskType(name string) HookTaskType

ToHookTaskType returns HookTaskType by given name.

func (HookTaskType) Name

func (t HookTaskType) Name() string

Name returns the name of an hook task type

type Issue

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

	DeadlineUnix util.TimeStamp `xorm:"INDEX"`

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
	ClosedUnix  util.TimeStamp `xorm:"INDEX"`

	Attachments      []*Attachment `xorm:"-"`
	Comments         []*Comment    `xorm:"-"`
	Reactions        ReactionList  `xorm:"-"`
	TotalTrackedTime int64         `xorm:"-"`
	Assignees        []*User       `xorm:"-"`
}

Issue represents an issue or pull request of repository.

func GetIssueByID

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 GetIssuesByIDs added in v1.2.0

func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error)

GetIssuesByIDs return issues with the given IDs.

func GetRawIssueByIndex

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

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

func Issues

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

Issues returns a list of issues by given conditions.

func (*Issue) APIFormat

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

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

func (*Issue) APIURL added in v1.1.0

func (issue *Issue) APIURL() string

APIURL returns the absolute APIURL to this issue.

func (*Issue) AddLabel

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

AddLabel adds a new label to the issue.

func (*Issue) AddLabels

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

AddLabels adds a list of new labels to the issue.

func (*Issue) ChangeAssignee

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

ChangeAssignee changes the Assignee of this issue.

func (*Issue) ChangeContent

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

ChangeContent changes issue content, as the given user.

func (*Issue) ChangeStatus

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

ChangeStatus changes issue status to open or closed.

func (*Issue) ChangeTitle

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

ChangeTitle changes the title of this issue, as the given user.

func (*Issue) ClearLabels

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

ClearLabels removes all issue labels as the given user. Triggers appropriate WebHooks, if any.

func (*Issue) DiffURL added in v1.0.0

func (issue *Issue) DiffURL() string

DiffURL returns the absolute URL to this diff

func (*Issue) GetIsRead added in v1.1.0

func (issue *Issue) GetIsRead(userID int64) error

GetIsRead load the `IsRead` field of the issue

func (*Issue) GetPullRequest added in v1.1.0

func (issue *Issue) GetPullRequest() (pr *PullRequest, err error)

GetPullRequest returns the issue pull request

func (*Issue) GetTasks added in v1.4.0

func (issue *Issue) GetTasks() int

GetTasks returns the amount of tasks in the issues content

func (*Issue) GetTasksDone added in v1.4.0

func (issue *Issue) GetTasksDone() int

GetTasksDone returns the amount of completed tasks in the issues content

func (*Issue) HTMLURL

func (issue *Issue) HTMLURL() string

HTMLURL returns the absolute URL to this issue.

func (*Issue) HasLabel

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

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

func (*Issue) HashTag

func (issue *Issue) HashTag() string

HashTag returns unique hash tag for issue.

func (*Issue) IsOverdue added in v1.5.0

func (issue *Issue) IsOverdue() bool

IsOverdue checks if the issue is overdue

func (*Issue) IsPoster

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

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

func (*Issue) IsTimetrackerEnabled added in v1.5.0

func (issue *Issue) IsTimetrackerEnabled() bool

IsTimetrackerEnabled returns true if the repo enables timetracking

func (*Issue) LoadAttributes

func (issue *Issue) LoadAttributes() error

LoadAttributes loads the attribute of this issue.

func (*Issue) MailParticipants

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

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

func (*Issue) PatchURL added in v1.0.0

func (issue *Issue) PatchURL() string

PatchURL returns the absolute URL to this patch

func (*Issue) ReadBy

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

ReadBy sets issue to be read by given user.

func (*Issue) RemoveLabel

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

RemoveLabel removes a label from issue by given ID.

func (*Issue) ReplaceLabels

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

ReplaceLabels removes all current labels and add new labels to the issue. Triggers appropriate WebHooks, if any.

func (*Issue) State

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

State returns string representation of issue status.

type IssueAssignees added in v1.5.0

type IssueAssignees struct {
	ID         int64 `xorm:"pk autoincr"`
	AssigneeID int64 `xorm:"INDEX"`
	IssueID    int64 `xorm:"INDEX"`
}

IssueAssignees saves all issue assignees

type IssueLabel

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

IssueLabel represents an issue-label relation.

type IssueList added in v1.1.0

type IssueList []*Issue

IssueList defines a list of issues

func (IssueList) LoadAttachments added in v1.4.0

func (issues IssueList) LoadAttachments() error

LoadAttachments loads attachments

func (IssueList) LoadAttributes added in v1.1.0

func (issues IssueList) LoadAttributes() error

LoadAttributes loads attributes of the issues, except for attachments and comments

func (IssueList) LoadComments added in v1.4.0

func (issues IssueList) LoadComments() error

LoadComments loads comments

func (IssueList) LoadRepositories added in v1.1.0

func (issues IssueList) LoadRepositories() ([]*Repository, error)

LoadRepositories loads issues' all repositories

type IssueStats

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

IssueStats represents issue statistic information.

func GetIssueStats

func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error)

GetIssueStats returns issue statistic information by given conditions.

func GetUserIssueStats

func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error)

GetUserIssueStats returns issue statistic information for dashboard by given conditions.

type IssueStatsOptions

type IssueStatsOptions struct {
	RepoID      int64
	Labels      string
	MilestoneID int64
	AssigneeID  int64
	MentionedID int64
	PosterID    int64
	IsPull      bool
	IssueIDs    []int64
}

IssueStatsOptions contains parameters accepted by GetIssueStats.

type IssueUser

type IssueUser struct {
	ID          int64 `xorm:"pk autoincr"`
	UID         int64 `xorm:"INDEX"` // User ID.
	IssueID     int64
	IsRead      bool
	IsMentioned bool
}

IssueUser represents an issue-user relation.

type IssueWatch added in v1.2.0

type IssueWatch struct {
	ID          int64          `xorm:"pk autoincr"`
	UserID      int64          `xorm:"UNIQUE(watch) NOT NULL"`
	IssueID     int64          `xorm:"UNIQUE(watch) NOT NULL"`
	IsWatching  bool           `xorm:"NOT NULL"`
	CreatedUnix util.TimeStamp `xorm:"created NOT NULL"`
	UpdatedUnix util.TimeStamp `xorm:"updated NOT NULL"`
}

IssueWatch is connection request for receiving issue notification.

func GetIssueWatch added in v1.2.0

func GetIssueWatch(userID, issueID int64) (iw *IssueWatch, exists bool, err error)

GetIssueWatch returns an issue watch by user and issue

func GetIssueWatchers added in v1.2.0

func GetIssueWatchers(issueID int64) ([]*IssueWatch, error)

GetIssueWatchers returns watchers/unwatchers of a given issue

type IssuesConfig added in v1.3.0

type IssuesConfig struct {
	EnableTimetracker                bool
	AllowOnlyContributorsToTrackTime bool
}

IssuesConfig describes issues config

func (*IssuesConfig) FromDB added in v1.3.0

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

FromDB fills up a IssuesConfig from serialized format.

func (*IssuesConfig) ToDB added in v1.3.0

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

ToDB exports a IssuesConfig to a serialized format.

type IssuesOptions

type IssuesOptions struct {
	RepoIDs     []int64 // include all repos if empty
	AssigneeID  int64
	PosterID    int64
	MentionedID int64
	MilestoneID int64
	Page        int
	PageSize    int
	IsClosed    util.OptionalBool
	IsPull      util.OptionalBool
	Labels      string
	SortType    string
	IssueIDs    []int64
}

IssuesOptions represents options of an issue.

type KeyType

type KeyType int

KeyType specifies the key type

type LDAPConfig

type LDAPConfig struct {
	*ldap.Source
}

LDAPConfig holds configuration for LDAP login source.

func (*LDAPConfig) FromDB

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

FromDB fills up a LDAPConfig from serialized format.

func (*LDAPConfig) SecurityProtocolName

func (cfg *LDAPConfig) SecurityProtocolName() string

SecurityProtocolName returns the name of configured security protocol.

func (*LDAPConfig) ToDB

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

ToDB exports a LDAPConfig to a serialized format.

type LFSLock added in v1.4.0

type LFSLock struct {
	ID      int64       `xorm:"pk autoincr"`
	Repo    *Repository `xorm:"-"`
	RepoID  int64       `xorm:"INDEX NOT NULL"`
	Owner   *User       `xorm:"-"`
	OwnerID int64       `xorm:"INDEX NOT NULL"`
	Path    string      `xorm:"TEXT"`
	Created time.Time   `xorm:"created"`
}

LFSLock represents a git lfs lock of repository.

func CreateLFSLock added in v1.4.0

func CreateLFSLock(lock *LFSLock) (*LFSLock, error)

CreateLFSLock creates a new lock.

func DeleteLFSLockByID added in v1.4.0

func DeleteLFSLockByID(id int64, u *User, force bool) (*LFSLock, error)

DeleteLFSLockByID deletes a lock by given ID.

func GetLFSLock added in v1.4.0

func GetLFSLock(repo *Repository, path string) (*LFSLock, error)

GetLFSLock returns release by given path.

func GetLFSLockByID added in v1.4.0

func GetLFSLockByID(id int64) (*LFSLock, error)

GetLFSLockByID returns release by given id.

func GetLFSLockByRepoID added in v1.4.0

func GetLFSLockByRepoID(repoID int64) (locks []*LFSLock, err error)

GetLFSLockByRepoID returns a list of locks of repository.

func (*LFSLock) APIFormat added in v1.4.0

func (l *LFSLock) APIFormat() *api.LFSLock

APIFormat convert a Release to lfs.LFSLock

func (*LFSLock) AfterLoad added in v1.4.0

func (l *LFSLock) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*LFSLock) BeforeInsert added in v1.4.0

func (l *LFSLock) BeforeInsert()

BeforeInsert is invoked from XORM before inserting an object of this type.

type LFSMetaObject added in v1.1.0

type LFSMetaObject struct {
	ID           int64          `xorm:"pk autoincr"`
	Oid          string         `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Size         int64          `xorm:"NOT NULL"`
	RepositoryID int64          `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Existing     bool           `xorm:"-"`
	CreatedUnix  util.TimeStamp `xorm:"created"`
}

LFSMetaObject stores metadata for LFS tracked files.

func NewLFSMetaObject added in v1.1.0

func NewLFSMetaObject(m *LFSMetaObject) (*LFSMetaObject, error)

NewLFSMetaObject stores a given populated LFSMetaObject structure in the database if it is not already present.

type LFSTokenResponse added in v1.1.0

type LFSTokenResponse struct {
	Header map[string]string `json:"header"`
	Href   string            `json:"href"`
}

LFSTokenResponse defines the JSON structure in which the JWT token is stored. This structure is fetched via SSH and passed by the Git LFS client to the server endpoint for authorization.

type Label

type Label struct {
	ID              int64 `xorm:"pk autoincr"`
	RepoID          int64 `xorm:"INDEX"`
	Name            string
	Description     string
	Color           string `xorm:"VARCHAR(7)"`
	NumIssues       int
	NumClosedIssues int
	NumOpenIssues   int  `xorm:"-"`
	IsChecked       bool `xorm:"-"`
}

Label represents a label of repository for issues.

func GetLabelByID

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

GetLabelByID returns a label by given ID.

func GetLabelInRepoByID

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

GetLabelInRepoByID returns a label by ID in given repository.

func GetLabelInRepoByName added in v1.0.0

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

GetLabelInRepoByName returns a label by name in given repository.

func GetLabelsByIssueID

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

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

func GetLabelsByRepoID

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

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

func GetLabelsInRepoByIDs

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

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

APIFormat converts a Label to the api.Label format

func (*Label) CalOpenIssues

func (label *Label) CalOpenIssues()

CalOpenIssues calculates the open issues of label.

func (*Label) ForegroundColor

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

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

type LoginSource

type LoginSource struct {
	ID            int64 `xorm:"pk autoincr"`
	Type          LoginType
	Name          string          `xorm:"UNIQUE"`
	IsActived     bool            `xorm:"INDEX NOT NULL DEFAULT false"`
	IsSyncEnabled bool            `xorm:"INDEX NOT NULL DEFAULT false"`
	Cfg           core.Conversion `xorm:"TEXT"`

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

LoginSource represents an external way for authorizing users.

func GetActiveOAuth2LoginSourceByName added in v1.1.0

func GetActiveOAuth2LoginSourceByName(name string) (*LoginSource, error)

GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name

func GetActiveOAuth2ProviderLoginSources added in v1.1.0

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

GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources

func GetLoginSourceByID

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

GetLoginSourceByID returns login source by given ID.

func LoginSources

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

LoginSources returns a slice of all login sources found in DB.

func (*LoginSource) BeforeSet

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

BeforeSet is invoked from XORM before setting the value of a field of this object.

func (*LoginSource) HasTLS

func (source *LoginSource) HasTLS() bool

HasTLS returns true of this source supports TLS.

func (*LoginSource) IsDLDAP

func (source *LoginSource) IsDLDAP() bool

IsDLDAP returns true of this source is of the DLDAP type.

func (*LoginSource) IsLDAP

func (source *LoginSource) IsLDAP() bool

IsLDAP returns true of this source is of the LDAP type.

func (*LoginSource) IsOAuth2 added in v1.1.0

func (source *LoginSource) IsOAuth2() bool

IsOAuth2 returns true of this source is of the OAuth2 type.

func (*LoginSource) IsPAM

func (source *LoginSource) IsPAM() bool

IsPAM returns true of this source is of the PAM type.

func (*LoginSource) IsSMTP

func (source *LoginSource) IsSMTP() bool

IsSMTP returns true of this source is of the SMTP type.

func (*LoginSource) LDAP

func (source *LoginSource) LDAP() *LDAPConfig

LDAP returns LDAPConfig for this source, if of LDAP type.

func (*LoginSource) OAuth2 added in v1.1.0

func (source *LoginSource) OAuth2() *OAuth2Config

OAuth2 returns OAuth2Config for this source, if of OAuth2 type.

func (*LoginSource) PAM

func (source *LoginSource) PAM() *PAMConfig

PAM returns PAMConfig for this source, if of PAM type.

func (*LoginSource) SMTP

func (source *LoginSource) SMTP() *SMTPConfig

SMTP returns SMTPConfig for this source, if of SMTP type.

func (*LoginSource) SkipVerify

func (source *LoginSource) SkipVerify() bool

SkipVerify returns true if this source is configured to skip SSL verification.

func (*LoginSource) TypeName

func (source *LoginSource) TypeName() string

TypeName return name of this login source type.

func (*LoginSource) UseTLS

func (source *LoginSource) UseTLS() bool

UseTLS returns true of this source is configured to use TLS.

type LoginType

type LoginType int

LoginType represents an login type.

const (
	LoginNoType LoginType = iota
	LoginPlain            // 1
	LoginLDAP             // 2
	LoginSMTP             // 3
	LoginPAM              // 4
	LoginDLDAP            // 5
	LoginOAuth2           // 6
)

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

type MergeStyle added in v1.4.0

type MergeStyle string

MergeStyle represents the approach to merge commits into base branch.

const (
	// MergeStyleMerge create merge commit
	MergeStyleMerge MergeStyle = "merge"
	// MergeStyleRebase rebase before merging
	MergeStyleRebase MergeStyle = "rebase"
	// MergeStyleSquash squash commits into single commit before merging
	MergeStyleSquash MergeStyle = "squash"
)

type MigrateRepoOptions

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

MigrateRepoOptions contains the repository migrate options

type Milestone

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

	DeadlineString string `xorm:"-"`
	DeadlineUnix   util.TimeStamp
	ClosedDateUnix util.TimeStamp

	TotalTrackedTime int64 `xorm:"-"`
}

Milestone represents a milestone of repository.

func GetMilestoneByRepoID

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

GetMilestoneByRepoID returns the milestone in a repository.

func (*Milestone) APIFormat

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

APIFormat returns this Milestone in API format.

func (*Milestone) AfterLoad added in v1.3.0

func (m *Milestone) AfterLoad()

AfterLoad is invoked from XORM after setting the value of a field of this object.

func (*Milestone) BeforeUpdate

func (m *Milestone) BeforeUpdate()

BeforeUpdate is invoked from XORM before updating this object.

func (*Milestone) State

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

State returns string representation of milestone status.

type MilestoneList added in v1.5.0

type MilestoneList []*Milestone

MilestoneList is a list of milestones offering additional functionality

func GetMilestones

func GetMilestones(repoID int64, page int, isClosed bool, sortType string) (MilestoneList, error)

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

func GetMilestonesByRepoID

func GetMilestonesByRepoID(repoID int64) (MilestoneList, error)

GetMilestonesByRepoID returns all milestones of a repository.

func (MilestoneList) LoadTotalTrackedTimes added in v1.5.0

func (milestones MilestoneList) LoadTotalTrackedTimes() error

LoadTotalTrackedTimes loads for every milestone in the list the TotalTrackedTime by a batch request

type Mirror

type Mirror struct {
	ID          int64       `xorm:"pk autoincr"`
	RepoID      int64       `xorm:"INDEX"`
	Repo        *Repository `xorm:"-"`
	Interval    time.Duration
	EnablePrune bool `xorm:"NOT NULL DEFAULT true"`

	UpdatedUnix    util.TimeStamp `xorm:"INDEX"`
	NextUpdateUnix util.TimeStamp `xorm:"INDEX"`
	// contains filtered or unexported fields
}

Mirror represents mirror information of a repository.

func GetMirrorByRepoID

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

GetMirrorByRepoID returns mirror information of a repository.

func (*Mirror) Address

func (m *Mirror) Address() string

Address returns mirror address from Git repository config without credentials.

func (*Mirror) AfterLoad added in v1.3.0

func (m *Mirror) AfterLoad(session *xorm.Session)

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*Mirror) BeforeInsert

func (m *Mirror) BeforeInsert()

BeforeInsert will be invoked by XORM before inserting a record

func (*Mirror) FullAddress

func (m *Mirror) FullAddress() string

FullAddress returns mirror address from Git repository config.

func (*Mirror) SaveAddress

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

SaveAddress writes new address to Git repository config.

func (*Mirror) ScheduleNextUpdate

func (m *Mirror) ScheduleNextUpdate()

ScheduleNextUpdate calculates and sets next update time.

type MirrorRepositoryList

type MirrorRepositoryList []*Repository

MirrorRepositoryList contains the mirror repositories

func (MirrorRepositoryList) LoadAttributes

func (repos MirrorRepositoryList) LoadAttributes() error

LoadAttributes loads the attributes for the given MirrorRepositoryList

type NewCommitStatusOptions added in v1.2.0

type NewCommitStatusOptions struct {
	Repo         *Repository
	Creator      *User
	SHA          string
	CommitStatus *CommitStatus
}

NewCommitStatusOptions holds options for creating a CommitStatus

type NewIssueOptions

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

NewIssueOptions represents the options of a new issue.

type Notice

type Notice struct {
	ID          int64 `xorm:"pk autoincr"`
	Type        NoticeType
	Description string         `xorm:"TEXT"`
	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
}

Notice represents a system notice for admin.

func Notices

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

Notices returns notices in given page.

func (*Notice) TrStr

func (n *Notice) TrStr() string

TrStr returns a translation format string.

type NoticeType

type NoticeType int

NoticeType describes the notice type

const (
	//NoticeRepository type
	NoticeRepository NoticeType = iota + 1
)

type Notification added in v1.1.0

type Notification struct {
	ID     int64 `xorm:"pk autoincr"`
	UserID int64 `xorm:"INDEX NOT NULL"`
	RepoID int64 `xorm:"INDEX NOT NULL"`

	Status NotificationStatus `xorm:"SMALLINT INDEX NOT NULL"`
	Source NotificationSource `xorm:"SMALLINT INDEX NOT NULL"`

	IssueID  int64  `xorm:"INDEX NOT NULL"`
	CommitID string `xorm:"INDEX"`

	UpdatedBy int64 `xorm:"INDEX NOT NULL"`

	Issue      *Issue      `xorm:"-"`
	Repository *Repository `xorm:"-"`

	CreatedUnix util.TimeStamp `xorm:"created INDEX NOT NULL"`
	UpdatedUnix util.TimeStamp `xorm:"updated INDEX NOT NULL"`
}

Notification represents a notification

func NotificationsForUser added in v1.1.0

func NotificationsForUser(user *User, statuses []NotificationStatus, page, perPage int) ([]*Notification, error)

NotificationsForUser returns notifications for a given user and status

func (*Notification) GetIssue added in v1.1.0

func (n *Notification) GetIssue() (*Issue, error)

GetIssue returns the issue of the notification

func (*Notification) GetRepo added in v1.1.0

func (n *Notification) GetRepo() (*Repository, error)

GetRepo returns the repo of the notification

type NotificationSource added in v1.1.0

type NotificationSource uint8

NotificationSource is the source of the notification (issue, PR, commit, etc)

const (
	// NotificationSourceIssue is a notification of an issue
	NotificationSourceIssue NotificationSource = iota + 1
	// NotificationSourcePullRequest is a notification of a pull request
	NotificationSourcePullRequest
	// NotificationSourceCommit is a notification of a commit
	NotificationSourceCommit
)

type NotificationStatus added in v1.1.0

type NotificationStatus uint8

NotificationStatus is the status of the notification (read or unread)

const (
	// NotificationStatusUnread represents an unread notification
	NotificationStatusUnread NotificationStatus = iota + 1
	// NotificationStatusRead represents a read notification
	NotificationStatusRead
	// NotificationStatusPinned represents a pinned notification
	NotificationStatusPinned
)

type OAuth2Config added in v1.1.0

type OAuth2Config struct {
	Provider                      string
	ClientID                      string
	ClientSecret                  string
	OpenIDConnectAutoDiscoveryURL string
	CustomURLMapping              *oauth2.CustomURLMapping
}

OAuth2Config holds configuration for the OAuth2 login source.

func (*OAuth2Config) FromDB added in v1.1.0

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

FromDB fills up an OAuth2Config from serialized format.

func (*OAuth2Config) ToDB added in v1.1.0

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

ToDB exports an SMTPConfig to a serialized format.

type OAuth2Provider added in v1.1.0

type OAuth2Provider struct {
	Name             string
	DisplayName      string
	Image            string
	CustomURLMapping *oauth2.CustomURLMapping
}

OAuth2Provider describes the display values of a single OAuth2 provider

type OrgUser

type OrgUser struct {
	ID       int64 `xorm:"pk autoincr"`
	UID      int64 `xorm:"INDEX UNIQUE(s)"`
	OrgID    int64 `xorm:"INDEX UNIQUE(s)"`
	IsPublic bool  `xorm:"INDEX"`
}

OrgUser represents an organization-user relation.

func GetOrgUsersByOrgID

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

GetOrgUsersByOrgID returns all organization-user relations by organization ID.

func GetOrgUsersByUserID

func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error)

GetOrgUsersByUserID returns all organization-user relations by user ID.

type PAMConfig

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

PAMConfig holds configuration for the PAM login source.

func (*PAMConfig) FromDB

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

FromDB fills up a PAMConfig from serialized format.

func (*PAMConfig) ToDB

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

ToDB exports a PAMConfig to a serialized format.

type ProtectedBranch added in v1.1.0

type ProtectedBranch struct {
	ID                    int64  `xorm:"pk autoincr"`
	RepoID                int64  `xorm:"UNIQUE(s)"`
	BranchName            string `xorm:"UNIQUE(s)"`
	CanPush               bool   `xorm:"NOT NULL DEFAULT false"`
	EnableWhitelist       bool
	WhitelistUserIDs      []int64        `xorm:"JSON TEXT"`
	WhitelistTeamIDs      []int64        `xorm:"JSON TEXT"`
	EnableMergeWhitelist  bool           `xorm:"NOT NULL DEFAULT false"`
	MergeWhitelistUserIDs []int64        `xorm:"JSON TEXT"`
	MergeWhitelistTeamIDs []int64        `xorm:"JSON TEXT"`
	CreatedUnix           util.TimeStamp `xorm:"created"`
	UpdatedUnix           util.TimeStamp `xorm:"updated"`
}

ProtectedBranch struct

func GetProtectedBranchBy added in v1.1.0

func GetProtectedBranchBy(repoID int64, BranchName string) (*ProtectedBranch, error)

GetProtectedBranchBy getting protected branch by ID/Name

func GetProtectedBranchByID added in v1.3.0

func GetProtectedBranchByID(id int64) (*ProtectedBranch, error)

GetProtectedBranchByID getting protected branch by ID

func GetProtectedBranchByRepoID added in v1.1.0

func GetProtectedBranchByRepoID(RepoID int64) ([]*ProtectedBranch, error)

GetProtectedBranchByRepoID getting protected branch by repo ID

func (*ProtectedBranch) CanUserMerge added in v1.5.0

func (protectBranch *ProtectedBranch) CanUserMerge(userID int64) bool

CanUserMerge returns if some user could merge a pull request to this protected branch

func (*ProtectedBranch) CanUserPush added in v1.3.0

func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool

CanUserPush returns if some user could push to this protected branch

func (*ProtectedBranch) IsProtected added in v1.2.0

func (protectBranch *ProtectedBranch) IsProtected() bool

IsProtected returns if the branch is protected

type PublicKey

type PublicKey struct {
	ID            int64      `xorm:"pk autoincr"`
	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"`
	LoginSourceID int64      `xorm:"NOT NULL DEFAULT 0"`

	CreatedUnix       util.TimeStamp `xorm:"created"`
	UpdatedUnix       util.TimeStamp `xorm:"updated"`
	HasRecentActivity bool           `xorm:"-"`
	HasUsed           bool           `xorm:"-"`
}

PublicKey represents a user or deploy SSH public key.

func AddPublicKey

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

AddPublicKey adds new public key to database and authorized_keys file.

func GetPublicKeyByID

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

GetPublicKeyByID returns public key by given ID.

func ListPublicKeys

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

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

func ListPublicLdapSSHKeys added in v1.5.0

func ListPublicLdapSSHKeys(uid int64, LoginSourceID int64) ([]*PublicKey, error)

ListPublicLdapSSHKeys returns a list of synchronized public ldap ssh keys belongs to given user and login source.

func SearchPublicKeyByContent

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

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

func (*PublicKey) AfterLoad added in v1.3.0

func (key *PublicKey) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*PublicKey) AuthorizedString

func (key *PublicKey) AuthorizedString() string

AuthorizedString returns formatted public key string for authorized_keys file.

func (*PublicKey) OmitEmail

func (key *PublicKey) OmitEmail() string

OmitEmail returns content of public key without email address.

type PullRequest

type PullRequest struct {
	ID     int64 `xorm:"pk autoincr"`
	Type   PullRequestType
	Status PullRequestStatus

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

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

	HasMerged      bool           `xorm:"INDEX"`
	MergedCommitID string         `xorm:"VARCHAR(40)"`
	MergerID       int64          `xorm:"INDEX"`
	Merger         *User          `xorm:"-"`
	MergedUnix     util.TimeStamp `xorm:"updated INDEX"`
}

PullRequest represents relation between pull request and repositories.

func GetPullRequestByID

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

GetPullRequestByID returns a pull request by given ID.

func GetPullRequestByIndex added in v1.0.0

func GetPullRequestByIndex(repoID int64, index int64) (*PullRequest, error)

GetPullRequestByIndex returns a pull request by the given index

func GetPullRequestByIssueID

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

GetPullRequestByIssueID returns pull request by given issue ID.

func GetUnmergedPullRequest

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

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

func GetUnmergedPullRequestsByBaseInfo

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

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

func GetUnmergedPullRequestsByHeadInfo

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

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

func PullRequests added in v1.0.0

func PullRequests(baseRepoID int64, opts *PullRequestsOptions) ([]*PullRequest, int64, error)

PullRequests returns all pull requests for a base Repo by the given conditions

func (*PullRequest) APIFormat

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

APIFormat assumes following fields have been assigned with valid values: Required - Issue Optional - Merger

func (*PullRequest) AddToTaskQueue

func (pr *PullRequest) AddToTaskQueue()

AddToTaskQueue adds itself to pull request test task queue.

func (*PullRequest) CanAutoMerge

func (pr *PullRequest) CanAutoMerge() bool

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

func (*PullRequest) CheckUserAllowedToMerge added in v1.5.0

func (pr *PullRequest) CheckUserAllowedToMerge(doer *User) (err error)

CheckUserAllowedToMerge checks whether the user is allowed to merge

func (*PullRequest) GetBaseRepo

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

GetBaseRepo loads the target repository

func (*PullRequest) GetDefaultMergeMessage added in v1.4.0

func (pr *PullRequest) GetDefaultMergeMessage() string

GetDefaultMergeMessage returns default message used when merging pull request

func (*PullRequest) GetDefaultSquashMessage added in v1.4.0

func (pr *PullRequest) GetDefaultSquashMessage() string

GetDefaultSquashMessage returns default message used when squash and merging pull request

func (*PullRequest) GetGitRefName added in v1.4.0

func (pr *PullRequest) GetGitRefName() string

GetGitRefName returns git ref for hidden pull request branch

func (*PullRequest) GetHeadRepo

func (pr *PullRequest) GetHeadRepo() error

GetHeadRepo loads the head repository

func (*PullRequest) IsChecking

func (pr *PullRequest) IsChecking() bool

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

func (*PullRequest) LoadAttributes

func (pr *PullRequest) LoadAttributes() error

LoadAttributes loads pull request attributes from database

func (*PullRequest) LoadIssue

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

LoadIssue loads issue information from database

func (*PullRequest) Merge

func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle, message 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

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

func (pr *PullRequest) Update() error

Update updates all fields of pull request.

func (*PullRequest) UpdateCols

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

UpdateCols updates specific fields of pull request.

func (*PullRequest) UpdatePatch

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

UpdatePatch generates and saves a new patch.

type PullRequestList

type PullRequestList []*PullRequest

PullRequestList defines a list of pull requests

func (PullRequestList) LoadAttributes

func (prs PullRequestList) LoadAttributes() error

LoadAttributes load all the prs attributes

type PullRequestStatus

type PullRequestStatus int

PullRequestStatus defines pull request status

const (
	PullRequestStatusConflict PullRequestStatus = iota
	PullRequestStatusChecking
	PullRequestStatusMergeable
	PullRequestStatusManuallyMerged
)

Enumerate all the pull request status

type PullRequestType

type PullRequestType int

PullRequestType defines pull request type

const (
	PullRequestGitea PullRequestType = iota
	PullRequestGit
)

Enumerate all the pull request types

type PullRequestsConfig added in v1.4.0

type PullRequestsConfig struct {
	IgnoreWhitespaceConflicts bool
	AllowMerge                bool
	AllowRebase               bool
	AllowSquash               bool
}

PullRequestsConfig describes pull requests config

func (*PullRequestsConfig) FromDB added in v1.4.0

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

FromDB fills up a PullRequestsConfig from serialized format.

func (*PullRequestsConfig) IsMergeStyleAllowed added in v1.4.0

func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool

IsMergeStyleAllowed returns if merge style is allowed

func (*PullRequestsConfig) ToDB added in v1.4.0

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

ToDB exports a PullRequestsConfig to a serialized format.

type PullRequestsOptions added in v1.0.0

type PullRequestsOptions struct {
	Page        int
	State       string
	SortType    string
	Labels      []string
	MilestoneID int64
}

PullRequestsOptions holds the options for PRs

type PushCommit

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

PushCommit represents a commit in a push operation.

func CommitToPushCommit

func CommitToPushCommit(commit *git.Commit) *PushCommit

CommitToPushCommit transforms a git.Commit to PushCommit type.

type PushCommits

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

PushCommits represents list of commits in a push operation.

func ListToPushCommits

func ListToPushCommits(l *list.List) *PushCommits

ListToPushCommits transforms a list.List to PushCommits type.

func NewPushCommits

func NewPushCommits() *PushCommits

NewPushCommits creates a new PushCommits object.

func (pc *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 v1.0.0

func (pc *PushCommits) ToAPIPayloadCommits(repoLink string) []*api.PayloadCommit

ToAPIPayloadCommits converts a PushCommits object to api.PayloadCommit format.

type PushUpdateOptions

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

PushUpdateOptions defines the push update options

type RawDiffType

type RawDiffType string

RawDiffType type of a raw diff.

const (
	RawDiffNormal RawDiffType = "diff"
	RawDiffPatch  RawDiffType = "patch"
)

RawDiffType possible values.

type Reaction added in v1.4.0

type Reaction struct {
	ID          int64          `xorm:"pk autoincr"`
	Type        string         `xorm:"INDEX UNIQUE(s) NOT NULL"`
	IssueID     int64          `xorm:"INDEX UNIQUE(s) NOT NULL"`
	CommentID   int64          `xorm:"INDEX UNIQUE(s)"`
	UserID      int64          `xorm:"INDEX UNIQUE(s) NOT NULL"`
	User        *User          `xorm:"-"`
	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
}

Reaction represents a reactions on issues and comments.

func CreateCommentReaction added in v1.4.0

func CreateCommentReaction(doer *User, issue *Issue, comment *Comment, content string) (*Reaction, error)

CreateCommentReaction creates a reaction on comment.

func CreateIssueReaction added in v1.4.0

func CreateIssueReaction(doer *User, issue *Issue, content string) (*Reaction, error)

CreateIssueReaction creates a reaction on issue.

func CreateReaction added in v1.4.0

func CreateReaction(opts *ReactionOptions) (reaction *Reaction, err error)

CreateReaction creates reaction for issue or comment.

type ReactionList added in v1.4.0

type ReactionList []*Reaction

ReactionList represents list of reactions

func (ReactionList) GetFirstUsers added in v1.4.0

func (list ReactionList) GetFirstUsers() string

GetFirstUsers returns first reacted user display names separated by comma

func (ReactionList) GetMoreUserCount added in v1.4.0

func (list ReactionList) GetMoreUserCount() int

GetMoreUserCount returns count of not shown users in reaction tooltip

func (ReactionList) GroupByType added in v1.4.0

func (list ReactionList) GroupByType() map[string]ReactionList

GroupByType returns reactions grouped by type

func (ReactionList) HasUser added in v1.4.0

func (list ReactionList) HasUser(userID int64) bool

HasUser check if user has reacted

func (ReactionList) LoadUsers added in v1.4.0

func (list ReactionList) LoadUsers() ([]*User, error)

LoadUsers loads reactions' all users

type ReactionOptions added in v1.4.0

type ReactionOptions struct {
	Type    string
	Doer    *User
	Issue   *Issue
	Comment *Comment
}

ReactionOptions defines options for creating or deleting reactions

type Release

type Release struct {
	ID               int64       `xorm:"pk autoincr"`
	RepoID           int64       `xorm:"INDEX UNIQUE(n)"`
	Repo             *Repository `xorm:"-"`
	PublisherID      int64       `xorm:"INDEX"`
	Publisher        *User       `xorm:"-"`
	TagName          string      `xorm:"INDEX UNIQUE(n)"`
	LowerTagName     string
	Target           string
	Title            string
	Sha1             string `xorm:"VARCHAR(40)"`
	NumCommits       int64
	NumCommitsBehind int64          `xorm:"-"`
	Note             string         `xorm:"TEXT"`
	IsDraft          bool           `xorm:"NOT NULL DEFAULT false"`
	IsPrerelease     bool           `xorm:"NOT NULL DEFAULT false"`
	IsTag            bool           `xorm:"NOT NULL DEFAULT false"`
	Attachments      []*Attachment  `xorm:"-"`
	CreatedUnix      util.TimeStamp `xorm:"INDEX"`
}

Release represents a release of repository.

func GetRelease

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

GetRelease returns release by given ID.

func GetReleaseByID

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

GetReleaseByID returns release with given ID.

func GetReleasesByRepoID

func GetReleasesByRepoID(repoID int64, opts FindReleasesOptions, page, pageSize int) (rels []*Release, err error)

GetReleasesByRepoID returns a list of releases of repository.

func (*Release) APIFormat added in v1.1.0

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

APIFormat convert a Release to api.Release

func (*Release) APIURL added in v1.1.0

func (r *Release) APIURL() string

APIURL the api url for a release. release must have attributes loaded

func (*Release) LoadAttributes added in v1.1.0

func (r *Release) LoadAttributes() error

LoadAttributes load repo and publisher attributes for a release

func (*Release) TarURL added in v1.1.0

func (r *Release) TarURL() string

TarURL the tar.gz url for a release. release must have attributes loaded

func (*Release) ZipURL added in v1.1.0

func (r *Release) ZipURL() string

ZipURL the zip url for a release. release must have attributes loaded

type RepoIndexerStatus added in v1.3.0

type RepoIndexerStatus struct {
	ID        int64  `xorm:"pk autoincr"`
	RepoID    int64  `xorm:"INDEX"`
	CommitSha string `xorm:"VARCHAR(40)"`
}

RepoIndexerStatus status of a repo's entry in the repo indexer For now, implicitly refers to default branch

type RepoRedirect added in v1.1.0

type RepoRedirect struct {
	ID             int64  `xorm:"pk autoincr"`
	OwnerID        int64  `xorm:"UNIQUE(s)"`
	LowerName      string `xorm:"UNIQUE(s) INDEX NOT NULL"`
	RedirectRepoID int64  // repoID to redirect to
}

RepoRedirect represents that a repo name should be redirected to another

type RepoTopic added in v1.5.0

type RepoTopic struct {
	RepoID  int64 `xorm:"UNIQUE(s)"`
	TopicID int64 `xorm:"UNIQUE(s)"`
}

RepoTopic represents associated repositories and topics

type RepoUnit added in v1.1.0

type RepoUnit struct {
	ID          int64
	RepoID      int64           `xorm:"INDEX(s)"`
	Type        UnitType        `xorm:"INDEX(s)"`
	Config      core.Conversion `xorm:"TEXT"`
	CreatedUnix util.TimeStamp  `xorm:"INDEX CREATED"`
}

RepoUnit describes all units of a repository

func (*RepoUnit) BeforeSet added in v1.1.0

func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell)

BeforeSet is invoked from XORM before setting the value of a field of this object.

func (*RepoUnit) CodeConfig added in v1.1.0

func (r *RepoUnit) CodeConfig() *UnitConfig

CodeConfig returns config for UnitTypeCode

func (*RepoUnit) ExternalTrackerConfig added in v1.1.0

func (r *RepoUnit) ExternalTrackerConfig() *ExternalTrackerConfig

ExternalTrackerConfig returns config for UnitTypeExternalTracker

func (*RepoUnit) ExternalWikiConfig added in v1.1.0

func (r *RepoUnit) ExternalWikiConfig() *ExternalWikiConfig

ExternalWikiConfig returns config for UnitTypeExternalWiki

func (*RepoUnit) IssuesConfig added in v1.1.0

func (r *RepoUnit) IssuesConfig() *IssuesConfig

IssuesConfig returns config for UnitTypeIssues

func (*RepoUnit) PullRequestsConfig added in v1.1.0

func (r *RepoUnit) PullRequestsConfig() *PullRequestsConfig

PullRequestsConfig returns config for UnitTypePullRequests

func (*RepoUnit) ReleasesConfig added in v1.1.0

func (r *RepoUnit) ReleasesConfig() *UnitConfig

ReleasesConfig returns config for UnitTypeReleases

func (*RepoUnit) Unit added in v1.1.0

func (r *RepoUnit) Unit() Unit

Unit returns Unit

type Repository

type Repository struct {
	ID            int64  `xorm:"pk autoincr"`
	OwnerID       int64  `xorm:"UNIQUE(s)"`
	OwnerName     string `xorm:"-"`
	Owner         *User  `xorm:"-"`
	LowerName     string `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Name          string `xorm:"INDEX NOT NULL"`
	Description   string
	Website       string
	DefaultBranch string

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

	IsPrivate bool `xorm:"INDEX"`
	IsBare    bool `xorm:"INDEX"`

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

	ExternalMetas map[string]string `xorm:"-"`
	Units         []*RepoUnit       `xorm:"-"`

	IsFork        bool               `xorm:"INDEX NOT NULL DEFAULT false"`
	ForkID        int64              `xorm:"INDEX"`
	BaseRepo      *Repository        `xorm:"-"`
	Size          int64              `xorm:"NOT NULL DEFAULT 0"`
	IndexerStatus *RepoIndexerStatus `xorm:"-"`
	IsFsckEnabled bool               `xorm:"NOT NULL DEFAULT true"`
	Topics        []string           `xorm:"TEXT JSON"`

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

Repository represents a git repository.

func CleanUpMigrateInfo

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

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

func CreateRepository

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

CreateRepository creates a repository for the user/organization u.

func ForkRepository

func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error)

ForkRepository forks a repository

func GetRepositoriesByForkID

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

GetRepositoriesByForkID returns all repositories with given fork ID.

func GetRepositoryByID

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

func GetRepositoryByOwnerAndName(ownerName, repoName string) (*Repository, error)

GetRepositoryByOwnerAndName returns the repository by given ownername and reponame.

func GetStarredRepos added in v1.0.0

func GetStarredRepos(userID int64, private bool) ([]*Repository, error)

GetStarredRepos returns the repos starred by a particular user

func GetUserMirrorRepositories

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

GetUserMirrorRepositories returns a list of mirror repositories of given user.

func GetUserRepositories

func GetUserRepositories(userID int64, private bool, page, pageSize int, orderBy string) ([]*Repository, error)

GetUserRepositories returns a list of repositories of given user.

func GetWatchedRepos added in v1.1.0

func GetWatchedRepos(userID int64, private bool) ([]*Repository, error)

GetWatchedRepos returns the repos watched by a particular user

func HasForkedRepo

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

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

func MigrateRepository

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

MigrateRepository migrates a existing repository from other project hosting.

func (*Repository) APIFormat

func (repo *Repository) APIFormat(mode AccessMode) *api.Repository

APIFormat converts a Repository to api.Repository

func (*Repository) APIURL added in v1.1.0

func (repo *Repository) APIURL() string

APIURL returns the repository API URL

func (*Repository) AddCollaborator

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

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

func (*Repository) AddDeletedBranch added in v1.3.0

func (repo *Repository) AddDeletedBranch(branchName, commit string, deletedByID int64) error

AddDeletedBranch adds a deleted branch to the database

func (*Repository) AddWikiPage

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

AddWikiPage adds a new wiki page with a given wikiPath.

func (*Repository) AfterLoad added in v1.3.0

func (repo *Repository) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

func (*Repository) AllowOnlyContributorsToTrackTime added in v1.3.0

func (repo *Repository) AllowOnlyContributorsToTrackTime() bool

AllowOnlyContributorsToTrackTime returns value of IssuesConfig or the default value

func (*Repository) AllowsPulls

func (repo *Repository) AllowsPulls() bool

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

func (*Repository) AnyUnitEnabled added in v1.2.1

func (repo *Repository) AnyUnitEnabled(tps ...UnitType) bool

AnyUnitEnabled if this repository has the any of the given units enabled

func (*Repository) CanBeForked

func (repo *Repository) CanBeForked() bool

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

func (*Repository) CanCreateBranch added in v1.3.0

func (repo *Repository) CanCreateBranch() bool

CanCreateBranch returns true if repository meets the requirements for creating new branches.

func (*Repository) CanEnableEditor

func (repo *Repository) CanEnableEditor() bool

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

func (*Repository) CanEnablePulls

func (repo *Repository) CanEnablePulls() bool

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

func (*Repository) CanEnableTimetracker added in v1.5.0

func (repo *Repository) CanEnableTimetracker() bool

CanEnableTimetracker returns true when the server admin enabled time tracking This overrules IsTimetrackerEnabled

func (*Repository) CanUserFork added in v1.2.1

func (repo *Repository) CanUserFork(user *User) (bool, error)

CanUserFork returns true if specified user can fork repository.

func (*Repository) ChangeCollaborationAccessMode

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

ChangeCollaborationAccessMode sets new access mode for the collaboration.

func (*Repository) CheckBranchName added in v1.3.0

func (repo *Repository) CheckBranchName(name string) error

CheckBranchName validates branch name with existing repository branches

func (*Repository) CheckUnitUser added in v1.2.0

func (repo *Repository) CheckUnitUser(userID int64, isAdmin bool, unitType UnitType) bool

CheckUnitUser check whether user could visit the unit of this repository

func (*Repository) CheckoutNewBranch

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

CheckoutNewBranch checks out a new branch

func (repo *Repository) CloneLink() (cl *CloneLink)

CloneLink returns clone URLs of repository.

func (*Repository) ComposeCompareURL

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

ComposeCompareURL returns the repository comparison URL

func (*Repository) ComposeMetas

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

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

func (*Repository) CreateNewBranch

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

CreateNewBranch creates a new repository branch

func (*Repository) CreateNewBranchFromCommit added in v1.3.0

func (repo *Repository) CreateNewBranchFromCommit(doer *User, commit, branchName string) (err error)

CreateNewBranchFromCommit creates a new repository branch

func (*Repository) DeleteCollaboration

func (repo *Repository) DeleteCollaboration(uid int64) (err error)

DeleteCollaboration removes collaboration relation between the user and repository.

func (*Repository) DeleteProtectedBranch added in v1.1.0

func (repo *Repository) DeleteProtectedBranch(id int64) (err error)

DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.

func (*Repository) DeleteRepoFile

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

DeleteRepoFile deletes a repository file

func (*Repository) DeleteWiki

func (repo *Repository) DeleteWiki() error

DeleteWiki removes the actual and local copy of repository wiki.

func (*Repository) DeleteWikiPage

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

DeleteWikiPage deletes a wiki page identified by its path.

func (*Repository) DescriptionHTML added in v1.0.0

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

DescriptionHTML does special handles to description and return HTML string.

func (*Repository) DiscardLocalRepoBranchChanges

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

DiscardLocalRepoBranchChanges discards the local repository branch changes

func (*Repository) EditWikiPage

func (repo *Repository) EditWikiPage(doer *User, oldWikiName, newWikiName, content, message string) error

EditWikiPage updates a wiki page identified by its wikiPath, optionally also changing wikiPath.

func (*Repository) FullName

func (repo *Repository) FullName() string

FullName returns the repository full name

func (*Repository) GetAssignees

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

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

func (*Repository) GetBaseRepo

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

GetBaseRepo populates repo.BaseRepo for a fork repository and returns an error on failure (NOTE: no error is returned for non-fork repositories, and BaseRepo will be left untouched)

func (*Repository) GetBranch

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

GetBranch returns a branch by it's name

func (*Repository) GetBranches

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

GetBranches returns all the branches of a repository

func (*Repository) GetCollaborators

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

GetCollaborators returns the collaborators for a repository

func (*Repository) GetCommitsCountCacheKey added in v1.3.0

func (repo *Repository) GetCommitsCountCacheKey(contextName string, isRef bool) string

GetCommitsCountCacheKey returns cache key used for commits count caching.

func (*Repository) GetDeletedBranchByID added in v1.3.0

func (repo *Repository) GetDeletedBranchByID(ID int64) (*DeletedBranch, error)

GetDeletedBranchByID get a deleted branch by its ID

func (*Repository) GetDeletedBranches added in v1.3.0

func (repo *Repository) GetDeletedBranches() ([]*DeletedBranch, error)

GetDeletedBranches returns all the deleted branches

func (*Repository) GetDiffPreview

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

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

GetForks returns all the forks of the repository

func (*Repository) GetLFSMetaObjectByOid added in v1.3.0

func (repo *Repository) GetLFSMetaObjectByOid(oid string) (*LFSMetaObject, error)

GetLFSMetaObjectByOid selects a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error. If the error is nil, the returned pointer is a valid LFSMetaObject.

func (*Repository) GetMilestoneByID

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

GetMilestoneByID returns the milestone belongs to repository by given ID.

func (*Repository) GetMirror

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

GetMirror sets the repository mirror, returns an error upon failure

func (*Repository) GetOwner

func (repo *Repository) GetOwner() error

GetOwner returns the repository owner

func (*Repository) GetOwnerName added in v1.4.1

func (repo *Repository) GetOwnerName() error

GetOwnerName returns the repository owner name

func (*Repository) GetProtectedBranches added in v1.1.0

func (repo *Repository) GetProtectedBranches() ([]*ProtectedBranch, error)

GetProtectedBranches get all protected branches

func (*Repository) GetStargazers

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

GetStargazers returns the users that starred the repo.

func (*Repository) GetUnit added in v1.1.0

func (repo *Repository) GetUnit(tp UnitType) (*RepoUnit, error)

GetUnit returns a RepoUnit object

func (*Repository) GetUserFork added in v1.1.0

func (repo *Repository) GetUserFork(userID int64) (*Repository, error)

GetUserFork return user forked repository from this repository, if not forked return nil

func (*Repository) GetUserIfHasWriteAccess added in v1.5.0

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

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

func (*Repository) GetWatchers

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

GetWatchers returns range of users watching given repository.

func (*Repository) GetWriters added in v1.3.0

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

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

func (*Repository) GitConfigPath

func (repo *Repository) GitConfigPath() string

GitConfigPath returns the repository git config path

func (*Repository) HTMLURL

func (repo *Repository) HTMLURL() string

HTMLURL returns the repository HTML URL

func (*Repository) HasAccess

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

HasAccess returns true when user has access to this repository

func (*Repository) HasWiki

func (repo *Repository) HasWiki() bool

HasWiki returns true if repository has wiki.

func (*Repository) InitWiki

func (repo *Repository) InitWiki() error

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

func (*Repository) IsCollaborator added in v1.1.0

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

IsCollaborator check if a user is a collaborator of a repository

func (*Repository) IsOwnedBy

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

IsOwnedBy returns true when user owns this repository

func (*Repository) IsProtectedBranch added in v1.2.0

func (repo *Repository) IsProtectedBranch(branchName string, doer *User) (bool, error)

IsProtectedBranch checks if branch is protected

func (*Repository) IsProtectedBranchForMerging added in v1.5.0

func (repo *Repository) IsProtectedBranchForMerging(branchName string, doer *User) (bool, error)

IsProtectedBranchForMerging checks if branch is protected for merging

func (*Repository) IsTimetrackerEnabled added in v1.3.0

func (repo *Repository) IsTimetrackerEnabled() bool

IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.

func (*Repository) IssueStats

func (repo *Repository) IssueStats(uid int64, filterMode int, isPull bool) (int64, int64)

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

func (repo *Repository) Link() string

Link returns the repository link

func (*Repository) LoadUnitsByUserID added in v1.2.0

func (repo *Repository) LoadUnitsByUserID(userID int64, isAdmin bool) error

LoadUnitsByUserID loads units according userID's permissions

func (*Repository) LocalCopyPath

func (repo *Repository) LocalCopyPath() string

LocalCopyPath returns the local repository copy path for the given repo.

func (*Repository) LocalWikiPath

func (repo *Repository) LocalWikiPath() string

LocalWikiPath returns the path to the local wiki repository (?).

func (*Repository) MustGetUnit added in v1.1.0

func (repo *Repository) MustGetUnit(tp UnitType) *RepoUnit

MustGetUnit always returns a RepoUnit object

func (*Repository) MustOwner

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 details when error occurs.

func (*Repository) MustOwnerName added in v1.4.1

func (repo *Repository) MustOwnerName() string

MustOwnerName always returns valid owner name to avoid conceptually impossible error handling. It returns "error" and logs error details when error occurs.

func (*Repository) NextIssueIndex

func (repo *Repository) NextIssueIndex() int64

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

func (*Repository) PatchPath

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

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

func (*Repository) RecalculateAccesses

func (repo *Repository) RecalculateAccesses() error

RecalculateAccesses recalculates all accesses for repository.

func (repo *Repository) RelLink() string

RelLink returns the repository relative link

func (*Repository) RemoveDeletedBranch added in v1.3.0

func (repo *Repository) RemoveDeletedBranch(id int64) (err error)

RemoveDeletedBranch removes a deleted branch from the database

func (*Repository) RemoveLFSMetaObjectByOid added in v1.3.0

func (repo *Repository) RemoveLFSMetaObjectByOid(oid string) error

RemoveLFSMetaObjectByOid removes a LFSMetaObject entry from database by its OID. It may return ErrLFSObjectNotExist or a database error.

func (*Repository) RepoPath

func (repo *Repository) RepoPath() string

RepoPath returns the repository path

func (*Repository) SavePatch

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

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

func (*Repository) UnitEnabled added in v1.2.0

func (repo *Repository) UnitEnabled(tp UnitType) bool

UnitEnabled if this repository has the given unit enabled

func (*Repository) UpdateDefaultBranch added in v1.1.0

func (repo *Repository) UpdateDefaultBranch() error

UpdateDefaultBranch updates the default branch

func (*Repository) UpdateLocalCopyBranch

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

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

func (*Repository) UpdateRepoFile

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

UpdateRepoFile adds or updates a file in repository.

func (*Repository) UpdateSize added in v1.2.0

func (repo *Repository) UpdateSize() error

UpdateSize updates the repository size, calculating it using git.GetRepoSize

func (*Repository) UploadRepoFiles

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

UploadRepoFiles uploads files to a repository

func (repo *Repository) WikiCloneLink() *CloneLink

WikiCloneLink returns clone URLs of repository wiki.

func (*Repository) WikiPath

func (repo *Repository) WikiPath() string

WikiPath returns wiki data path for given repository.

type RepositoryList

type RepositoryList []*Repository

RepositoryList contains a list of repositories

func RepositoryListOfMap added in v1.2.0

func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList

RepositoryListOfMap make list from values of map

func SearchRepositoryByName

func SearchRepositoryByName(opts *SearchRepoOptions) (RepositoryList, int64, error)

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

func (RepositoryList) Len added in v1.4.0

func (repos RepositoryList) Len() int

func (RepositoryList) Less added in v1.4.0

func (repos RepositoryList) Less(i, j int) bool

func (RepositoryList) LoadAttributes

func (repos RepositoryList) LoadAttributes() error

LoadAttributes loads the attributes for the given RepositoryList

func (RepositoryList) Swap added in v1.4.0

func (repos RepositoryList) Swap(i, j int)

type SMTPConfig

type SMTPConfig struct {
	Auth           string
	Host           string
	Port           int
	AllowedDomains string `xorm:"TEXT"`
	TLS            bool
	SkipVerify     bool
}

SMTPConfig holds configuration for the SMTP login source.

func (*SMTPConfig) FromDB

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

FromDB fills up an SMTPConfig from serialized format.

func (*SMTPConfig) ToDB

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

ToDB exports an SMTPConfig to a serialized format.

type SearchOrderBy added in v1.3.0

type SearchOrderBy string

SearchOrderBy is used to sort the result

func (SearchOrderBy) String added in v1.3.0

func (s SearchOrderBy) String() string

type SearchRepoOptions

type SearchRepoOptions struct {
	Keyword   string
	OwnerID   int64
	OrderBy   SearchOrderBy
	Private   bool // Include private repositories in results
	Starred   bool
	Page      int
	IsProfile bool
	AllPublic bool // Include also all public repositories
	PageSize  int  // Can be smaller than or equal to setting.ExplorePagingNum
	// None -> include collaborative AND non-collaborative
	// True -> include just collaborative
	// False -> incude just non-collaborative
	Collaborate util.OptionalBool
	// None -> include forks AND non-forks
	// True -> include just forks
	// False -> include just non-forks
	Fork util.OptionalBool
	// None -> include mirrors AND non-mirrors
	// True -> include just mirrors
	// False -> include just non-mirrors
	Mirror util.OptionalBool
}

SearchRepoOptions holds the search options

type SearchUserOptions

type SearchUserOptions struct {
	Keyword       string
	Type          UserType
	OrderBy       SearchOrderBy
	Page          int
	PageSize      int // Can be smaller than or equal to setting.UI.ExplorePagingNum
	IsActive      util.OptionalBool
	SearchByEmail bool // Search by email as well as username/full name
}

SearchUserOptions contains the options for searching

type SignCommit added in v1.2.0

type SignCommit struct {
	Verification *CommitVerification
	*UserCommit
}

SignCommit represents a commit with validation of signature.

type SignCommitWithStatuses added in v1.2.0

type SignCommitWithStatuses struct {
	Status *CommitStatus
	*SignCommit
}

SignCommitWithStatuses represents a commit with validation of signature and status state.

type SlackAttachment

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

SlackAttachment contains the slack message

type SlackMeta

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

SlackMeta contains the slack metadata

type SlackPayload

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

SlackPayload contains the information about the slack channel

func GetSlackPayload

func GetSlackPayload(p api.Payloader, event HookEventType, meta string) (*SlackPayload, error)

GetSlackPayload converts a slack webhook into a SlackPayload

func (*SlackPayload) JSONPayload

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

JSONPayload Marshals the SlackPayload to json

func (*SlackPayload) SetSecret

func (p *SlackPayload) SetSecret(_ string)

SetSecret sets the slack secret

type Star

type Star struct {
	ID     int64 `xorm:"pk autoincr"`
	UID    int64 `xorm:"UNIQUE(s)"`
	RepoID int64 `xorm:"UNIQUE(s)"`
}

Star represents a starred repo by an user.

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

Statistic contains the database statistics

func GetStatistic

func GetStatistic() (stats Statistic)

GetStatistic returns the database statistics

type Stopwatch added in v1.3.0

type Stopwatch struct {
	ID          int64          `xorm:"pk autoincr"`
	IssueID     int64          `xorm:"INDEX"`
	UserID      int64          `xorm:"INDEX"`
	CreatedUnix util.TimeStamp `xorm:"created"`
}

Stopwatch represents a stopwatch for time tracking.

func HasUserStopwatch added in v1.3.0

func HasUserStopwatch(userID int64) (exists bool, sw *Stopwatch, err error)

HasUserStopwatch returns true if the user has a stopwatch

type Team

type Team struct {
	ID          int64 `xorm:"pk autoincr"`
	OrgID       int64 `xorm:"INDEX"`
	LowerName   string
	Name        string
	Description string
	Authorize   AccessMode
	Repos       []*Repository `xorm:"-"`
	Members     []*User       `xorm:"-"`
	NumRepos    int
	NumMembers  int
	Units       []*TeamUnit `xorm:"-"`
}

Team represents a organization team.

func GetTeam

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

GetTeam returns team by given team name and organization.

func GetTeamByID

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

GetTeamByID returns team by given ID.

func GetTeamsWithAccessToRepo added in v1.3.0

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

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

func GetUserTeams

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

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

func (*Team) AddMember

func (t *Team) AddMember(userID 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

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

AddRepository adds new repository to team of organization.

func (*Team) GetMembers

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

GetMembers returns all members in team of organization.

func (*Team) GetRepositories

func (t *Team) GetRepositories() error

GetRepositories returns all repositories in team of organization.

func (*Team) HasRepository

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

HasRepository returns true if given repository belong to team.

func (*Team) HasWriteAccess added in v1.3.0

func (t *Team) HasWriteAccess() bool

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

func (*Team) IsMember

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

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

func (*Team) IsOwnerTeam

func (t *Team) IsOwnerTeam() bool

IsOwnerTeam returns true if team is owner team.

func (*Team) RemoveMember

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

RemoveMember removes member from team of organization.

func (*Team) RemoveRepository

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

RemoveRepository removes repository from team of organization.

func (*Team) UnitEnabled added in v1.2.0

func (t *Team) UnitEnabled(tp UnitType) bool

UnitEnabled returns if the team has the given unit type enabled

type TeamRepo

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

TeamRepo represents an team-repository relation.

type TeamUnit added in v1.5.0

type TeamUnit struct {
	ID     int64    `xorm:"pk autoincr"`
	OrgID  int64    `xorm:"INDEX"`
	TeamID int64    `xorm:"UNIQUE(s)"`
	Type   UnitType `xorm:"UNIQUE(s)"`
}

TeamUnit describes all units of a repository

func (*TeamUnit) Unit added in v1.5.0

func (t *TeamUnit) Unit() Unit

Unit returns Unit

type TeamUser

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

TeamUser represents an team-user relation.

type Topic added in v1.5.0

type Topic struct {
	ID          int64
	Name        string `xorm:"UNIQUE"`
	RepoCount   int
	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

Topic represents a topic of repositories

func FindTopics added in v1.5.0

func FindTopics(opts *FindTopicOptions) (topics []*Topic, err error)

FindTopics retrieves the topics via FindTopicOptions

func GetTopicByName added in v1.5.0

func GetTopicByName(name string) (*Topic, error)

GetTopicByName retrieves topic by name

type TrackedTime added in v1.3.0

type TrackedTime struct {
	ID          int64     `xorm:"pk autoincr" json:"id"`
	IssueID     int64     `xorm:"INDEX" json:"issue_id"`
	UserID      int64     `xorm:"INDEX" json:"user_id"`
	Created     time.Time `xorm:"-" json:"created"`
	CreatedUnix int64     `xorm:"created" json:"-"`
	Time        int64     `json:"time"`
}

TrackedTime represents a time that was spent for a specific issue.

func AddTime added in v1.3.0

func AddTime(user *User, issue *Issue, time int64) (*TrackedTime, error)

AddTime will add the given time (in seconds) to the issue

func GetTrackedTimes added in v1.3.0

func GetTrackedTimes(options FindTrackedTimesOptions) (trackedTimes []*TrackedTime, err error)

GetTrackedTimes returns all tracked times that fit to the given options.

func (*TrackedTime) APIFormat added in v1.3.0

func (t *TrackedTime) APIFormat() *api.TrackedTime

APIFormat converts TrackedTime to API format

func (*TrackedTime) AfterLoad added in v1.3.0

func (t *TrackedTime) AfterLoad()

AfterLoad is invoked from XORM after setting the values of all fields of this object.

type TwoFactor added in v1.1.0

type TwoFactor struct {
	ID               int64 `xorm:"pk autoincr"`
	UID              int64 `xorm:"UNIQUE"`
	Secret           string
	ScratchToken     string
	LastUsedPasscode string         `xorm:"VARCHAR(10)"`
	CreatedUnix      util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix      util.TimeStamp `xorm:"INDEX updated"`
}

TwoFactor represents a two-factor authentication token.

func GetTwoFactorByUID added in v1.1.0

func GetTwoFactorByUID(uid int64) (*TwoFactor, error)

GetTwoFactorByUID returns the two-factor authentication token associated with the user, if any.

func (*TwoFactor) GenerateScratchToken added in v1.1.0

func (t *TwoFactor) GenerateScratchToken() error

GenerateScratchToken recreates the scratch token the user is using.

func (*TwoFactor) SetSecret added in v1.1.0

func (t *TwoFactor) SetSecret(secret string) error

SetSecret sets the 2FA secret.

func (*TwoFactor) ValidateTOTP added in v1.1.0

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

ValidateTOTP validates the provided passcode.

func (*TwoFactor) VerifyScratchToken added in v1.1.0

func (t *TwoFactor) VerifyScratchToken(token string) bool

VerifyScratchToken verifies if the specified scratch token is valid.

type U2FRegistration added in v1.5.0

type U2FRegistration struct {
	ID          int64 `xorm:"pk autoincr"`
	Name        string
	UserID      int64 `xorm:"INDEX"`
	Raw         []byte
	Counter     uint32
	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

U2FRegistration represents the registration data and counter of a security key

func CreateRegistration added in v1.5.0

func CreateRegistration(user *User, name string, reg *u2f.Registration) (*U2FRegistration, error)

CreateRegistration will create a new U2FRegistration from the given Registration

func GetU2FRegistrationByID added in v1.5.0

func GetU2FRegistrationByID(id int64) (*U2FRegistration, error)

GetU2FRegistrationByID returns U2F registration by id

func (*U2FRegistration) Parse added in v1.5.0

func (reg *U2FRegistration) Parse() (*u2f.Registration, error)

Parse will convert the db entry U2FRegistration to an u2f.Registration struct

func (U2FRegistration) TableName added in v1.5.0

func (reg U2FRegistration) TableName() string

TableName returns a better table name for U2FRegistration

func (*U2FRegistration) UpdateCounter added in v1.5.0

func (reg *U2FRegistration) UpdateCounter() error

UpdateCounter will update the database value of counter

type U2FRegistrationList added in v1.5.0

type U2FRegistrationList []*U2FRegistration

U2FRegistrationList is a list of *U2FRegistration

func GetU2FRegistrationsByUID added in v1.5.0

func GetU2FRegistrationsByUID(uid int64) (U2FRegistrationList, error)

GetU2FRegistrationsByUID returns all U2F registrations of the given user

func (U2FRegistrationList) ToRegistrations added in v1.5.0

func (list U2FRegistrationList) ToRegistrations() []u2f.Registration

ToRegistrations will convert all U2FRegistrations to u2f.Registrations

type Unit added in v1.1.0

type Unit struct {
	Type    UnitType
	NameKey string
	URI     string
	DescKey string
	Idx     int
}

Unit is a section of one repository

func (*Unit) CanDisable added in v1.2.0

func (u *Unit) CanDisable() bool

CanDisable returns if this unit could be disabled.

func (Unit) IsLessThan added in v1.3.0

func (u Unit) IsLessThan(unit Unit) bool

IsLessThan compares order of two units

type UnitConfig added in v1.1.0

type UnitConfig struct {
}

UnitConfig describes common unit config

func (*UnitConfig) FromDB added in v1.1.0

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

FromDB fills up a UnitConfig from serialized format.

func (*UnitConfig) ToDB added in v1.1.0

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

ToDB exports a UnitConfig to a serialized format.

type UnitType added in v1.1.0

type UnitType int

UnitType is Unit's Type

const (
	UnitTypeCode            UnitType = iota + 1 // 1 code
	UnitTypeIssues                              // 2 issues
	UnitTypePullRequests                        // 3 PRs
	UnitTypeReleases                            // 4 Releases
	UnitTypeWiki                                // 5 Wiki
	UnitTypeExternalWiki                        // 6 ExternalWiki
	UnitTypeExternalTracker                     // 7 ExternalTracker
)

Enumerate all the unit types

type UpdateRepoFileOptions

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

UpdateRepoFileOptions holds the repository file update options

type Upload

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

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

func GetUploadByUUID

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

GetUploadByUUID returns the Upload by UUID

func GetUploadsByUUIDs

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

GetUploadsByUUIDs returns multiple uploads by UUIDS

func NewUpload

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

NewUpload creates a new upload object.

func (*Upload) LocalPath

func (upload *Upload) LocalPath() string

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

type UploadRepoFileOptions

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

UploadRepoFileOptions contains the uploaded repository file options

type User

type User struct {
	ID        int64  `xorm:"pk autoincr"`
	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"`
	KeepEmailPrivate bool
	Passwd           string `xorm:"NOT NULL"`
	LoginType        LoginType
	LoginSource      int64 `xorm:"NOT NULL DEFAULT 0"`
	LoginName        string
	Type             UserType
	OwnedOrgs        []*User       `xorm:"-"`
	Orgs             []*User       `xorm:"-"`
	Repos            []*Repository `xorm:"-"`
	Location         string
	Website          string
	Rands            string `xorm:"VARCHAR(10)"`
	Salt             string `xorm:"VARCHAR(10)"`
	Language         string `xorm:"VARCHAR(5)"`

	CreatedUnix   util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix   util.TimeStamp `xorm:"INDEX updated"`
	LastLoginUnix util.TimeStamp `xorm:"INDEX"`

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

	// Permissions
	IsActive                bool `xorm:"INDEX"` // Activate primary email
	IsAdmin                 bool
	AllowGitHook            bool
	AllowImportLocal        bool // Allow migrate repository by local path
	AllowCreateOrganization bool `xorm:"DEFAULT true"`
	ProhibitLogin           bool `xorm:"NOT NULL DEFAULT false"`

	// 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:"-"`
	Members     []*User `xorm:"-"`

	// Preferences
	DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
}

User represents the object of individual and member of organization.

func ExternalUserLogin

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

ExternalUserLogin attempts a login using external source types.

func GetAssigneesByIssue added in v1.5.0

func GetAssigneesByIssue(issue *Issue) (assignees []*User, err error)

GetAssigneesByIssue returns everyone assigned to that issue

func GetOrgByName

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

GetOrgByName returns organization by given name.

func GetOrgsByUserID

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

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

func GetOwnedOrgsByUserID

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

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

func GetOwnedOrgsByUserIDDesc

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

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

func GetParticipantsByIssueID added in v1.2.0

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

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

func GetTeamMembers

func GetTeamMembers(teamID int64) ([]*User, error)

GetTeamMembers returns all members in given team of organization.

func GetUserByEmail

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

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

func GetUserByID

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

GetUserByID returns the user object by given ID if exists.

func GetUserByKeyID

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

GetUserByKeyID get user information by user's public key id

func GetUserByName

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

GetUserByName returns user by given name.

func GetUserByOpenID added in v1.2.0

func GetUserByOpenID(uri string) (*User, error)

GetUserByOpenID returns the user object by given OpenID if exists.

func GetUserIfHasWriteAccess added in v1.5.0

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

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

func GetUsersByIDs added in v1.0.0

func GetUsersByIDs(ids []int64) ([]*User, error)

GetUsersByIDs returns all resolved users from a list of Ids.

func LoginViaLDAP

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

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

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

func NewGhostUser() *User

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

func SearchUsers added in v1.3.0

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

SearchUsers takes options i.e. keyword and part of user name to search, it returns results in given range and number of total results.

func UserSignIn

func UserSignIn(username, password string) (*User, error)

UserSignIn validates user name and password.

func ValidateCommitWithEmail

func ValidateCommitWithEmail(c *git.Commit) *User

ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user.

func VerifyUserActiveCode

func VerifyUserActiveCode(code string) (user *User)

VerifyUserActiveCode verifies active code when active account

func (*User) APIFormat

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

APIFormat converts a User to api.User

func (*User) AccessibleReposEnv added in v1.1.0

func (org *User) AccessibleReposEnv(userID int64) (AccessibleReposEnvironment, error)

AccessibleReposEnv an AccessibleReposEnvironment for the repositories in `org` that are accessible to the specified user.

func (*User) AddMember

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

AddMember adds new member to organization.

func (u *User) AvatarLink() string

AvatarLink returns user avatar absolute link.

func (*User) BeforeUpdate

func (u *User) BeforeUpdate()

BeforeUpdate is invoked from XORM before updating this object.

func (*User) CanCreateOrganization added in v1.1.0

func (u *User) CanCreateOrganization() bool

CanCreateOrganization returns true if user can create organisation.

func (*User) CanCreateRepo

func (u *User) CanCreateRepo() bool

CanCreateRepo returns if user login can create a repository

func (*User) CanEditGitHook

func (u *User) CanEditGitHook() bool

CanEditGitHook returns true if user can edit Git hooks.

func (*User) CanImportLocal

func (u *User) CanImportLocal() bool

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

func (*User) CustomAvatarPath

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

func (u *User) DeleteAvatar() error

DeleteAvatar deletes the user's custom avatar.

func (*User) DisplayName

func (u *User) DisplayName() string

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

func (*User) GenerateActivateCode

func (u *User) GenerateActivateCode() string

GenerateActivateCode generates an activate code based on user information.

func (*User) GenerateEmailActivateCode

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

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

func (*User) GenerateRandomAvatar

func (u *User) GenerateRandomAvatar() error

GenerateRandomAvatar generates a random avatar for user.

func (*User) GetAccessRepoIDs added in v1.1.0

func (u *User) GetAccessRepoIDs(units ...UnitType) ([]int64, error)

GetAccessRepoIDs returns all repositories IDs where user's or user is a team member organizations

func (*User) GetAccessibleRepositories

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

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

GetFollowers returns range of user's followers.

func (*User) GetFollowing

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

GetFollowing returns range of user's following.

func (*User) GetMembers

func (org *User) GetMembers() error

GetMembers returns all members of organization.

func (*User) GetMirrorRepositories

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

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

func (*User) GetOrgRepositoryIDs added in v1.1.0

func (u *User) GetOrgRepositoryIDs(units ...UnitType) ([]int64, error)

GetOrgRepositoryIDs returns repositories IDs where user's team owned and has unittypes

func (*User) GetOrganizationCount

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

GetOrganizationCount returns count of membership of organization of user.

func (*User) GetOrganizations

func (u *User) GetOrganizations(all bool) error

GetOrganizations returns all organizations that user belongs to.

func (*User) GetOwnedOrganizations

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

GetOwnedOrganizations returns all organizations that user owns.

func (*User) GetOwnerTeam

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

GetOwnerTeam returns owner team of organization.

func (*User) GetRepositories

func (u *User) GetRepositories(page, pageSize int) (err error)

GetRepositories returns repositories that user owns, including private repositories.

func (*User) GetRepositoryAccesses

func (user *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) GetRepositoryIDs added in v1.1.0

func (u *User) GetRepositoryIDs(units ...UnitType) ([]int64, error)

GetRepositoryIDs returns repositories IDs where user owned and has unittypes

func (*User) GetStarredRepoCount added in v1.1.0

func (u *User) GetStarredRepoCount(private bool) (int64, error)

GetStarredRepoCount returns the numbers of repo the user starred.

func (*User) GetStarredRepos added in v1.1.0

func (u *User) GetStarredRepos(private bool, page, pageSize int, orderBy string) (repos RepositoryList, err error)

GetStarredRepos returns the repos the user starred.

func (*User) GetTeam

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

GetTeam returns named team of organization.

func (*User) GetTeams

func (org *User) GetTeams() error

GetTeams returns all teams that belong to organization.

func (*User) GetUserTeamIDs

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

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

func (*User) GetUserTeams

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

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

func (*User) HTMLURL added in v1.1.0

func (u *User) HTMLURL() string

HTMLURL returns the user or organization's full link.

func (*User) HasForkedRepo

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

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

func (*User) HashPassword added in v1.4.0

func (u *User) HashPassword(passwd string)

HashPassword hashes a password using PBKDF.

func (u *User) HomeLink() string

HomeLink returns the user or organization home page link.

func (*User) IsAdminOfRepo

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

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

func (*User) IsFollowing

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

IsFollowing returns true if user is following followID.

func (*User) IsLocal

func (u *User) IsLocal() bool

IsLocal returns true if user login type is LoginPlain.

func (*User) IsMailable added in v1.1.0

func (u *User) IsMailable() bool

IsMailable checks if a user is eligible to receive emails.

func (*User) IsOAuth2 added in v1.1.0

func (u *User) IsOAuth2() bool

IsOAuth2 returns true if user login type is LoginOAuth2.

func (*User) IsOrgMember

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

IsOrgMember returns true if given user is member of organization.

func (*User) IsOrganization

func (u *User) IsOrganization() bool

IsOrganization returns true if user is actually a organization.

func (*User) IsOwnedBy

func (org *User) IsOwnedBy(uid int64) (bool, error)

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

func (*User) IsPasswordSet added in v1.1.0

func (u *User) IsPasswordSet() bool

IsPasswordSet checks if the password is set or left empty

func (*User) IsPublicMember

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

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

func (*User) IsUserOrgOwner

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

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

func (*User) IsWriterOfRepo

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

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

func (*User) MaxCreationLimit added in v1.2.0

func (u *User) MaxCreationLimit() int

MaxCreationLimit returns the number of repositories a user is allowed to create

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 a relative link to the user's avatar. The link may either be a sub-URL to this site, or a full URL to an external avatar service.

func (*User) RemoveMember

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

RemoveMember removes member from organization.

func (*User) RemoveOrgRepo

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

RemoveOrgRepo removes all team-repository relations of organization.

func (*User) SetLastLogin added in v1.0.0

func (u *User) SetLastLogin()

SetLastLogin set time to last login

func (*User) ShortName

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

ShortName ellipses username to length

func (u *User) SizedRelAvatarLink(size int) string

SizedRelAvatarLink returns a relative link to the user's avatar. When applicable, the link is for an avatar of the indicated size (in pixels).

func (*User) TeamsWithAccessToRepo added in v1.3.0

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

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

func (*User) UpdateDiffViewStyle added in v1.0.0

func (u *User) UpdateDiffViewStyle(style string) error

UpdateDiffViewStyle updates the users diff view style

func (*User) UploadAvatar

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

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

func (*User) ValidatePassword

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

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

type UserCommit

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

UserCommit represents a commit with validation of user.

type UserIssueStatsOptions added in v1.4.0

type UserIssueStatsOptions struct {
	UserID      int64
	RepoID      int64
	UserRepoIDs []int64
	FilterMode  int
	IsPull      bool
	IsClosed    bool
}

UserIssueStatsOptions contains parameters accepted by GetUserIssueStats.

type UserOpenID added in v1.2.0

type UserOpenID struct {
	ID   int64  `xorm:"pk autoincr"`
	UID  int64  `xorm:"INDEX NOT NULL"`
	URI  string `xorm:"UNIQUE NOT NULL"`
	Show bool   `xorm:"DEFAULT false"`
}

UserOpenID is the list of all OpenID identities of a user.

func GetUserOpenIDs added in v1.2.0

func GetUserOpenIDs(uid int64) ([]*UserOpenID, error)

GetUserOpenIDs returns all openid addresses that belongs to given user.

type UserType

type UserType int

UserType defines the user type

const (
	// UserTypeIndividual defines an individual user
	UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.

	// UserTypeOrganization defines an organization
	UserTypeOrganization
)

type Watch

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

Watch is connection request for receiving repository notification.

func GetWatchers

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

GetWatchers returns all watchers of given repository.

type Webhook

type Webhook struct {
	ID           int64  `xorm:"pk autoincr"`
	RepoID       int64  `xorm:"INDEX"`
	OrgID        int64  `xorm:"INDEX"`
	URL          string `xorm:"url TEXT"`
	ContentType  HookContentType
	Secret       string `xorm:"TEXT"`
	Events       string `xorm:"TEXT"`
	*HookEvent   `xorm:"-"`
	IsSSL        bool `xorm:"is_ssl"`
	IsActive     bool `xorm:"INDEX"`
	HookTaskType HookTaskType
	Meta         string     `xorm:"TEXT"` // store hook-specific attributes
	LastStatus   HookStatus // Last delivery status

	CreatedUnix util.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
}

Webhook represents a web hook object.

func GetActiveWebhooksByOrgID

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

GetActiveWebhooksByOrgID returns all active webhooks for an organization.

func GetActiveWebhooksByRepoID

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

GetActiveWebhooksByRepoID returns all active webhooks of repository.

func GetWebhookByID added in v1.3.0

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

GetWebhookByID returns webhook of repository by given ID.

func GetWebhookByOrgID

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

GetWebhookByOrgID returns webhook of organization by given ID.

func GetWebhookByRepoID

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

GetWebhookByRepoID returns webhook of repository by given ID.

func GetWebhooksByOrgID

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

GetWebhooksByOrgID returns all webhooks for an organization.

func GetWebhooksByRepoID

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

GetWebhooksByRepoID returns all webhooks of a repository.

func (*Webhook) AfterLoad added in v1.3.0

func (w *Webhook) AfterLoad()

AfterLoad updates the webhook object upon setting a column

func (*Webhook) EventsArray

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

EventsArray returns an array of hook events

func (*Webhook) GetDiscordHook added in v1.3.0

func (w *Webhook) GetDiscordHook() *DiscordMeta

GetDiscordHook returns discord metadata

func (*Webhook) GetSlackHook

func (w *Webhook) GetSlackHook() *SlackMeta

GetSlackHook returns slack metadata

func (*Webhook) HasCreateEvent

func (w *Webhook) HasCreateEvent() bool

HasCreateEvent returns true if hook enabled create event.

func (*Webhook) HasDeleteEvent added in v1.5.0

func (w *Webhook) HasDeleteEvent() bool

HasDeleteEvent returns true if hook enabled delete event.

func (*Webhook) HasForkEvent added in v1.5.0

func (w *Webhook) HasForkEvent() bool

HasForkEvent returns true if hook enabled fork event.

func (*Webhook) HasIssueCommentEvent added in v1.5.0

func (w *Webhook) HasIssueCommentEvent() bool

HasIssueCommentEvent returns true if hook enabled issue_comment event.

func (*Webhook) HasIssuesEvent added in v1.5.0

func (w *Webhook) HasIssuesEvent() bool

HasIssuesEvent returns true if hook enabled issues event.

func (*Webhook) HasPullRequestEvent

func (w *Webhook) HasPullRequestEvent() bool

HasPullRequestEvent returns true if hook enabled pull request event.

func (*Webhook) HasPushEvent

func (w *Webhook) HasPushEvent() bool

HasPushEvent returns true if hook enabled push event.

func (*Webhook) HasReleaseEvent added in v1.5.0

func (w *Webhook) HasReleaseEvent() bool

HasReleaseEvent returns if hook enabled release event.

func (*Webhook) HasRepositoryEvent added in v1.3.0

func (w *Webhook) HasRepositoryEvent() bool

HasRepositoryEvent returns if hook enabled repository event.

func (*Webhook) History

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

History returns history of webhook by given conditions.

func (*Webhook) UpdateEvent

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