models

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 97 Imported by: 1,618

Documentation

Index

Constants

View Source
const (
	// BadSignature is used as the reason when the signature has a KeyID that is in the db
	// but no key that has that ID verifies the signature. This is a suspicious failure.
	BadSignature = "gpg.error.probable_bad_signature"
	// BadDefaultSignature is used as the reason when the signature has a KeyID that matches the
	// default Key but is not verified by the default key. This is a suspicious failure.
	BadDefaultSignature = "gpg.error.probable_bad_default_signature"
	// NoKeyFound is used as the reason when no key can be found to verify the signature.
	NoKeyFound = "gpg.error.no_gpg_keys_found"
)
View Source
const (
	EnvRepoName     = "GITEA_REPO_NAME"
	EnvRepoUsername = "GITEA_REPO_USER_NAME"
	EnvRepoID       = "GITEA_REPO_ID"
	EnvRepoIsWiki   = "GITEA_REPO_IS_WIKI"
	EnvPusherName   = "GITEA_PUSHER_NAME"
	EnvPusherEmail  = "GITEA_PUSHER_EMAIL"
	EnvPusherID     = "GITEA_PUSHER_ID"
	EnvKeyID        = "GITEA_KEY_ID"
	EnvIsDeployKey  = "GITEA_IS_DEPLOY_KEY"
	EnvPRID         = "GITEA_PR_ID"
	EnvIsInternal   = "GITEA_INTERNAL_PUSH"
	EnvAppURL       = "GITEA_ROOT_URL"
)

env keys for git hooks need

View Source
const (
	FilterModeAll = iota
	FilterModeAssign
	FilterModeCreate
	FilterModeMention
	FilterModeReviewRequested
)

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 (
	// KeyTypeUser specifies the user key
	KeyTypeUser = iota + 1
	// KeyTypeDeploy specifies the deploy key
	KeyTypeDeploy
	// KeyTypePrincipal specifies the authorized principal key
	KeyTypePrincipal
)
View Source
const (
	// EmailNotificationsEnabled indicates that the user would like to receive all email notifications
	EmailNotificationsEnabled = "enabled"
	// EmailNotificationsOnMention indicates that the user would like to be notified via email when mentioned.
	EmailNotificationsOnMention = "onmention"
	// EmailNotificationsDisabled indicates that the user would not like to be notified via email.
	EmailNotificationsDisabled = "disabled"
)
View Source
const (
	HookStatusNone = iota
	HookStatusSucceed
	HookStatusFail
)

Possible statuses of a web hook

View Source
const AvatarRenderedSizeFactor = 2

AvatarRenderedSizeFactor is the factor by which the default size is increased for finer rendering

View Source
const DefaultAvatarPixelSize = 28

DefaultAvatarPixelSize is the default size in pixels of a rendered avatar

View Source
const DefaultAvatarSize = -1

DefaultAvatarSize is a sentinel value for the default avatar size, as determined by the avatar-hosting service.

View Source
const NonexistentID = int64(math.MaxInt64)

NonexistentID an ID that will never exist

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 (
	// 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 and the list of labels for each file
	LabelTemplates map[string]string

	// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
	ItemsPerPage = 40
)
View Source
var (
	// AllRepoUnitTypes contains all the unit types
	AllRepoUnitTypes = []UnitType{
		UnitTypeCode,
		UnitTypeIssues,
		UnitTypePullRequests,
		UnitTypeReleases,
		UnitTypeWiki,
		UnitTypeExternalWiki,
		UnitTypeExternalTracker,
		UnitTypeProjects,
	}

	// DefaultRepoUnits contains the default unit types
	DefaultRepoUnits = []UnitType{
		UnitTypeCode,
		UnitTypeIssues,
		UnitTypePullRequests,
		UnitTypeReleases,
		UnitTypeWiki,
		UnitTypeProjects,
	}

	// NotAllowedDefaultRepoUnits contains units that can't be default
	NotAllowedDefaultRepoUnits = []UnitType{
		UnitTypeExternalWiki,
		UnitTypeExternalTracker,
	}

	// MustRepoUnits contains the units could not be disabled currently
	MustRepoUnits = []UnitType{
		UnitTypeCode,
		UnitTypeReleases,
	}

	// DisabledRepoUnits contains the units that have been globally disabled
	DisabledRepoUnits = []UnitType{}
)
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,
	}

	UnitProjects = Unit{
		UnitTypeProjects,
		"repo.projects",
		"/projects",
		"repo.projects.desc",
		5,
	}

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

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 AvailableHashAlgorithms = []string{
	algoPbkdf2,
	algoArgon2,
	algoScrypt,
	algoBcrypt,
}

AvailableHashAlgorithms represents the available password hashing algorithms

View Source
var ErrEmailAddressNotExist = errors.New("Email address does not exist")

ErrEmailAddressNotExist email address not exist

