models

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 99 Imported by: 1,618

Documentation

Index

Constants

View Source
const (
	// ProtectedBranchRepoID protected Repo ID
	ProtectedBranchRepoID = "GITEA_REPO_ID"
	// ProtectedBranchPRID protected Repo PR ID
	ProtectedBranchPRID = "GITEA_PR_ID"
)
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 (
	// 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"
	EnvPusherEmail  = "GITEA_PUSHER_EMAIL"
	EnvPusherID     = "GITEA_PUSHER_ID"
)

env keys for git hooks need

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 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
	LabelTemplates []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,
	}

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

	// MustRepoUnits contains the units could not be disabled currently
	MustRepoUnits = []UnitType{
		UnitTypeCode,
		UnitTypeReleases,
	}
)
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 (

	// HasEngine specifies if we have a xorm.Engine
	HasEngine bool
)
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 OAuth2DefaultCustomURLMappings = map[string]*oauth2.CustomURLMapping{
	"github": OAuth2Providers["github"].CustomURLMapping,
	"gitlab": OAuth2Providers["gitlab"].CustomURLMapping,
	"gitea":  OAuth2Providers["gitea"].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.png"},
	"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"),
		},
	},
}

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

CheckCreateRepository check if could created a repository

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

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

func CreateRepositoryNotice(desc string) error

CreateRepositoryNotice creates new system notice with type NoticeRepository.

func CreateTemporaryPath added in v1.9.0

func CreateTemporaryPath(prefix string) (string, error)

CreateTemporaryPath creates a temporary path

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 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, doer *User) 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 DeleteDefaultWebhook added in v1.9.0

func DeleteDefaultWebhook(id int64) error

DeleteDefaultWebhook deletes an admin-default webhook by given ID.

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

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

DeleteReleaseByID deletes a release from database by given ID.

func DeleteRepoFromIndexer added in v1.3.0

