models

package
Version: v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 97 Imported by: 1,473

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 (
	SMTPPlain = "PLAIN"
	SMTPLogin = "LOGIN"
)

SMTP authentication type names.

View Source
const (
	RepoArchiverGenerating = iota // the archiver is generating
	RepoArchiverReady             // it's ready
)

enumerate all repo archive statuses

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

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 (
	// ErrResouceOutdated represents an error when request resource outdated
	ErrResouceOutdated = errors.New("resource outdated")
	// ErrGetResourceIndexFailed represents an error when resource index retries 3 times
	ErrGetResourceIndexFailed = errors.New("get resource index failed")
)
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 (
	// 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 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 (
	// ErrPushMirrorNotExist mirror does not exist error
	ErrPushMirrorNotExist = errors.New("PushMirror does not exist")
)
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: "/assets/img/auth/bitbucket.png"},
	"dropbox":   {Name: "dropbox", DisplayName: "Dropbox", Image: "/assets/img/auth/dropbox.png"},
	"facebook":  {Name: "facebook", DisplayName: "Facebook", Image: "/assets/img/auth/facebook.png"},
	"github": {
		Name: "github", DisplayName: "GitHub", Image: "/assets/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: "/assets/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: "/assets/img/auth/google.png"},
	"openidConnect": {Name: "openidConnect", DisplayName: "OpenID Connect", Image: "/assets/img/auth/openid_connect.svg"},
	"twitter":       {Name: "twitter", DisplayName: "Twitter", Image: "/assets/img/auth/twitter.png"},
	"discord":       {Name: "discord", DisplayName: "Discord", Image: "/assets/img/auth/discord.png"},
	"gitea": {
		Name: "gitea", DisplayName: "Gitea", Image: "/assets/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: "/assets/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: "/assets/img/auth/yandex.png"},
	"mastodon": {
		Name: "mastodon", DisplayName: "Mastodon", Image: "/assets/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, activate bool) (err error)

ActivateUserEmail will change the activated state of an email address, either primary or secondary (all 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(ctx DBContext, releaseID int64, attachmentUUIDs []string) (err error)

AddReleaseAttachments adds a release attachments

func AddRepoArchiver added in v1.15.0

func AddRepoArchiver(ctx DBContext, archiver *RepoArchiver) error

AddRepoArchiver adds an archiver

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 CountMilestonesByRepoCondAndKw added in v1.15.0

func CountMilestonesByRepoCondAndKw(repoCond builder.Cond, keyword string, isClosed bool) (map[int64]int64, error)

CountMilestonesByRepoCondAndKw map from repo conditions and the keyword of milestones' name 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 CountReleasesByRepoID added in v1.15.0

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

CountReleasesByRepoID returns a number of releases matching FindReleaseOptions and RepoID.

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, overwriteDefault ...*CreateUserOverwriteOptions) (err error)

CreateUser creates record of a new user.

func CreateWebhook

func CreateWebhook(w *Webhook) error

CreateWebhook creates a new web hook.

func DecrementRepoForkNum added in v1.15.3

func DecrementRepoForkNum(ctx DBContext, repoID int64) error

DecrementRepoForkNum decrement repository fork number

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