View Source
var ErrLFSObjectNotExist = errors.New("LFS Meta object does not exist")

ErrLFSObjectNotExist is returned from lfs models functions in order to differentiate between database and missing object errors.

View Source
var ErrOpenIDNotExist = errors.New("OpenID is unknown")

ErrOpenIDNotExist openid is not known

View Source
var (

	// HasEngine specifies if we have a xorm.Engine
	HasEngine bool
)
View Source
var LabelColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")

LabelColorPattern is a regexp witch can validate LabelColor

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

LoginNames contains the name of LoginType values.

View Source
var OAuth2DefaultCustomURLMappings = map[string]*oauth2.CustomURLMapping{
	"github":    OAuth2Providers["github"].CustomURLMapping,
	"gitlab":    OAuth2Providers["gitlab"].CustomURLMapping,
	"gitea":     OAuth2Providers["gitea"].CustomURLMapping,
	"nextcloud": OAuth2Providers["nextcloud"].CustomURLMapping,
	"mastodon":  OAuth2Providers["mastodon"].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.png"},
	"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/img/auth/openid_connect.svg"},
	"twitter":       {Name: "twitter", DisplayName: "Twitter", Image: "/img/auth/twitter.png"},
	"discord":       {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"},
	"gitea": {
		Name: "gitea", DisplayName: "Gitea", Image: "/img/auth/gitea.png",
		CustomURLMapping: &oauth2.CustomURLMapping{
			TokenURL:   oauth2.GetDefaultTokenURL("gitea"),
			AuthURL:    oauth2.GetDefaultAuthURL("gitea"),
			ProfileURL: oauth2.GetDefaultProfileURL("gitea"),
		},
	},
	"nextcloud": {
		Name: "nextcloud", DisplayName: "Nextcloud", Image: "/img/auth/nextcloud.png",
		CustomURLMapping: &oauth2.CustomURLMapping{
			TokenURL:   oauth2.GetDefaultTokenURL("nextcloud"),
			AuthURL:    oauth2.GetDefaultAuthURL("nextcloud"),
			ProfileURL: oauth2.GetDefaultProfileURL("nextcloud"),
		},
	},
	"yandex": {Name: "yandex", DisplayName: "Yandex", Image: "/img/auth/yandex.png"},
	"mastodon": {
		Name: "mastodon", DisplayName: "Mastodon", Image: "/img/auth/mastodon.png",
		CustomURLMapping: &oauth2.CustomURLMapping{
			AuthURL: oauth2.GetDefaultAuthURL("mastodon"),
		},
	},
}

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 AccessTokenByNameExists added in v1.12.0

func AccessTokenByNameExists(token *AccessToken) (bool, error)

AccessTokenByNameExists checks if a token name has been used already by a user.

func AccessibleRepoIDsQuery added in v1.11.0

func AccessibleRepoIDsQuery(user *User) *builder.Builder

AccessibleRepoIDsQuery queries accessible repository ids. Usable as a subquery wherever repo ids need to be filtered.

func ActivateUserEmail added in v1.11.2

func ActivateUserEmail(userID int64, email string, primary, activate bool) (err error)

ActivateUserEmail will change the activated state of an email address, either primary (in the user table) or secondary (in the email_address table)

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 AddReleaseAttachments added in v1.10.0

func AddReleaseAttachments(releaseID int64, attachmentUUIDs []string) (err error)

AddReleaseAttachments adds a release attachments

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 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, 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 AttachmentRelativePath added in v1.13.0

func AttachmentRelativePath(uuid string) string

AttachmentRelativePath returns the relative path

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 BuildLabelNamesIssueIDsCondition added in v1.12.0

func BuildLabelNamesIssueIDsCondition(labelNames []string) *builder.Builder

BuildLabelNamesIssueIDsCondition returns a builder where get issue ids match label names

func CalculateTrustStatus added in v1.11.2

func CalculateTrustStatus(verification *CommitVerification, repository *Repository, keyMap *map[string]bool) (err error)

CalculateTrustStatus will calculate the TrustStatus for a commit verification within a repository

func CanBeAssigned added in v1.11.0

func CanBeAssigned(user *User, repo *Repository, isPull bool) (bool, error)