func DeleteRepoFromIndexer(repo *Repository, watchers ...chan<- error)

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 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 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(userID int64) ([]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 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 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 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 GetIssueIDsByRepoID added in v1.8.0

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

GetIssueIDsByRepoID returns all issue ids by repo id

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

func GetUserIDByExternalUserID added in v1.10.0

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

GetUserIDByExternalUserID get user id according to provider and userID

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) (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 *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 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 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 InitTestPullRequests

func InitTestPullRequests()

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

func InitalizeLabels added in v1.10.0

func InitalizeLabels(repoID int64, labelTemplate string) error

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

func IsErrFilenameInvalid(err error) bool

IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.

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

func IsErrNewIssueInsert(err error) bool

IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.

func IsErrNotAllowedToMerge added in v1.5.0

func IsErrNotAllowedToMerge(err error) bool

IsErrNotAllowedToMerge checks if an error is an ErrNotAllowedToMerge.

func IsErrNotExist added in v1.10.0

func IsErrNotExist(err error) bool

IsErrNotExist checks if an error is an ErrNotExist

func IsErrOAuthApplicationNotFound added in v1.8.0

func IsErrOAuthApplicationNotFound(err error) bool

IsErrOAuthApplicationNotFound checks if an error is a ErrReviewNotExist.

func IsErrOauthClientIDInvalid added in v1.8.0

func IsErrOauthClientIDInvalid(err error) bool

IsErrOauthClientIDInvalid checks if an error is a ErrReviewNotExist.

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

func IsErrRepoFileAlreadyExists(err error) bool

IsErrRepoFileAlreadyExists checks if an error is a ErrRepoFileAlreadyExists.

func IsErrRepoFileDoesNotExist added in v1.9.0

func IsErrRepoFileDoesNotExist(err error) bool

IsErrRepoFileDoesNotExist checks if an error is a ErrRepoDoesNotExist.

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 IsErrReviewNotExist added in v1.6.0

func IsErrReviewNotExist(err error) bool

IsErrReviewNotExist checks if an error is a ErrReviewNotExist.

func IsErrSHADoesNotMatch added in v1.9.0

func IsErrSHADoesNotMatch(err error) bool

IsErrSHADoesNotMatch checks if an error is a ErrSHADoesNotMatch.

func IsErrSHANotFound added in v1.9.0

func IsErrSHANotFound(err error) bool

IsErrSHANotFound checks if an error is a ErrSHANotFound.

func IsErrSHAOrCommitIDNotProvided added in v1.9.0

func IsErrSHAOrCommitIDNotProvided(err error) bool

IsErrSHAOrCommitIDNotProvided checks if an error is a ErrSHAOrCommitIDNotProvided.

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

func IsErrTaskDoesNotExist(err error) bool

IsErrTaskDoesNotExist checks if an error is a ErrTaskIsNotExist.

func IsErrTeamAlreadyExist

func IsErrTeamAlreadyExist(err error) bool

IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.

func IsErrTeamNotExist added in v1.10.0

func IsErrTeamNotExist(err error) bool

IsErrTeamNotExist checks if an error is a ErrTeamNotExist.

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

func IsErrUnitTypeNotExist(err error) bool

IsErrUnitTypeNotExist checks if an error is a ErrUnitNotExist.

func IsErrUnknownDependencyType added in v1.6.0

func IsErrUnknownDependencyType(err error) bool

IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType

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

func IsErrUserCannotCommit(err error) bool

IsErrUserCannotCommit checks if an error is an ErrUserCannotCommit.

func IsErrUserDoesNotHaveAccessToRepo added in v1.5.0

func IsErrUserDoesNotHaveAccessToRepo(err error) bool

IsErrUserDoesNotHaveAccessToRepo checks if an error is a ErrRepoFileAlreadyExists.

func IsErrUserHasOrgs

func IsErrUserHasOrgs(err error) bool

IsErrUserHasOrgs checks if an error is a ErrUserHasOrgs.

func IsErrUserInactive added in v1.7.3

func IsErrUserInactive(err error) bool

IsErrUserInactive checks if an error is a ErrUserInactive

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 IsErrUserProhibitLogin added in v1.7.3

func IsErrUserProhibitLogin(err error) bool

IsErrUserProhibitLogin checks if an error is a ErrUserProhibitLogin

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 IsUserRepoAdmin added in v1.7.0

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

IsUserRepoAdmin return ture if user has admin right of a repo

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 IssueNoDependenciesLeft added in v1.6.0

func IssueNoDependenciesLeft(issue *Issue) (bool, error)

IssueNoDependenciesLeft checks if issue can be closed

func LinkExternalToUser added in v1.10.0

func LinkExternalToUser(user *User, externalLoginUser *ExternalLoginUser) error

LinkExternalToUser link the external user to the user

func LoadFixtures added in v1.2.0

func LoadFixtures() error

LoadFixtures load fixtures for a test database

func LocalCopyPath added in v1.4.0

func LocalCopyPath() string

LocalCopyPath returns the local repository temporary copy path.

func LockIssue added in v1.8.0

func LockIssue(opts *IssueLockOptions) error

LockIssue locks an issue. This would limit commenting abilities to users with write access to the repo

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

func MaxBatchInsertSize(bean interface{}) int

MaxBatchInsertSize returns the table's max batch insert size

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 MirrorSyncCreateAction added in v1.6.0

func MirrorSyncCreateAction(repo *Repository, refName string) error

MirrorSyncCreateAction adds new action for mirror synchronization of new reference.

func MirrorSyncDeleteAction added in v1.6.0

func MirrorSyncDeleteAction(repo *Repository, refName string) error

MirrorSyncDeleteAction adds new action for mirror synchronization of delete reference.

func MirrorSyncPushAction added in v1.6.0

func MirrorSyncPushAction(repo *Repository, opts MirrorSyncPushActionOptions) error

MirrorSyncPushAction adds new action for mirror synchronization of pushed commits.

func MirrorsIterate added in v1.10.0

func MirrorsIterate(f func(idx int, bean interface{}) error) error

MirrorsIterate iterates all mirror repositories.

func NewAccessToken

func NewAccessToken(t *AccessToken) error

NewAccessToken creates new access token.

func NewCommitStatus added in v1.2.0

func NewCommitStatus(opts NewCommitStatusOptions) error

NewCommitStatus save commit statuses into database

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

func NewXORMLogger(showSQL bool) core.ILogger

NewXORMLogger inits a log bridge for xorm

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

func PushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string) error

PushUpdateAddTag must be called for any push actions to add tag

func PushUpdateDeleteTag added in v1.10.0

func PushUpdateDeleteTag(repo *Repository, tagName string) error

PushUpdateDeleteTag must be called for any push actions to delete tag

func PushingEnvironment added in v1.9.0

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

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

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 RemoveIssueDependency added in v1.6.0

func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType DependencyType) (err error)

RemoveIssueDependency removes a dependency from an issue

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

func RemoveRandomAvatars() error

RemoveRandomAvatars removes the randomly generated avatars that were created for repositories

func RemoveTeamMember

func RemoveTeamMember(team *Team, userID int64) error

RemoveTeamMember removes member from given team of given organization.

func RemoveTemporaryPath added in v1.9.0

func RemoveTemporaryPath(basePath string) error

RemoveTemporaryPath removes the temporary path

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

func RevokeOAuth2Grant(grantID, userID int64) error

RevokeOAuth2Grant deletes the grant with grantID and userID

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

func SanitizeAndValidateTopics(topics []string) (validTopics []string, invalidTopics []string)

SanitizeAndValidateTopics sanitizes and checks an array or topics

func SaveTopics added in v1.5.0

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

SaveTopics save topics to a repository

func SearchIssueIDsByKeyword added in v1.8.0

func SearchIssueIDsByKeyword(kw string, repoID int64, limit, start int) (int64, []int64, error)

SearchIssueIDsByKeyword search issues on database

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

func TxDBContext() (DBContext, Committer, error)

TxDBContext represents a transaction DBContext

func UnfollowUser

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

UnfollowUser unmarks someone as another's follower.

func UnlockIssue added in v1.8.0

func UnlockIssue(opts *IssueLockOptions) error

UnlockIssue unlocks a previously locked issue.

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(c *Comment, doer *User) error

UpdateComment updates information of comment.

func UpdateCommentsMigrationsByType added in v1.10.0

func UpdateCommentsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error

UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id

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

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

UpdateExternalUser updates external user's information

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 UpdateIssueDeadline added in v1.5.0

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

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

func UpdateIssueMentions

func UpdateIssueMentions(ctx DBContext, issueID int64, mentions []*User) error

UpdateIssueMentions updates issue-user relations for mentioned users.

func UpdateIssueUserByRead

func UpdateIssueUserByRead(uid, issueID int64) error

UpdateIssueUserByRead updates issue-user relation for reading.

func UpdateIssueUsersByMentions

func UpdateIssueUsersByMentions(ctx DBContext, issueID int64, uids []int64) error

UpdateIssueUsersByMentions updates issue-user pairs by mentioning.

func UpdateIssuesCommit

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

UpdateIssuesCommit checks if issues are manipulated by commit message.

func UpdateIssuesMigrationsByType added in v1.10.0

func UpdateIssuesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error

UpdateIssuesMigrationsByType updates all migrated repositories' issues from gitServiceType to replace originalAuthorID to posterID

func UpdateLabel

func UpdateLabel(l *Label) error

UpdateLabel updates label information.

func UpdateMigrationsByType added in v1.10.0

func UpdateMigrationsByType(tp structs.GitServiceType, externalUserID string, userID int64) error

UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID

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

func UpdateOAuth2Application(opts UpdateOAuth2ApplicationOptions) error

UpdateOAuth2Application updates an oauth2 application

func UpdateProtectBranch added in v1.3.0

func UpdateProtectBranch(repo *Repository, protectBranch *ProtectedBranch, opts WhitelistOptions) (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(rel *Release) error

UpdateRelease updates all columns of a release

func UpdateReleasesMigrationsByType added in v1.10.0

func UpdateReleasesMigrationsByType(gitServiceType structs.GitServiceType, originalAuthorID string, posterID int64) error

UpdateReleasesMigrationsByType updates all migrated repositories' releases from gitServiceType to replace originalAuthorID to posterID

func UpdateRepoIndexer added in v1.3.0

func UpdateRepoIndexer(repo *Repository, watchers ...chan<- error)

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

func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error

UpdateRepositoryUpdatedTime updates a repository's updated time

func UpdateReview added in v1.6.0

func UpdateReview(r *Review) error

UpdateReview will update all cols of the given review in db

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 UsersInTeamsCount added in v1.7.0

func UsersInTeamsCount(userIDs []int64, teamIDs []int64) (int64, error)

UsersInTeamsCount counts the number of users which are in userIDs and teamIDs

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 a topic 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.

func WithContext added in v1.10.0

func WithContext(f func(ctx DBContext) error) error

WithContext represents executing database operations

func WithTx added in v1.10.0

func WithTx(f func(ctx DBContext) error) error

WithTx represents executing database operations on a trasaction

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(user *User, 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) ColorFormat added in v1.9.0

func (mode AccessMode) ColorFormat(s fmt.State)

ColorFormat provides a ColorFormatted version of this AccessMode

func (AccessMode) String

func (mode AccessMode) String() string

type AccessToken

type AccessToken struct {
	ID             int64 `xorm:"pk autoincr"`
	UID            int64 `xorm:"INDEX"`
	Name           string
	Token          string `xorm:"-"`
	TokenHash      string `xorm:"UNIQUE"` // sha256 of token
	TokenSalt      string
	TokenLastEight string `xorm:"token_last_eight"`

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

AccessToken represents a personal access token.

func GetAccessTokenBySHA

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

GetAccessTokenBySHA returns access token by given token value

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)
	AddKeyword(keyword string)
	SetSort(SearchOrderBy)
}

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 timeutil.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) GetActFullName added in v1.6.0

func (a *Action) GetActFullName() string

GetActFullName gets the action's user full name.

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

func (a *Action) GetDisplayName() string

GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME

func (*Action) GetDisplayNameTitle added in v1.9.0

func (a *Action) GetDisplayNameTitle() string

GetDisplayNameTitle gets the action's display name used for the title (tooltip) based on DEFAULT_SHOW_FULL_NAME

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
	ActionMirrorSyncPush                          // 18
	ActionMirrorSyncCreate                        // 19
	ActionMirrorSyncDelete                        // 20
)

Possible action types.

type ActivityAuthorData added in v1.9.0

type ActivityAuthorData struct {
	Name       string `json:"name"`
	Login      string `json:"login"`
	AvatarLink string `json:"avatar_link"`
	Commits    int64  `json:"commits"`
}

ActivityAuthorData represents statistical git commit count data

func GetActivityStatsTopAuthors added in v1.9.0

func GetActivityStatsTopAuthors(repo *Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error)

GetActivityStatsTopAuthors returns top author stats for git commits for all branches

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
	Code                        *git.CodeActivityStats
}

ActivityStats represets issue and pull request information.

func GetActivityStats added in v1.3.0

func GetActivityStats(repo *Repository, timeFrom time.Time, releases, issues, prs, code 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