CanBeAssigned return true if user can be assigned to issue or pull requests in repo Currently any write access (code, issues or pr's) is assignable, to match assignee list in user interface. FIXME: user could send PullRequest also could be assigned???

func CanCreateOrgRepo added in v1.11.0

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

CanCreateOrgRepo returns true if user can create repo in organization

func CanMarkConversation added in v1.12.0

func CanMarkConversation(issue *Issue, doer *User) (permResult bool, err error)

CanMarkConversation Add or remove Conversation mark for a code comment permission check the PR writer , offfcial reviewer and poster can do it

func CancelRepositoryTransfer added in v1.14.0

func CancelRepositoryTransfer(repo *Repository) error

CancelRepositoryTransfer marks the repository as ready and remove pending transfer entry, thus cancel the transfer process.

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 ChangeMilestoneStatusByRepoIDAndID added in v1.13.0

func ChangeMilestoneStatusByRepoIDAndID(repoID, milestoneID int64, isClosed bool) error

ChangeMilestoneStatusByRepoIDAndID changes a milestone open/closed status if the milestone ID is in the repo.

func ChangeOrgUserStatus

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

ChangeOrgUserStatus changes public or private membership status.

func ChangeProjectAssign added in v1.13.0

func ChangeProjectAssign(issue *Issue, doer *User, newProjectID int64) error

ChangeProjectAssign changes the project associated with an issue

func ChangeProjectStatus added in v1.13.0

func ChangeProjectStatus(p *Project, isClosed bool) error

ChangeProjectStatus toggle a project between opened and closed

func ChangeProjectStatusByRepoIDAndID added in v1.13.0

func ChangeProjectStatusByRepoIDAndID(repoID, projectID int64, isClosed bool) error

ChangeProjectStatusByRepoIDAndID toggles a project between opened and closed

func ChangeRepositoryName

func ChangeRepositoryName(doer *User, repo *Repository, 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 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 CheckCreateRepository added in v1.10.0

func CheckCreateRepository(doer, u *User, name string, overwriteOrAdopt bool) error

CheckCreateRepository check if could created a repository

func CheckIssueWatch added in v1.12.0

func CheckIssueWatch(user *User, issue *Issue) (bool, error)

CheckIssueWatch check if an user is watching an issue it takes participants and repo watch into account

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 CheckPrincipalKeyString added in v1.13.0

func CheckPrincipalKeyString(user *User, content string) (_ string, err error)

CheckPrincipalKeyString strips spaces and returns an error if the given principal contains newlines

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(ctx context.Context) error

CheckRepoStats checks the repository stats

func CleanupHookTaskTable added in v1.14.0

func CleanupHookTaskTable(ctx context.Context, cleanupType HookTaskCleanupType, olderThan time.Duration, numberToKeep int) error

CleanupHookTaskTable deletes rows from hook_task as needed.

func CleanupSessions added in v1.14.0

func CleanupSessions(maxLifetime int64) error

CleanupSessions cleans up expired sessions

func CommentHashTag added in v1.5.0

func CommentHashTag(id int64) string

CommentHashTag returns unique hash tag for comment id.

func CommentTypeIsRef added in v1.10.0

func CommentTypeIsRef(t CommentType) bool

CommentTypeIsRef returns true if CommentType is a reference from another issue

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 ConvertUtf8ToUtf8mb4 added in v1.9.0

func ConvertUtf8ToUtf8mb4() error

ConvertUtf8ToUtf8mb4 converts database and tables from utf8 to utf8mb4 if it's mysql and set ROW_FORMAT=dynamic

func CopyLFS added in v1.11.0

func CopyLFS(ctx DBContext, newRepo, oldRepo *Repository) error

CopyLFS copies LFS data from one repo to another

func CopyLanguageStat added in v1.12.0

func CopyLanguageStat(originalRepo, destRepo *Repository) error

CopyLanguageStat Copy originalRepo language stat information to destRepo (use for forked repo)

func Count added in v1.10.0

func Count(bean interface{}) (int64, error)

Count returns records number according struct's fields as database query conditions

func CountBadSequences added in v1.13.5

func CountBadSequences() (int64, error)

CountBadSequences looks for broken sequences from recreate-table mistakes

func CountCommentTypeLabelWithEmptyLabel added in v1.14.0

func CountCommentTypeLabelWithEmptyLabel() (int64, error)

CountCommentTypeLabelWithEmptyLabel count label comments with empty label

func CountCommentTypeLabelWithOutsideLabels added in v1.14.0

func CountCommentTypeLabelWithOutsideLabels() (int64, error)

CountCommentTypeLabelWithOutsideLabels count label comments with outside label

func CountIssueLabelWithOutsideLabels added in v1.14.0

func CountIssueLabelWithOutsideLabels() (int64, error)

CountIssueLabelWithOutsideLabels count label comments with outside label

func CountIssues added in v1.13.0

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

CountIssues number return of issues by given conditions.

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 CountLFSLockByRepoID added in v1.11.0

func CountLFSLockByRepoID(repoID int64) (int64, error)

CountLFSLockByRepoID returns a count of all LFSLocks associated with a repository.

func CountLoginSources

func CountLoginSources() int64

CountLoginSources returns number of login sources.

func CountMilestonesByRepoCond added in v1.12.0

func CountMilestonesByRepoCond(repoCond builder.Cond, isClosed bool) (map[int64]int64, error)

CountMilestonesByRepoCond map from repo conditions to number of milestones matching the options`

func CountNotices

func CountNotices() int64

CountNotices returns number of notices.

func CountNullArchivedRepository added in v1.12.0

func CountNullArchivedRepository() (int64, error)

CountNullArchivedRepository counts the number of repositories with is_archived is null

func CountOrgMembers added in v1.11.0

func CountOrgMembers(opts FindOrgMembersOpts) (int64, error)

CountOrgMembers counts the organization's members

func CountOrganizations

func CountOrganizations() int64

CountOrganizations returns number of organizations.

func CountOrphanedIssueLabels added in v1.13.5

func CountOrphanedIssueLabels() (int64, error)

CountOrphanedIssueLabels return count of IssueLabels witch have no label behind anymore

func CountOrphanedIssues added in v1.12.0

func CountOrphanedIssues() (int64, error)

CountOrphanedIssues count issues without a repo

func CountOrphanedLabels added in v1.12.0

func CountOrphanedLabels() (int64, error)

CountOrphanedLabels return count of labels witch are broken and not accessible via ui anymore

func CountOrphanedObjects added in v1.11.7

func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error)

CountOrphanedObjects count subjects with have no existing refobject anymore

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 CountSessions added in v1.14.0

func CountSessions() (int64, error)

CountSessions returns the number of sessions

func CountUnread added in v1.12.0

func CountUnread(user *User) int64

CountUnread count unread notifications for a user

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 CountWrongUserType added in v1.14.0

func CountWrongUserType() (int64, error)

CountWrongUserType count OrgUser who have wrong type

func CreateHookTask

func CreateHookTask(t *HookTask) error

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

func CreateIssueDependency added in v1.6.0

func CreateIssueDependency(user *User, issue, dep *Issue) error

CreateIssueDependency creates a new dependency for an issue

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, args ...interface{}) 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(issueID, commentID, notificationAuthorID, receiverID int64) error

CreateOrUpdateIssueNotifications creates an issue notification for each watcher, or updates it if already exists receiverID > 0 just send to reciver, else send to all watcher

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 CreatePendingRepositoryTransfer added in v1.14.0

func CreatePendingRepositoryTransfer(doer, newOwner *User, repoID int64, teams []*Team) error

CreatePendingRepositoryTransfer transfer a repo from one owner to a new one. it marks the repository transfer as "pending"

func CreateRefComment

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

CreateRefComment creates a commit reference comment to issue.

func CreateRepoTransferNotification added in v1.14.0

func CreateRepoTransferNotification(doer, newOwner *User, repo *Repository) error

CreateRepoTransferNotification creates notification for the user a repository was transferred to

func CreateRepository

func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, overwriteOrAdopt bool) (err error)

CreateRepository creates a repository for the user/organization.

func CreateRepositoryNotice

func CreateRepositoryNotice(desc string, args ...interface{}) error

CreateRepositoryNotice creates new system notice with type NoticeRepository.

func CreateTask added in v1.12.0

func CreateTask(task *Task) error

CreateTask creates a task on database

func CreateTemporaryPath added in v1.9.0

func CreateTemporaryPath(prefix string) (string, error)

CreateTemporaryPath creates a temporary path

func CreateTestEngine added in v1.2.0

func CreateTestEngine(fixturesDir string) error

CreateTestEngine creates a memory database and loads the fixture data from fixturesDir

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 DefaultAvatarLink() string

DefaultAvatarLink the default avatar link

func DeleteAccessTokenByID

func DeleteAccessTokenByID(id, userID int64) error

DeleteAccessTokenByID deletes access token by given ID.

func DeleteAllRecords added in v1.11.0

func DeleteAllRecords(tableName string) error

DeleteAllRecords will delete all the records of this table

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 DeleteAttachmentsByRelease added in v1.10.0

func DeleteAttachmentsByRelease(releaseID int64) error

DeleteAttachmentsByRelease deletes all attachments associated with the given release.

func DeleteComment added in v1.1.0

func DeleteComment(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 DeleteDefaultSystemWebhook added in v1.12.0

func DeleteDefaultSystemWebhook(id int64) error

DeleteDefaultSystemWebhook deletes an admin-configured default or system webhook (where Org and Repo ID both 0)

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 DeleteInactiveUsers added in v1.12.0

func DeleteInactiveUsers(ctx context.Context, olderThan time.Duration) (err error)

DeleteInactiveUsers deletes all inactive 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 DeleteIssueUserTimes added in v1.11.0

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

DeleteIssueUserTimes deletes times for issue

func DeleteLabel

func DeleteLabel(id, labelID int64) error

DeleteLabel delete a label

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 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 DeleteOAuth2Application added in v1.8.0

func DeleteOAuth2Application(id, userid int64) error

DeleteOAuth2Application deletes the application with the given id and the grants and auth codes related to it. It checks if the userid was the creator of the app.

func DeleteOldRepositoryArchives added in v1.1.0

func DeleteOldRepositoryArchives(ctx context.Context, olderThan time.Duration) error

DeleteOldRepositoryArchives deletes old repository archives.

func DeleteOrganization

func DeleteOrganization(org *User) (err error)

DeleteOrganization completely and permanently deletes everything of organization.

func DeleteOrphanedIssueLabels added in v1.13.5

func DeleteOrphanedIssueLabels() error

DeleteOrphanedIssueLabels delete IssueLabels witch have no label behind anymore

func DeleteOrphanedIssues added in v1.12.0

func DeleteOrphanedIssues() error

DeleteOrphanedIssues delete issues without a repo

func DeleteOrphanedLabels added in v1.12.0

func DeleteOrphanedLabels() error

DeleteOrphanedLabels delete labels witch are broken and not accessible via ui anymore

func DeleteOrphanedObjects added in v1.11.7

func DeleteOrphanedObjects(subject, refobject, joinCond string) error

DeleteOrphanedObjects delete subjects with have no existing refobject anymore

func DeleteProjectBoardByID added in v1.13.0

func DeleteProjectBoardByID(boardID int64) error

DeleteProjectBoardByID removes all issues references to the project board.

func DeleteProjectByID added in v1.13.0

func DeleteProjectByID(id int64) error

DeleteProjectByID deletes a project from a repository.

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

DeleteReleaseByID deletes a release from database by given ID.

func DeleteRepository

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

DeleteRepository deletes a repository for a user or organization. make sure if you call this func to close open sessions (sqlite will otherwise get a deadlock)

func DeleteRepositoryArchives

func DeleteRepositoryArchives(ctx context.Context) error

DeleteRepositoryArchives deletes all repositories' archives.

func DeleteReview added in v1.12.0

func DeleteReview(r *Review) error

DeleteReview delete a review and it's code comments

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 DeleteTime added in v1.11.0

func DeleteTime(t *TrackedTime) error

DeleteTime delete a specific Time

func DeleteTwoFactorByID added in v1.1.0

func DeleteTwoFactorByID(id, userID int64) error

DeleteTwoFactorByID deletes two-factor authentication token by given ID.

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, unless the user is younger than USER_DELETE_WITH_COMMENTS_MAX_DAYS.

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 DestroySession added in v1.14.0

func DestroySession(key string) error

DestroySession destroys a session

func DismissReview added in v1.14.0

func DismissReview(review *Review, isDismiss bool) (err error)

DismissReview change the dismiss status of a review

func DoctorUserStarNum added in v1.12.2

func DoctorUserStarNum() (err error)

DoctorUserStarNum recalculate Stars number for all user

func DumpDatabase

func DumpDatabase(filePath, dbType string) error

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

func ErrCancelledf added in v1.12.0

func ErrCancelledf(format string, args ...interface{}) error

ErrCancelledf returns an ErrCancelled for the provided format and args

func ExistSession added in v1.14.0

func ExistSession(key string) (bool, error)

ExistSession checks if a session exists

func FilterOutRepoIdsWithoutUnitAccess added in v1.11.0

func FilterOutRepoIdsWithoutUnitAccess(u *User, repoIDs []int64, units ...UnitType) ([]int64, error)

FilterOutRepoIdsWithoutUnitAccess filter out repos where user has no access to repositories

func FindByMaxID added in v1.11.0

func FindByMaxID(maxID int64, limit int, results interface{}) error

FindByMaxID filled results as the condition from database

func FindRepoRecentCommitStatusContexts added in v1.10.0

func FindRepoRecentCommitStatusContexts(repoID int64, before time.Duration) ([]string, error)

FindRepoRecentCommitStatusContexts returns repository's recent commit status contexts

func FindUserAccessibleRepoIDs added in v1.5.0

func FindUserAccessibleRepoIDs(user *User) ([]int64, error)

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

func FinishMigrateTask added in v1.10.0

func FinishMigrateTask(task *Task) error

FinishMigrateTask updates database when migrate task finished

func FixBadSequences added in v1.13.5

func FixBadSequences() error

FixBadSequences fixes for broken sequences from recreate-table mistakes

func FixCommentTypeLabelWithEmptyLabel added in v1.14.0

func FixCommentTypeLabelWithEmptyLabel() (int64, error)

FixCommentTypeLabelWithEmptyLabel count label comments with empty label

func FixCommentTypeLabelWithOutsideLabels added in v1.14.0

func FixCommentTypeLabelWithOutsideLabels() (int64, error)

FixCommentTypeLabelWithOutsideLabels count label comments with outside label

func FixIssueLabelWithOutsideLabels added in v1.14.0

func FixIssueLabelWithOutsideLabels() (int64, error)

FixIssueLabelWithOutsideLabels fix label comments with outside label

func FixNullArchivedRepository added in v1.12.0

func FixNullArchivedRepository() (int64, error)

FixNullArchivedRepository sets is_archived to false where it is null

func FixWrongUserType added in v1.14.0

func FixWrongUserType() (int64, error)

FixWrongUserType fix OrgUser who have wrong type

func FollowUser

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

FollowUser marks someone be another's follower.

func FullPushingEnvironment added in v1.9.0

func FullPushingEnvironment(author, committer *User, repo *Repository, repoName string, prID int64) []string

FullPushingEnvironment returns an os environment to allow hooks to work on push

func GPGKeyToEntity added in v1.9.0

func GPGKeyToEntity(k *GPGKey) (*openpgp.Entity, error)

GPGKeyToEntity retrieve the imported key and the traducted entity

func GenerateAvatar added in v1.11.0

func GenerateAvatar(ctx DBContext, templateRepo, generateRepo *Repository) error

GenerateAvatar generates the avatar from a template repository

func GenerateGitHooks added in v1.11.0

func GenerateGitHooks(ctx DBContext, templateRepo, generateRepo *Repository) error

GenerateGitHooks generates git hooks from a template repository

func GenerateIssueLabels added in v1.11.0

func GenerateIssueLabels(ctx DBContext, templateRepo, generateRepo *Repository) error

GenerateIssueLabels generates issue labels from a template repository

func GenerateLFSOid added in v1.8.0

func GenerateLFSOid(content io.Reader) (string, error)

GenerateLFSOid generates a Sha256Sum to represent an oid for arbitrary content

func GenerateTopics added in v1.11.0

func GenerateTopics(ctx DBContext, templateRepo, generateRepo *Repository) error

GenerateTopics generates topics from a template repository

func GenerateWebhooks added in v1.11.0

func GenerateWebhooks(ctx DBContext, templateRepo, generateRepo *Repository) error

GenerateWebhooks generates webhooks from a template repository

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 GetAssigneeIDsByIssue added in v1.11.0

func GetAssigneeIDsByIssue(issueID int64) ([]int64, error)

GetAssigneeIDsByIssue returns the IDs of users assigned to an issue but skips joining with `user` for performance reasons. User permissions must be verified elsewhere if required.

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 GetEmailForHash added in v1.12.0

func GetEmailForHash(md5Sum string) (string, error)

GetEmailForHash converts a provided md5sum to the email

func GetExternalLogin added in v1.1.0

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

GetExternalLogin checks if a externalID in loginSourceID scope already exists

func GetIssueIDsByRepoID added in v1.8.0

func GetIssueIDsByRepoID(repoID int64) ([]int64, error)

GetIssueIDsByRepoID returns all issue ids by repo id

func GetIssueWatchersIDs added in v1.11.0

func GetIssueWatchersIDs(issueID int64, watching bool) ([]int64, error)

GetIssueWatchersIDs returns IDs of subscribers or explicit unsubscribers to a given issue id but avoids joining with `user` for performance reasons User permissions must be verified elsewhere if required

func GetLabelIDsInOrgByNames added in v1.12.0

func GetLabelIDsInOrgByNames(orgID int64, labelNames []string) ([]int64, error)

GetLabelIDsInOrgByNames returns a list of labelIDs by names in a given organization.

func GetLabelIDsInOrgsByNames added in v1.12.0

func GetLabelIDsInOrgsByNames(orgIDs []int64, labelNames []string) ([]int64, error)

GetLabelIDsInOrgsByNames returns a list of labelIDs by names in one of the given organization. it silently ignores label names that do not belong to the organization.

func GetLabelIDsInRepoByNames added in v1.8.0

func GetLabelIDsInRepoByNames(repoID int64, labelNames []string) ([]int64, error)

GetLabelIDsInRepoByNames returns a list of labelIDs by names in a given repository. it silently ignores label names that do not belong to the repository.

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 GetMaxID added in v1.11.0

func GetMaxID(beanOrTableName interface{}) (maxID int64, err error)

GetMaxID will return max id of the table

func GetNotificationCount added in v1.1.0

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

GetNotificationCount returns the notification count for user

func GetParticipantsIDsByIssueID added in v1.11.0

func GetParticipantsIDsByIssueID(issueID int64) ([]int64, error)

GetParticipantsIDsByIssueID returns the IDs of all users who participated in comments of an issue, but skips joining with `user` for performance reasons. User permissions must be verified elsewhere if required.

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 GetPullRequestIDsByCheckStatus added in v1.11.0

func GetPullRequestIDsByCheckStatus(status PullRequestStatus) ([]int64, error)

GetPullRequestIDsByCheckStatus returns all pull requests according the special checking status.

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 GetRepoIDsForIssuesOptions added in v1.12.0

func GetRepoIDsForIssuesOptions(opts *IssuesOptions, user *User) ([]int64, error)

GetRepoIDsForIssuesOptions find all repo ids for the given options

func GetRepoInitFile added in v1.12.0

func GetRepoInitFile(tp, name string) ([]byte, error)

GetRepoInitFile returns repository init files

func GetRepoIssueStats

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

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

func GetRepoWatchersIDs added in v1.11.0

func GetRepoWatchersIDs(repoID int64) ([]int64, error)

GetRepoWatchersIDs returns IDs of watchers for a given repo ID but avoids joining with `user` for performance reasons User permissions must be verified elsewhere if required

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 GetTeamIDsByNames added in v1.12.0

func GetTeamIDsByNames(orgID int64, names []string, ignoreNonExistent bool) ([]int64, error)

GetTeamIDsByNames returns a slice of team ids corresponds to names.

func GetTeamNamesByID added in v1.12.0

func GetTeamNamesByID(teamIDs []int64) ([]string, error)

GetTeamNamesByID returns team's lower name from a list of team ids.

func GetTrackedSeconds added in v1.11.0

func GetTrackedSeconds(opts FindTrackedTimesOptions) (int64, error)

GetTrackedSeconds return sum of seconds

func GetUnindexedRepos added in v1.11.0

func GetUnindexedRepos(indexerType RepoIndexerType, maxRepoID int64, page, pageSize int) ([]int64, error)

GetUnindexedRepos returns repos which do not have an indexer status

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 of users that have their email notifications set to enabled or onmention.

func GetUserIDByExternalUserID added in v1.10.0

func GetUserIDByExternalUserID(provider, userID string) (int64, error)

GetUserIDByExternalUserID get user id according to provider and userID

func GetUserIDsByNames

func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error)

GetUserIDsByNames returns a slice of ids corresponds to names.

func GetUserNamesByIDs added in v1.12.0

func GetUserNamesByIDs(ids []int64) ([]string, error)

GetUserNamesByIDs returns usernames for all resolved users from a list of Ids.

func GetUserSalt

func GetUserSalt() (string, error)

GetUserSalt returns a random user salt token.

func GetYamlFixturesAccess added in v1.12.0

func GetYamlFixturesAccess() (string, error)

GetYamlFixturesAccess returns a string containing the contents for the access table, as recalculated using repo.RecalculateAccesses()

func GitConfigPath added in v1.3.1

func GitConfigPath(repoPath string) string

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

func HasAccess

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

HasAccess returns true if user has access to repo

func HasAccessUnit added in v1.7.0

func HasAccessUnit(user *User, repo *Repository, unitType UnitType, testMode AccessMode) (bool, error)

HasAccessUnit returns ture if user has testMode to the unit of the repository

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 HasOrgVisible added in v1.8.0

func HasOrgVisible(org, user *User) bool

HasOrgVisible tells if the given user can see the given org

func HasOrgsVisible added in v1.8.0

func HasOrgsVisible(orgs []*User, user *User) bool

HasOrgsVisible tells if the given user can see at least one of the orgs provided

func HasTeamRepo

func HasTeamRepo(orgID, teamID, repoID int64) bool

HasTeamRepo returns true if given repository belongs to team.

func HashEmail added in v1.14.0

func HashEmail(email string) string

HashEmail hashes email address to MD5 string. https://en.gravatar.com/site/implement/hash/

func HashedAvatarLink(email string) string

HashedAvatarLink returns an avatar link for a provided email

func IncrementRepoForkNum added in v1.12.0

func IncrementRepoForkNum(ctx DBContext, repoID int64) error

IncrementRepoForkNum increment repository fork number

func InitFixtures added in v1.2.0

func InitFixtures(dir string) (err error)

InitFixtures initialize test fixtures for a test database

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 InitializeLabels added in v1.12.0

func InitializeLabels(ctx DBContext, repoID int64, labelTemplate string, isOrg bool) error

InitializeLabels adds a label set to a repository using a template

func InsertIssueComments added in v1.9.0

func InsertIssueComments(comments []*Comment) error

InsertIssueComments inserts many comments of issues.

func InsertIssues added in v1.9.0

func InsertIssues(issues ...*Issue) error

InsertIssues insert issues to database

func InsertMilestones added in v1.9.0

func InsertMilestones(ms ...*Milestone) (err error)

InsertMilestones creates milestones of repository.

func InsertMirror added in v1.11.0

func InsertMirror(mirror *Mirror) error

InsertMirror inserts a mirror to database

func InsertPullRequests added in v1.9.0

func InsertPullRequests(prs ...*PullRequest) error

InsertPullRequests inserted pull requests

func InsertRelease added in v1.10.0

func InsertRelease(rel *Release) error

InsertRelease inserts a release

func InsertReleases added in v1.9.0

func InsertReleases(rels ...*Release) error

InsertReleases migrates release

func InsertReleasesContext added in v1.12.0

func InsertReleasesContext(ctx DBContext, rels []*Release) error

InsertReleasesContext insert releases

func InsertReviews added in v1.12.0

func InsertReviews(reviews []*Review) error

InsertReviews inserts review and review comments

func InternalPushingEnvironment added in v1.11.0

func InternalPushingEnvironment(doer *User, repo *Repository) []string

InternalPushingEnvironment returns an os environment to switch off hooks on push It is recommended to avoid using this unless you are pushing within a transaction or if you absolutely are sure that post-receive and pre-receive will do nothing We provide the full pushing-environment for other hook providers

func IsContentEmptyErr added in v1.11.0

func IsContentEmptyErr(err error) bool

IsContentEmptyErr returns true if err is a ContentEmptyErr

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 IsErrBranchDoesNotExist added in v1.13.0

func IsErrBranchDoesNotExist(err error) bool

IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.

func IsErrBranchNameConflict added in v1.3.0

func IsErrBranchNameConflict(err error) bool

IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.

func IsErrBranchesEqual added in v1.11.0

func IsErrBranchesEqual(err error) bool

IsErrBranchesEqual checks if an error is an ErrBranchesEqual.

func IsErrCancelled added in v1.12.0

func IsErrCancelled(err error) bool

IsErrCancelled checks if an error is a ErrCancelled.

func IsErrCircularDependency added in v1.6.0

func IsErrCircularDependency(err error) bool

IsErrCircularDependency checks if an error is a ErrCircularDependency.

func IsErrCommentNotExist

func IsErrCommentNotExist(err error) bool

IsErrCommentNotExist checks if an error is a ErrCommentNotExist.

func IsErrCommitIDDoesNotMatch added in v1.9.0

func IsErrCommitIDDoesNotMatch(err error) bool

IsErrCommitIDDoesNotMatch checks if an error is a ErrCommitIDDoesNotMatch.

func IsErrDependenciesLeft added in v1.6.0

func IsErrDependenciesLeft(err error) bool

IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.

func IsErrDependencyExists added in v1.6.0

func IsErrDependencyExists(err error) bool

IsErrDependencyExists checks if an error is a ErrDependencyExists.

func IsErrDependencyNotExists added in v1.6.0

func IsErrDependencyNotExists(err error) bool

IsErrDependencyNotExists checks if an error is a ErrDependencyExists.

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 IsErrEmailInvalid added in v1.13.0

func IsErrEmailInvalid(err error) bool

IsErrEmailInvalid checks if an error is an ErrEmailInvalid

func IsErrErrPullRequestHeadRepoMissing added in v1.9.0

func IsErrErrPullRequestHeadRepoMissing(err error) bool

IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.

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 IsErrFilePathInvalid added in v1.9.0

func IsErrFilePathInvalid(err error) bool

IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.

func IsErrFilePathProtected added in v1.12.0

func IsErrFilePathProtected(err error) bool

IsErrFilePathProtected checks if an error is an ErrFilePathProtected.

func IsErrFilenameInvalid added in v1.9.0

func IsErrFilenameInvalid(err error) bool

IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.

func IsErrForbiddenIssueReaction added in v1.11.0

func IsErrForbiddenIssueReaction(err error) bool

IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.

func IsErrForkAlreadyExist added in v1.9.0

func IsErrForkAlreadyExist(err error) bool

IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.

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 IsErrGPGKeyImportNotExist added in v1.9.0

func IsErrGPGKeyImportNotExist(err error) bool

IsErrGPGKeyImportNotExist checks if an error is a ErrGPGKeyImportNotExist.

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 IsErrIssueIsClosed added in v1.11.0

func IsErrIssueIsClosed(err error) bool

IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.

func IsErrIssueLabelTemplateLoad added in v1.10.0

func IsErrIssueLabelTemplateLoad(err error) bool

IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.

func IsErrIssueNotExist

func IsErrIssueNotExist(err error) bool

IsErrIssueNotExist checks if an error is a ErrIssueNotExist.

func IsErrIssueWasClosed added in v1.11.0

func IsErrIssueWasClosed(err error) bool

IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.

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 IsErrLFSFileLocked added in v1.11.0

func IsErrLFSFileLocked(err error) bool

IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.

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 IsErrMergeConflicts added in v1.11.0

func IsErrMergeConflicts(err error) bool

IsErrMergeConflicts checks if an error is a ErrMergeConflicts.

func IsErrMergeUnrelatedHistories added in v1.11.0

func IsErrMergeUnrelatedHistories(err error) bool

IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.

func IsErrMilestoneNotExist

func IsErrMilestoneNotExist(err error) bool

IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.

func IsErrNameCharsNotAllowed added in v1.11.2

func IsErrNameCharsNotAllowed(err error) bool

IsErrNameCharsNotAllowed checks if an error is an ErrNameCharsNotAllowed.

func IsErrNamePatternNotAllowed

func IsErrNamePatternNotAllowed(err