models

package
v1.16.9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 53 Imported by: 1,618

Documentation

Index

Constants

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" // public key ID
	EnvDeployKeyID  = "GITEA_DEPLOY_KEY_ID"
	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
	FilterModeYourRepositories
)

Filter modes.

View Source
const LuminanceThreshold float64 = 0.179

LuminanceThreshold is the luminance at which white and black appear to have the same contrast i.e. x such that 1.05 / (x + 0.05) = (x + 0.05) / 0.05 i.e. math.Sqrt(1.05*0.05) - 0.05

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 (
	// 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 BoardColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")

BoardColorPattern is a regexp witch can validate BoardColor

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 LabelColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")

LabelColorPattern is a regexp witch can validate LabelColor

Functions

func AccessLevel

func AccessLevel(user *user_model.User, repo *repo_model.Repository) (perm_model.AccessMode, error)

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

func AccessLevelUnit added in v1.11.0

func AccessLevelUnit(user *user_model.User, repo *repo_model.Repository, unitType unit.Type) (perm_model.AccessMode, error)

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

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_model.User) *builder.Builder

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

func AddCollaborator added in v1.16.0

func AddCollaborator(repo *repo_model.Repository, u *user_model.User) error

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

func AddDeletePRBranchComment added in v1.1.0

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

AddDeletePRBranchComment adds delete branch comment for pull request issue

func AddDeletedBranch added in v1.16.0

func AddDeletedBranch(repoID int64, branchName, commit string, deletedByID int64) error

AddDeletedBranch adds a deleted branch to the database

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

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

BuildLabelNamesIssueIDsCondition returns a builder where get issue ids match label names

func CanBeAssigned added in v1.11.0

func CanBeAssigned(user *user_model.User, repo *repo_model.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_model.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 CanUserDelete added in v1.16.0

func CanUserDelete(repo *repo_model.Repository, user *user_model.User) (bool, error)

CanUserDelete returns true if user could delete the repository

func CanUserForkRepo added in v1.16.0

func CanUserForkRepo(user *user_model.User, repo *repo_model.Repository) (bool, error)

CanUserForkRepo returns true if specified user can fork repository.

func CancelRepositoryTransfer added in v1.14.0

func CancelRepositoryTransfer(repo *repo_model.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_model.User, issue *Issue) error

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

func ChangeCollaborationAccessMode added in v1.16.0

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

ChangeCollaborationAccessMode sets new access mode for the collaboration.

func ChangeMilestoneAssign

func ChangeMilestoneAssign(issue *Issue, doer *user_model.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_model.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 CheckDaemonExportOK added in v1.16.0

func CheckDaemonExportOK(ctx context.Context, repo *repo_model.Repository) error

CheckDaemonExportOK creates/removes git-daemon-export-ok for git-daemon...

func CheckIssueWatch added in v1.12.0

func CheckIssueWatch(user *user_model.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(ownerID int64, repo *repo_model.Repository, mode perm.AccessMode) error

CheckLFSAccessForRepo check needed access mode base on action

func CheckRepoStats

func CheckRepoStats(ctx context.Context) error

CheckRepoStats checks the repository stats

func CheckRepoUnitUser added in v1.16.0

func CheckRepoUnitUser(repo *repo_model.Repository, user *user_model.User, unitType unit.Type) bool

CheckRepoUnitUser check whether user could visit the unit of this repository

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

func CopyLFS(ctx context.Context, newRepo, oldRepo *repo_model.Repository) error

CopyLFS copies LFS data from one repo to another

func CountAccessTokens added in v1.16.0

func CountAccessTokens(opts ListAccessTokensOptions) (int64, error)

CountAccessTokens count access tokens belongs to given user by options

func CountActionCreatedUnixString added in v1.16.8

func CountActionCreatedUnixString() (int64, error)

CountActionCreatedUnixString count actions where created_unix is an empty string

func CountCollaborators added in v1.16.0

func CountCollaborators(repoID int64) (int64, error)

CountCollaborators returns total number of collaborators for a repository

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 CountComments added in v1.16.0

func CountComments(opts *FindCommentsOptions) (int64, error)

CountComments count all comments according options by ignoring pagination

func CountIssueLabelWithOutsideLabels added in v1.14.0

func CountIssueLabelWithOutsideLabels() (int64, error)

CountIssueLabelWithOutsideLabels count label comments with outside label

func CountIssueWatchers added in v1.16.0

func CountIssueWatchers(issueID int64) (int64, error)

CountIssueWatchers count watchers/unwatchers of a given issue

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 CountLFSMetaObjects added in v1.16.0

func CountLFSMetaObjects(repoID int64) (int64, error)

CountLFSMetaObjects returns a count of all LFSMetaObjects associated with a repository

func CountLabelsByOrgID added in v1.16.0

func CountLabelsByOrgID(orgID int64) (int64, error)

CountLabelsByOrgID count all labels that belong to given organization by ID.

func CountLabelsByRepoID added in v1.16.0

func CountLabelsByRepoID(repoID int64) (int64, error)

CountLabelsByRepoID count number of all labels that belong to given repository by ID.

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 CountNotifications added in v1.16.0

func CountNotifications(opts *FindNotificationOptions) (int64, error)

CountNotifications count all notifications that fit to the given options and ignore pagination.

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 CountOrgs added in v1.16.0

func CountOrgs(opts FindOrgOptions) (int64, error)

CountOrgs returns total count organizations according options

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 CountReviews added in v1.16.0

func CountReviews(opts FindReviewOptions) (int64, error)

CountReviews returns count of reviews passing FindReviewOptions

func CountTrackedTimes added in v1.16.0

func CountTrackedTimes(opts *FindTrackedTimesOptions) (int64, error)

CountTrackedTimes returns count of tracked times that fit to the given options.

func CountUnread added in v1.12.0

func CountUnread(user *user_model.User) int64

CountUnread count unread notifications for a user

func CountUserStopwatches added in v1.16.0

func CountUserStopwatches(userID int64) (int64, error)

CountUserStopwatches return count of all stopwatches of a user

func CountWrongUserType added in v1.14.0

func CountWrongUserType() (int64, error)

CountWrongUserType count OrgUser who have wrong type

func CreateIssueDependency added in v1.6.0

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

CreateIssueDependency creates a new dependency for an issue

func CreateIssueStopwatch added in v1.15.7

func CreateIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error

CreateIssueStopwatch creates a stopwatch if not exist, otherwise return an error

func CreateOrStopIssueStopwatch added in v1.3.0

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

CreateOrStopIssueStopwatch create an issue stopwatch if it's not exist, otherwise finish it

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 receiver, 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 *Organization, owner *user_model.User) (err error)

CreateOrganization creates record of a new organization.

func CreatePendingRepositoryTransfer added in v1.14.0

func CreatePendingRepositoryTransfer(doer, newOwner *user_model.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_model.User, repo *repo_model.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_model.User, repo *repo_model.Repository) error

CreateRepoTransferNotification creates notification for the user a repository was transferred to

func CreateRepository

func CreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository, overwriteOrAdopt bool) (err error)

CreateRepository creates a repository for the user/organization.

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 DecrementRepoForkNum added in v1.15.3

func DecrementRepoForkNum(ctx context.Context, repoID int64) error

DecrementRepoForkNum decrement repository fork number

func DeleteAccessTokenByID

func DeleteAccessTokenByID(id, userID int64) error

DeleteAccessTokenByID deletes access token by given ID.

func DeleteCollaboration added in v1.16.0

func DeleteCollaboration(repo *repo_model.Repository, uid int64) (err error)

DeleteCollaboration removes collaboration relation between the user and repository.

func DeleteComment added in v1.1.0

func DeleteComment(comment *Comment) error

DeleteComment deletes the comment

func DeleteCommentReaction added in v1.4.0

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

DeleteCommentReaction deletes a reaction on comment.

func DeleteDeployKey

func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error

DeleteDeployKey delete deploy keys

func DeleteIssueLabel

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

DeleteIssueLabel deletes issue-label relation.

func DeleteIssueReaction added in v1.4.0

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

DeleteIssueReaction deletes a reaction on issue.

func DeleteIssueUserTimes added in v1.11.0

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

DeleteIssueUserTimes deletes times for issue

func DeleteLabel

func DeleteLabel(id, labelID int64) error

DeleteLabel delete a label

func DeleteMilestoneByRepoID

func DeleteMilestoneByRepoID(repoID, id int64) error

DeleteMilestoneByRepoID deletes a milestone from a repository.

func DeleteOldActions added in v1.15.0

func DeleteOldActions(olderThan time.Duration) (err error)

DeleteOldActions deletes all old actions from database.

func DeleteOrganization

func DeleteOrganization(ctx context.Context, org *Organization) error

DeleteOrganization deletes models associated to an organization.

func DeleteOrphanedIssueLabels added in v1.13.5

func DeleteOrphanedIssueLabels() error

DeleteOrphanedIssueLabels delete IssueLabels witch have no label behind anymore

func DeleteOrphanedIssues added in v1.12.0

func DeleteOrphanedIssues() error

DeleteOrphanedIssues delete issues without a repo

func DeleteOrphanedLabels added in v1.12.0

func DeleteOrphanedLabels() error

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

func DeleteOrphanedObjects added in v1.11.7

func DeleteOrphanedObjects(subject, refobject, joinCond string) error

DeleteOrphanedObjects delete subjects with have no existing refobject anymore

func DeleteProjectBoardByID added in v1.13.0

func DeleteProjectBoardByID(boardID int64) error

DeleteProjectBoardByID removes all issues references to the project board.

func DeleteProjectByID added in v1.13.0

func DeleteProjectByID(id int64) error

DeleteProjectByID deletes a project from a repository.

func DeleteProtectedBranch added in v1.16.0

func DeleteProtectedBranch(repoID, id int64) (err error)

DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.

func DeleteProtectedTag added in v1.15.0

func DeleteProtectedTag(pt *ProtectedTag) error

DeleteProtectedTag deletes a protected tag by ID

func DeleteReaction added in v1.4.0

func DeleteReaction(opts *ReactionOptions) error

DeleteReaction deletes reaction for issue or comment.

func DeleteReleaseByID

func DeleteReleaseByID(id int64) error

DeleteReleaseByID deletes a release from database by given ID.

func DeleteRepository

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

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

func DeleteReview added in v1.12.0

func DeleteReview(r *Review) error

DeleteReview delete a review and it's code comments

func DeleteTeam

func DeleteTeam(t *Team) error

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

func DeleteTime added in v1.11.0

func DeleteTime(t *TrackedTime) error

DeleteTime delete a specific Time

func 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(ctx context.Context, u *user_model.User) (err error)

DeleteUser deletes models associated to an user.

func DismissReview added in v1.14.0

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

DismissReview change the dismiss status of a review

func DoctorUserStarNum added in v1.12.2

func DoctorUserStarNum() (err error)

DoctorUserStarNum recalculate Stars number for all user

func FindOrgMembers added in v1.11.0

func FindOrgMembers(opts *FindOrgMembersOpts) (user_model.UserList, map[int64]bool, error)

FindOrgMembers loads organization members according conditions

func FindRepoRecentCommitStatusContexts added in v1.10.0

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

FindRepoRecentCommitStatusContexts returns repository's recent commit status contexts

func FindUserAccessibleRepoIDs added in v1.5.0

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

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

func FindUserOrgForks added in v1.16.0

func FindUserOrgForks(repoID, userID int64) ([]*repo_model.Repository, error)

FindUserOrgForks returns the forked repositories for one user from a repository

func FinishIssueStopwatch added in v1.15.7

func FinishIssueStopwatch(ctx context.Context, user *user_model.User, issue *Issue) error

FinishIssueStopwatch if stopwatch exist then finish it otherwise return an error

func FinishIssueStopwatchIfPossible added in v1.15.7

func FinishIssueStopwatchIfPossible(ctx context.Context, user *user_model.User, issue *Issue) error

FinishIssueStopwatchIfPossible if stopwatch exist then finish it otherwise ignore

func FinishMigrateTask added in v1.10.0

func FinishMigrateTask(task *Task) error

FinishMigrateTask updates database when migrate task finished

func FixActionCreatedUnixString added in v1.16.8

func FixActionCreatedUnixString() (int64, error)

FixActionCreatedUnixString set created_unix to zero if it is an empty string

func FixCommentTypeLabelWithEmptyLabel added in v1.14.0

func FixCommentTypeLabelWithEmptyLabel() (int64, error)

FixCommentTypeLabelWithEmptyLabel count label comments with empty label

func FixCommentTypeLabelWithOutsideLabels added in v1.14.0

func FixCommentTypeLabelWithOutsideLabels() (int64, error)

FixCommentTypeLabelWithOutsideLabels count label comments with outside label

func FixIssueLabelWithOutsideLabels added in v1.14.0

func FixIssueLabelWithOutsideLabels() (int64, error)

FixIssueLabelWithOutsideLabels fix label comments with outside label

func FixNullArchivedRepository added in v1.12.0

func FixNullArchivedRepository() (int64, error)

FixNullArchivedRepository sets is_archived to false where it is null

func FixWrongUserType added in v1.14.0

func FixWrongUserType() (int64, error)

FixWrongUserType fix OrgUser who have wrong type

func FullPushingEnvironment added in v1.9.0

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

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

func GenerateIssueLabels added in v1.11.0

func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error

GenerateIssueLabels generates issue labels from a template repository

func GenerateWebhooks added in v1.11.0

func GenerateWebhooks(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error

GenerateWebhooks generates webhooks from a template repository

func GetAssigneeIDsByIssue added in v1.11.0

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

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

func GetAssigneesByIssue added in v1.5.0

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

GetAssigneesByIssue returns everyone assigned to that issue

func GetForksByUserAndOrgs added in v1.16.0

func GetForksByUserAndOrgs(user *user_model.User, repo *repo_model.Repository) ([]*repo_model.Repository, error)

GetForksByUserAndOrgs return forked repos of the user and owned orgs

func GetIssueIDsByRepoID added in v1.8.0

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

GetIssueIDsByRepoID returns all issue ids by repo id

func GetIssueWatchersIDs added in v1.11.0

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

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

func GetLabelIDsInOrgByNames added in v1.12.0

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

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

func 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 GetNextCommitStatusIndex added in v1.16.0

func GetNextCommitStatusIndex(repoID int64, sha string) (int64, error)

GetNextCommitStatusIndex retried 3 times to generate a resource index

func GetNotificationCount added in v1.1.0

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

GetNotificationCount returns the notification count for user

func GetOrganizationCount added in v1.16.0

func GetOrganizationCount(ctx context.Context, u *user_model.User) (int64, error)

GetOrganizationCount returns count of membership of organization of the user.

func GetParticipantsIDsByIssueID added in v1.11.0

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

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

func GetPullRequestIDsByCheckStatus added in v1.11.0

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

GetPullRequestIDsByCheckStatus returns all pull requests according the special checking status.

func GetReleaseAttachments added in v1.1.0

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

GetReleaseAttachments retrieves the attachments for releases

func GetReleaseCountByRepoID added in v1.2.0

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

GetReleaseCountByRepoID returns the count of releases of repository

func GetRepoAssignees added in v1.16.0

func GetRepoAssignees(repo *repo_model.Repository) (_ []*user_model.User, err error)

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

func GetRepoIDsForIssuesOptions added in v1.12.0

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

GetRepoIDsForIssuesOptions find all repo ids for the given options

func GetRepoInitFile added in v1.12.0

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

GetRepoInitFile returns repository init files

func GetRepoIssueStats

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

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

func GetRepoReaders added in v1.16.0

func GetRepoReaders(repo *repo_model.Repository) (_ []*user_model.User, err error)

GetRepoReaders returns all users that have explicit read access or higher to the repository.

func GetRepoWriters added in v1.16.0

func GetRepoWriters(repo *repo_model.Repository) (_ []*user_model.User, err error)

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

func GetRepositoryFromMatch added in v1.9.0

func GetRepositoryFromMatch(ownerName, repoName string) (*repo_model.Repository, error)

GetRepositoryFromMatch returns a *repo_model.Repository from a username and repo strings

func GetReviewers added in v1.16.0

func GetReviewers(repo *repo_model.Repository, doerID, posterID int64) ([]*user_model.User, error)

GetReviewers get all users can be requested to review: * for private repositories this returns all users that have read access or higher to the repository. * for public repositories this returns all users that have read access or higher to the repository, all repo watchers and all organization members. TODO: may be we should have a busy choice for users to block review request to them.

func GetStarredRepos added in v1.0.0

func GetStarredRepos(userID int64, private bool, listOptions db.ListOptions) ([]*repo_model.Repository, error)

GetStarredRepos returns the repos starred by a particular user

func GetTeamIDsByNames added in v1.12.0

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

GetTeamIDsByNames returns a slice of team ids corresponds to names.

func GetTeamMembers

func GetTeamMembers(teamID int64) ([]*user_model.User, error)

GetTeamMembers returns all members in given team of organization.

func GetTeamNamesByID added in v1.12.0

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

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

func GetTrackedSeconds added in v1.11.0

func GetTrackedSeconds(opts FindTrackedTimesOptions) (int64, error)

GetTrackedSeconds return sum of seconds

func GetUserRepositories

func GetUserRepositories(opts *SearchRepoOptions) ([]*repo_model.Repository, int64, error)

GetUserRepositories returns a list of repositories of given user.

func GetUsersWhoCanCreateOrgRepo added in v1.14.0

func GetUsersWhoCanCreateOrgRepo(orgID int64) ([]*user_model.User, error)

GetUsersWhoCanCreateOrgRepo returns users which are able to create repo in organization

func GetWatchedRepos added in v1.1.0

func GetWatchedRepos(userID int64, private bool, listOptions db.ListOptions) ([]*repo_model.Repository, int64, error)

GetWatchedRepos returns the repos watched by a particular user

func GetYamlFixturesAccess added in v1.12.0

func GetYamlFixturesAccess() (string, error)

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

func HasAccess

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

HasAccess returns true if user has access to repo

func HasAccessUnit added in v1.7.0

func HasAccessUnit(user *user_model.User, repo *repo_model.Repository, unitType unit.Type, testMode perm_model.AccessMode) (bool, error)

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

func HasIssueLabel

func HasIssueLabel(issueID, labelID int64) bool

HasIssueLabel returns true if issue has been labeled.

func HasOrgOrUserVisible added in v1.15.0

func HasOrgOrUserVisible(org, user *user_model.User) bool

HasOrgOrUserVisible tells if the given user can see the given org or user

func HasOrgsVisible added in v1.8.0

func HasOrgsVisible(orgs []*Organization, user *user_model.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 HasUnmergedPullRequestsByHeadInfo added in v1.16.0

func HasUnmergedPullRequestsByHeadInfo(repoID int64, branch string) (bool, error)

HasUnmergedPullRequestsByHeadInfo checks if there are open and not merged pull request by given head information (repo and branch)

func HasWorkInProgressPrefix added in v1.15.0

func HasWorkInProgressPrefix(title string) bool

HasWorkInProgressPrefix determines if the given PR title has a Work In Progress prefix

func IncrementRepoForkNum added in v1.12.0

func IncrementRepoForkNum(ctx context.Context, repoID int64) error

IncrementRepoForkNum increment repository fork number

func InitializeLabels added in v1.12.0

func InitializeLabels(ctx context.Context, repoID int64, labelTemplate string, isOrg bool) error

InitializeLabels adds a label set to a repository using a template

func InsertIssueComments added in v1.9.0

func InsertIssueComments(comments []*Comment) error

InsertIssueComments inserts many comments of issues.

func InsertIssues added in v1.9.0

func InsertIssues(issues ...*Issue) error

InsertIssues insert issues to database

func InsertMilestones added in v1.9.0

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

InsertMilestones creates milestones of repository.

func InsertProtectedTag added in v1.15.0

func InsertProtectedTag(pt *ProtectedTag) error

InsertProtectedTag inserts a protected tag to database

func InsertPullRequests added in v1.9.0

func InsertPullRequests(prs ...*PullRequest) error

InsertPullRequests inserted pull requests

func InsertRelease added in v1.10.0

func InsertRelease(rel *Release) error

InsertRelease inserts a release

func InsertReleases added in v1.9.0

func InsertReleases(rels ...*Release) error

InsertReleases migrates release

func InsertReleasesContext added in v1.12.0

func InsertReleasesContext(ctx context.Context, rels []*Release) error

InsertReleasesContext insert releases

func InsertReviews added in v1.12.0

func InsertReviews(reviews []*Review) error

InsertReviews inserts review and review comments

func InternalPushingEnvironment added in v1.11.0

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

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

func IsCollaborator added in v1.16.0

func IsCollaborator(repoID, userID int64) (bool, error)

IsCollaborator check if a user is a collaborator of a repository

func IsContentEmptyErr added in v1.11.0

func IsContentEmptyErr(err error) bool

IsContentEmptyErr returns true if err is a ContentEmptyErr

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

func IsErrBranchAlreadyExists(err error) bool

IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.

func IsErrBranchDoesNotExist added in v1.13.0

func IsErrBranchDoesNotExist(err error) bool

IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.

func IsErrBranchNameConflict added in v1.3.0

func IsErrBranchNameConflict(err error) bool

IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.

func IsErrBranchesEqual added in v1.11.0

func IsErrBranchesEqual(err error) bool

IsErrBranchesEqual checks if an error is an ErrBranchesEqual.

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

func IsErrErrPullRequestHeadRepoMissing(err error) bool

IsErrErrPullRequestHeadRepoMissing checks if an error is a ErrPullRequestHeadRepoMissing.

func IsErrFilePathInvalid added in v1.9.0

func IsErrFilePathInvalid(err error) bool

IsErrFilePathInvalid checks if an error is an ErrFilePathInvalid.

func IsErrFilePathProtected added in v1.12.0

func IsErrFilePathProtected(err error) bool

IsErrFilePathProtected checks if an error is an ErrFilePathProtected.

func IsErrFilenameInvalid added in v1.9.0

func IsErrFilenameInvalid(err error) bool

IsErrFilenameInvalid checks if an error is an ErrFilenameInvalid.

func IsErrForbiddenIssueReaction added in v1.11.0

func IsErrForbiddenIssueReaction(err error) bool

IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.

func IsErrForkAlreadyExist added in v1.9.0

func IsErrForkAlreadyExist(err error) bool

IsErrForkAlreadyExist checks if an error is an ErrForkAlreadyExist.

func IsErrInvalidCloneAddr

func IsErrInvalidCloneAddr(err error) bool

IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.

func IsErrInvalidMergeStyle added in v1.4.0

func IsErrInvalidMergeStyle(err error) bool

IsErrInvalidMergeStyle checks if an error is a ErrInvalidMergeStyle.

func IsErrInvalidTagName

func IsErrInvalidTagName(err error) bool

IsErrInvalidTagName checks if an error is a ErrInvalidTagName.

func IsErrIssueIsClosed added in v1.11.0

func IsErrIssueIsClosed(err error) bool

IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.

func IsErrIssueLabelTemplateLoad added in v1.10.0

func IsErrIssueLabelTemplateLoad(err error) bool

IsErrIssueLabelTemplateLoad checks if an error is a ErrIssueLabelTemplateLoad.

func IsErrIssueNotExist

func IsErrIssueNotExist(err error) bool

IsErrIssueNotExist checks if an error is a ErrIssueNotExist.

func IsErrIssueWasClosed added in v1.11.0

func IsErrIssueWasClosed(err error) bool

IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.

func IsErrLFSFileLocked added in v1.11.0

func IsErrLFSFileLocked(err error) bool

IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.

func IsErrLFSLockAlreadyExist added in v1.4.0

func IsErrLFSLockAlreadyExist(err error) bool

IsErrLFSLockAlreadyExist checks if an error is a ErrLFSLockAlreadyExist.

func IsErrLFSLockNotExist added in v1.4.0

func IsErrLFSLockNotExist(err error) bool

IsErrLFSLockNotExist checks if an error is a ErrLFSLockNotExist.

func IsErrLFSUnauthorizedAction added in v1.4.0

func IsErrLFSUnauthorizedAction(err error) bool

IsErrLFSUnauthorizedAction checks if an error is a ErrLFSUnauthorizedAction.

func IsErrLabelNotExist

func IsErrLabelNotExist(err error) bool

IsErrLabelNotExist checks if an error is a ErrLabelNotExist.

func IsErrLastOrgOwner

func IsErrLastOrgOwner(err error) bool

IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.

func IsErrMergeConflicts added in v1.11.0

func IsErrMergeConflicts(err error) bool

IsErrMergeConflicts checks if an error is a ErrMergeConflicts.

func IsErrMergeUnrelatedHistories added in v1.11.0

func IsErrMergeUnrelatedHistories(err error) bool

IsErrMergeUnrelatedHistories checks if an error is a ErrMergeUnrelatedHistories.

func IsErrMilestoneNotExist

func IsErrMilestoneNotExist(err error) bool

IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.

func IsErrNewIssueInsert added in v1.10.0

func IsErrNewIssueInsert(err error) bool

IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.

func IsErrNoPendingTransfer added in v1.14.0

func IsErrNoPendingTransfer(err error) bool

IsErrNoPendingTransfer is an error type when a repository has no pending transfers

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

func IsErrNotValidReviewRequest(err error) bool

IsErrNotValidReviewRequest checks if an error is a ErrNotValidReviewRequest.

func IsErrOrgLabelNotExist added in v1.12.0

func IsErrOrgLabelNotExist(err error) bool

IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.

func IsErrOrgNotExist added in v1.2.0

func IsErrOrgNotExist(err error) bool

IsErrOrgNotExist checks if an error is a ErrOrgNotExist.

func IsErrProjectBoardNotExist added in v1.13.0

func IsErrProjectBoardNotExist(err error) bool

IsErrProjectBoardNotExist checks if an error is a ErrProjectBoardNotExist

func IsErrProjectNotExist added in v1.13.0

func IsErrProjectNotExist(err error) bool

IsErrProjectNotExist checks if an error is a ErrProjectNotExist

func IsErrProtectedTagName added in v1.15.0

func IsErrProtectedTagName(err error) bool

IsErrProtectedTagName checks if an error is a ErrProtectedTagName.

func IsErrPullRequestAlreadyExists added in v1.0.0

func IsErrPullRequestAlreadyExists(err error) bool

IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.

func IsErrPullRequestHasMerged added in v1.11.0

func IsErrPullRequestHasMerged(err error) bool

IsErrPullRequestHasMerged checks if an error is a ErrPullRequestHasMerged.

func IsErrPullRequestNotExist

func IsErrPullRequestNotExist(err error) bool

IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.

func IsErrPullWasClosed added in v1.11.0

func IsErrPullWasClosed(err error) bool

IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.

func IsErrReactionAlreadyExist added in v1.10.2

func IsErrReactionAlreadyExist(err error) bool

IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.

func IsErrRebaseConflicts added in v1.11.0

func IsErrRebaseConflicts(err error) bool

IsErrRebaseConflicts checks if an error is a ErrRebaseConflicts.

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

func IsErrRepoLabelNotExist(err error) bool

IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.

func IsErrRepoTransferInProgress added in v1.14.0

func IsErrRepoTransferInProgress(err error) bool

IsErrRepoTransferInProgress checks if an error is a ErrRepoTransferInProgress.

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

func IsErrTrackedTimeNotExist(err error) bool

IsErrTrackedTimeNotExist checks if an error is a ErrTrackedTimeNotExist.

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

func IsErrUserNotAllowedCreateOrg(err error) bool

IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.

func IsErrUserOwnRepos

func IsErrUserOwnRepos(err error) bool

IsErrUserOwnRepos checks if an error is a ErrUserOwnRepos.

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

func IsOfficialReviewer(issue *Issue, reviewers ...*user_model.User) (bool, error)

IsOfficialReviewer check if at least one of the provided reviewers can make official reviews in issue (counts towards required approvals)

func IsOfficialReviewerTeam added in v1.13.0

func IsOfficialReviewerTeam(issue *Issue, team *Team) (bool, error)

IsOfficialReviewerTeam check if reviewer in this team can make official reviews in issue (counts towards required approvals)

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 IsOwnerMemberCollaborator added in v1.16.0

func IsOwnerMemberCollaborator(repo *repo_model.Repository, userID int64) (bool, error)

IsOwnerMemberCollaborator checks if a provided user is the owner, a collaborator or a member of a team in a repository

func IsProjectBoardTypeValid added in v1.13.0

func IsProjectBoardTypeValid(p ProjectBoardType) bool

IsProjectBoardTypeValid checks if the project board type is valid

func IsProjectTypeValid added in v1.13.0

func IsProjectTypeValid(p ProjectType) bool

IsProjectTypeValid checks if a project type is valid

func IsProtectedBranch added in v1.16.0

func IsProtectedBranch(repoID int64, branchName string) (bool, error)

IsProtectedBranch checks if branch is protected

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 IsRepoReader added in v1.16.0

func IsRepoReader(repo *repo_model.Repository, userID int64) (bool, error)

IsRepoReader returns true if user has explicit read access or higher to the repository.

func IsTeamMember

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

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

func IsUsableTeamName added in v1.0.0

func IsUsableTeamName(name string) error

IsUsableTeamName tests if a name could be as team name

func IsUserAllowedModifyTag added in v1.16.0

func IsUserAllowedModifyTag(pt *ProtectedTag, userID int64) (bool, error)

IsUserAllowedModifyTag returns true if the user is allowed to modify the tag

func IsUserAllowedToControlTag added in v1.15.0

func IsUserAllowedToControlTag(tags []*ProtectedTag, tagName string, userID int64) (bool, error)

IsUserAllowedToControlTag checks if a user can control the specific tag. It returns true if the tag name is not protected or the user is allowed to control it.

func IsUserAssignedToIssue added in v1.5.0

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

IsUserAssignedToIssue returns true when the user is assigned to the issue

func IsUserInTeams added in v1.3.0

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

IsUserInTeams returns if a user in some teams

func IsUserMergeWhitelisted added in v1.16.0

func IsUserMergeWhitelisted(protectBranch *ProtectedBranch, userID int64, permissionInRepo Permission) bool

IsUserMergeWhitelisted checks if some user is whitelisted to merge to this branch

func IsUserOfficialReviewer added in v1.16.0

func IsUserOfficialReviewer(protectBranch *ProtectedBranch, user *user_model.User) (bool, error)

IsUserOfficialReviewer check if user is official reviewer for the branch (counts towards required approvals)

func IsUserOrgOwner added in v1.16.0

func IsUserOrgOwner(users user_model.UserList, orgID int64) map[int64]bool

IsUserOrgOwner returns true if user is in the owner team of given organization.

func IsUserParticipantsOfIssue added in v1.12.0

func IsUserParticipantsOfIssue(user *user_model.User, issue *Issue) bool

IsUserParticipantsOfIssue return true if user is participants of an issue

func IsUserRealRepoAdmin added in v1.13.0

func IsUserRealRepoAdmin(repo *repo_model.Repository, user *user_model.User) (bool, error)

IsUserRealRepoAdmin check if this user is real repo admin

func IsUserRepoAdmin added in v1.7.0

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

IsUserRepoAdmin return true if user has admin right of a repo

func IsUserVisibleToViewer added in v1.16.0

func IsUserVisibleToViewer(u, viewer *user_model.User) bool

IsUserVisibleToViewer check if viewer is able to see user profile

func IssueNoDependenciesLeft added in v1.6.0

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

IssueNoDependenciesLeft checks if issue can be closed

func IterateLFS added in v1.13.0

func IterateLFS(f func(mo *LFSMetaObject) error) error

IterateLFS iterates lfs object

func LFSAutoAssociate added in v1.11.0

func LFSAutoAssociate(metas []*LFSMetaObject, user *user_model.User, repoID int64) error

LFSAutoAssociate auto associates accessible LFSMetaObjects

func LFSObjectAccessible added in v1.11.0

func LFSObjectAccessible(user *user_model.User, oid string) (bool, error)

LFSObjectAccessible checks if a provided Oid is accessible to the user

func LFSObjectIsAssociated added in v1.16.0

func LFSObjectIsAssociated(oid string) (bool, error)

LFSObjectIsAssociated checks if a provided Oid is associated

func LinkedRepository added in v1.16.0

func LinkedRepository(a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error)

LinkedRepository returns the linked repo if any

func LoadLabelsFormatted added in v1.11.0

func LoadLabelsFormatted(labelTemplate string) (string, error)

LoadLabelsFormatted loads the labels' list of a template file as a string separated by comma

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 Luminance added in v1.16.0

func Luminance(color uint32) float64

Luminance returns the luminance of an sRGB color

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

func MarkConversation(comment *Comment, doer *user_model.User, isResolve bool) (err error)

MarkConversation Add or remove Conversation mark for a code comment

func MarkReviewsAsNotStale added in v1.12.0

func MarkReviewsAsNotStale(issueID int64, commitID string) (err error)

MarkReviewsAsNotStale marks existing reviews as not stale for a giving commit SHA

func MarkReviewsAsStale added in v1.12.0

func MarkReviewsAsStale(issueID int64) (err error)

MarkReviewsAsStale marks existing reviews as stale

func MoveIssuesOnProjectBoard added in v1.16.0

func MoveIssuesOnProjectBoard(board *ProjectBoard, sortedIssueIDs map[int64]int64) error

MoveIssuesOnProjectBoard moves or keeps issues in a column and sorts them inside that column

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 NewIssue

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

NewIssue creates new issue with labels for repository.

func NewIssueLabel

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

NewIssueLabel creates a new issue-label relation.

func NewIssueLabels

func NewIssueLabels(issue *Issue, labels []*Label, doer *user_model.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

func NewLabels

func NewLabels(labels ...*Label) error

NewLabels creates new labels

func NewMilestone

func NewMilestone(m *Milestone) (err error)

NewMilestone creates new milestone of repository.

func NewProject added in v1.13.0

func NewProject(p *Project) error

NewProject creates a new Project

func NewProjectBoard added in v1.13.0

func NewProjectBoard(board *ProjectBoard) error

NewProjectBoard adds a new project board to a given project

func NewPullRequest

func NewPullRequest(repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids []string, pr *PullRequest) (err error)

NewPullRequest creates new pull request with labels for repository.

func NewRepoContext

func NewRepoContext()

NewRepoContext creates a new repository context

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 NotifyWatchers

func NotifyWatchers(actions ...*Action) error

NotifyWatchers creates batch of actions for every watcher.

func NotifyWatchersActions added in v1.11.0

func NotifyWatchersActions(acts []*Action) error

NotifyWatchersActions creates batch of actions for every watcher.

func PushUpdateDeleteTag added in v1.10.0

func PushUpdateDeleteTag(repo *repo_model.Repository, tagName string) error

PushUpdateDeleteTag must be called for any push actions to delete tag

func PushUpdateDeleteTagsContext added in v1.12.0

func PushUpdateDeleteTagsContext(ctx context.Context, repo *repo_model.Repository, tags []string) error

PushUpdateDeleteTagsContext updates a number of delete tags with context

func PushingEnvironment added in v1.9.0

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

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

func RecalculateAccesses added in v1.16.0

func RecalculateAccesses(repo *repo_model.Repository) error

RecalculateAccesses recalculates all accesses for repository.

func RecalculateIssueIndexForRepo added in v1.15.0

func RecalculateIssueIndexForRepo(repoID int64) error

RecalculateIssueIndexForRepo create issue_index for repo if not exist and update it based on highest index of existing issues assigned to a repo

func RemoveDeletedBranchByID added in v1.16.0

func RemoveDeletedBranchByID(repoID, id int64) (err error)

RemoveDeletedBranchByID removes a deleted branch from the database

func RemoveDeletedBranchByName added in v1.16.0

func RemoveDeletedBranchByName(repoID int64, branch string) error

RemoveDeletedBranchByName removes all deleted branches

func RemoveIssueDependency added in v1.6.0

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

RemoveIssueDependency removes a dependency from an issue

func RemoveLFSMetaObjectByOid added in v1.1.0

func RemoveLFSMetaObjectByOid(repoID int64, oid string) (int64, error)

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

func RemoveOldDeletedBranches added in v1.3.0

func RemoveOldDeletedBranches(ctx context.Context, olderThan time.Duration)

RemoveOldDeletedBranches removes old deleted branches

func RemoveOrgUser

func RemoveOrgUser(orgID, userID int64) error

RemoveOrgUser removes user from given organization.

func RemoveTeamMember

func RemoveTeamMember(team *Team, userID int64) error

RemoveTeamMember removes member from given team of given organization.

func RemoveTemporaryPath added in v1.9.0

func RemoveTemporaryPath(basePath string) error

RemoveTemporaryPath removes the temporary path

func RenameBranch added in v1.16.0

func RenameBranch(repo *repo_model.Repository, from, to string, gitAction func(isDefault bool) error) (err error)

RenameBranch rename a branch

func ReviewExists added in v1.11.0

func ReviewExists(issue *Issue, treePath string, line int64) (bool, error)

ReviewExists returns whether a review exists for a particular line of code in the PR

func SaveOrUpdateTag added in v1.12.0

func SaveOrUpdateTag(repo *repo_model.Repository, newRel *Release) error

SaveOrUpdateTag must be called for any push actions to add tag

func SearchIssueIDsByKeyword added in v1.8.0

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

SearchIssueIDsByKeyword search issues on database

func SearchRepositoryCondition added in v1.11.4

func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond

SearchRepositoryCondition creates a query condition according search repository options

func SearchRepositoryIDs added in v1.14.0

func SearchRepositoryIDs(opts *SearchRepoOptions) ([]int64, int64, error)

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

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

func SetDefaultBoard(projectID, boardID int64) error

SetDefaultBoard represents a board for issues not assigned to one if boardID is 0 unset default

func SetRepoReadBy added in v1.16.0

func SetRepoReadBy(repoID, userID int64) error

SetRepoReadBy sets repo to be visited by given user.

func SortReleases

func SortReleases(rels []*Release)

SortReleases sorts releases by number of commits and created time.

func SrgbToLinear added in v1.16.0

func SrgbToLinear(color uint8) float64

SrgbToLinear converts a component of an sRGB color to its linear intensity See: https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation_(sRGB_to_CIE_XYZ)

func StatsCorrectSQL added in v1.16.0

func StatsCorrectSQL(ctx context.Context, sql string, id int64) error

func StopwatchExists added in v1.3.0

func StopwatchExists(userID, issueID int64) bool

StopwatchExists returns true if the stopwatch exists

func SubmitReview added in v1.11.0

func SubmitReview(doer *user_model.User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool, attachmentUUIDs []string) (*Review, *Comment, error)

SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist

func TestRepositoryReadyForTransfer added in v1.14.0

func TestRepositoryReadyForTransfer(status repo_model.RepositoryStatus) error

TestRepositoryReadyForTransfer make sure repo is ready to transfer

func TotalTimes added in v1.3.0

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

TotalTimes returns the spent time for each user by an issue

func TransferOwnership

func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_model.Repository) (err error)

TransferOwnership transfers all corresponding repository items from old user to new one.

func UnlockIssue added in v1.8.0

func UnlockIssue(opts *IssueLockOptions) error

UnlockIssue unlocks a previously locked issue.

func UpdateAccessToken

func UpdateAccessToken(t *AccessToken) error

UpdateAccessToken updates information of access token.

func UpdateComment

func UpdateComment(c *Comment, doer *user_model.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 UpdateIssueDeadline added in v1.5.0

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

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

func UpdateIssueMentions

func UpdateIssueMentions(ctx context.Context, issueID int64, mentions []*user_model.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 context.Context, issueID int64, uids []int64) error

UpdateIssueUsersByMentions updates issue-user pairs by mentioning.

func UpdateIssuesMigrationsByType added in v1.10.0

func UpdateIssuesMigrationsByType(gitServiceType api.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, oldIsClosed bool) error

UpdateMilestone updates information of given milestone.

func UpdateNotificationStatuses added in v1.4.0

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

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

func UpdateProject added in v1.13.0

func UpdateProject(p *Project) error

UpdateProject updates project properties

func UpdateProjectBoard added in v1.13.0

func UpdateProjectBoard(board *ProjectBoard) error

UpdateProjectBoard updates a project board

func UpdateProjectBoardSorting added in v1.14.0

func UpdateProjectBoardSorting(bs ProjectBoardList) error

UpdateProjectBoardSorting update project board sorting

func UpdateProtectBranch added in v1.3.0

func UpdateProtectBranch(repo *repo_model.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 UpdateProtectedTag added in v1.15.0

func UpdateProtectedTag(pt *ProtectedTag) error

UpdateProtectedTag updates the protected tag

func UpdateReactionsMigrationsByType added in v1.12.0

func UpdateReactionsMigrationsByType(gitServiceType api.GitServiceType, originalAuthorID string, userID int64) error

UpdateReactionsMigrationsByType updates all migrated repositories' reactions from gitServiceType to replace originalAuthorID to posterID

func UpdateRelease

func UpdateRelease(ctx context.Context, 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 UpdateRepoSize added in v1.16.0

func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error

UpdateRepoSize updates the repository size, calculating it using util.GetDirectorySize

func UpdateRepoStats added in v1.16.0

func UpdateRepoStats(ctx context.Context, id int64) error

func UpdateRepository

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

UpdateRepository updates a repository

func UpdateRepositoryCtx added in v1.12.0

func UpdateRepositoryCtx(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) error

UpdateRepositoryCtx updates a repository with db context

func UpdateReviewsMigrationsByType added in v1.12.0

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

UpdateReviewsMigrationsByType updates reviews' migrations information via given git service type and original id and poster id

func UpdateTeam

func UpdateTeam(t *Team, authChanged, includeAllChanged 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 UploadLocalPath

func UploadLocalPath(uuid string) string

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

func UsersInTeamsCount added in v1.7.0

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

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

Types

type Access

type Access struct {
	ID     int64 `xorm:"pk autoincr"`
	UserID int64 `xorm:"UNIQUE(s)"`
	RepoID int64 `xorm:"UNIQUE(s)"`
	Mode   perm.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 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(opts ListAccessTokensOptions) ([]*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) ([]*repo_model.Repository, error)
	MirrorRepos() ([]*repo_model.Repository, error)
	AddKeyword(keyword string)
	SetSort(db.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_model.User       `xorm:"-"`
	RepoID      int64                  `xorm:"INDEX"`
	Repo        *repo_model.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) 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, or falls back to the username if it is blank.

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

GetRefLink returns the action's ref link.

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

func (a *Action) GetTag() string

GetTag returns the action's repository tag.

func (*Action) LoadActUser added in v1.14.0

func (a *Action) LoadActUser()

LoadActUser loads a.ActUser

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() ([]*repo_model.Repository, error)

LoadRepositories loads actions' all repositories

func (ActionList) LoadUsers added in v1.4.0

func (actions ActionList) LoadUsers() ([]*user_model.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
	ActionApprovePullRequest                              // 21
	ActionRejectPullRequest                               // 22
	ActionCommentPull                                     // 23
	ActionPublishRelease                                  // 24
	ActionPullReviewDismissed                             // 25
	ActionPullRequestReadyForReview                       // 26
)

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"`
	HomeLink   string `json:"home_link"`
	Commits    int64  `json:"commits"`
}

ActivityAuthorData represents statistical git commit count data

func GetActivityStatsTopAuthors added in v1.9.0

func GetActivityStatsTopAuthors(repo *repo_model.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 *repo_model.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

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

FillPullRequests returns pull request information for activity page

func (*ActivityStats) FillReleases added in v1.3.0

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

FillReleases returns release information for activity page

func (*ActivityStats) FillUnresolvedIssues added in v1.3.0

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

FillUnresolvedIssues returns unresolved issue and pull request information for activity page

func (*ActivityStats) MergedPRCount added in v1.3.0

func (stats *ActivityStats) MergedPRCount() int

MergedPRCount returns merged pull request count

func (*ActivityStats) MergedPRPerc added in v1.3.0

func (stats *ActivityStats) MergedPRPerc() int

MergedPRPerc returns merged pull request percent from total active

func (*ActivityStats) OpenedIssueCount added in v1.3.0

func (stats *ActivityStats) OpenedIssueCount() int

OpenedIssueCount returns open issue count

func (*ActivityStats) OpenedIssuePerc added in v1.3.0

func (stats *ActivityStats) OpenedIssuePerc() int

OpenedIssuePerc returns open issue count percent from total active

func (*ActivityStats) OpenedPRCount added in v1.3.0

func (stats *ActivityStats) OpenedPRCount() int

OpenedPRCount returns opened pull request count

func (*ActivityStats) OpenedPRPerc added in v1.3.0

func (stats *ActivityStats) OpenedPRPerc() int

OpenedPRPerc returns opened pull request percents from total active

func (*ActivityStats) PublishedReleaseCount added in v1.3.0

func (stats *ActivityStats) PublishedReleaseCount() int

PublishedReleaseCount returns published release count

func (*ActivityStats) UnresolvedIssueCount added in v1.3.0

func (stats *ActivityStats) UnresolvedIssueCount() int

UnresolvedIssueCount returns unresolved issue and pull request count

type CodeComments added in v1.6.0

type CodeComments map[string]map[int64][]*Comment

CodeComments represents comments on code by using this structure: FILENAME -> LINE (+ == proposed; - == previous) -> COMMENTS

func FetchCodeComments added in v1.6.0

func FetchCodeComments(issue *Issue, currentUser *user_model.User) (CodeComments, error)

FetchCodeComments will return a 2d-map: ["Path"]["Line"] = Comments at line

type Collaboration

type Collaboration struct {
	ID          int64              `xorm:"pk autoincr"`
	RepoID      int64              `xorm:"UNIQUE(s) INDEX NOT NULL"`
	UserID      int64              `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Mode        perm.AccessMode    `xorm:"DEFAULT 2 NOT NULL"`
	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

Collaboration represent the relation between an individual and a repository.

type Collaborator

type Collaborator struct {
	*user_model.User
	Collaboration *Collaboration
}

Collaborator represents a user with collaboration details.

func GetCollaborators added in v1.16.0

func GetCollaborators(repoID int64, listOptions db.ListOptions) ([]*Collaborator, error)

GetCollaborators returns the collaborators for a repository

type Comment

type Comment struct {
	ID               int64            `xorm:"pk autoincr"`
	Type             CommentType      `xorm:"INDEX"`
	PosterID         int64            `xorm:"INDEX"`
	Poster           *user_model.User `xorm:"-"`
	OriginalAuthor   string
	OriginalAuthorID int64
	IssueID          int64  `xorm:"INDEX"`
	Issue            *Issue `xorm:"-"`
	LabelID          int64
	Label            *Label   `xorm:"-"`
	AddedLabels      []*Label `xorm:"-"`
	RemovedLabels    []*Label `xorm:"-"`
	OldProjectID     int64
	ProjectID        int64
	OldProject       *Project `xorm:"-"`
	Project          *Project `xorm:"-"`
	OldMilestoneID   int64
	MilestoneID      int64
	OldMilestone     *Milestone `xorm:"-"`
	Milestone        *Milestone `xorm:"-"`
	TimeID           int64
	Time             *TrackedTime `xorm:"-"`
	AssigneeID       int64
	RemovedAssignee  bool
	Assignee         *user_model.User `xorm:"-"`
	AssigneeTeamID   int64            `xorm:"NOT NULL DEFAULT 0"`
	AssigneeTeam     *Team            `xorm:"-"`
	ResolveDoerID    int64
	ResolveDoer      *user_model.User `xorm:"-"`
	OldTitle         string
	NewTitle         string
	OldRef           string
	NewRef           string
	DependentIssueID int64
	DependentIssue   *Issue `xorm:"-"`

	CommitID        int64
	Line            int64 // - previous line / + proposed line
	TreePath        string
	Content         string `xorm:"LONGTEXT"`
	RenderedContent string `xorm:"-"`

	// Path represents the 4 lines of code cemented by this comment
	Patch       string `xorm:"-"`
	PatchQuoted string `xorm:"LONGTEXT patch"`

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

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

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

	// For view issue page.
	ShowRole RoleDescriptor `xorm:"-"`

	Review      *Review `xorm:"-"`
	ReviewID    int64   `xorm:"index"`
	Invalidated bool

	// Reference an issue or pull from another comment, issue or PR
	// All information is about the origin of the reference
	RefRepoID    int64                 `xorm:"index"` // Repo where the referencing
	RefIssueID   int64                 `xorm:"index"`
	RefCommentID int64                 `xorm:"index"`    // 0 if origin is Issue title or content (or PR's)
	RefAction    references.XRefAction `xorm:"SMALLINT"` // What happens if RefIssueID resolves
	RefIsPull    bool

	RefRepo    *repo_model.Repository `xorm:"-"`
	RefIssue   *Issue                 `xorm:"-"`
	RefComment *Comment               `xorm:"-"`

	Commits     []*SignCommitWithStatuses `xorm:"-"`
	OldCommit   string                    `xorm:"-"`
	NewCommit   string                    `xorm:"-"`
	CommitsNum  int64                     `xorm:"-"`
	IsForcePush bool                      `xorm:"-"`
}

Comment represents a comment in commit and issue page.

func AddReviewRequest added in v1.12.0

func AddReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Comment, error)

AddReviewRequest add a review request from one reviewer

func AddTeamReviewRequest added in v1.13.0

func AddTeamReviewRequest(issue *Issue, reviewer *Team, doer *user_model.User) (*Comment, error)

AddTeamReviewRequest add a review request from one team

func CreateComment

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

CreateComment creates comment of issue or commit.

func CreatePushPullComment added in v1.13.0

func CreatePushPullComment(pusher *user_model.User, pr *PullRequest, oldCommitID, newCommitID string) (comment *Comment, err error)

CreatePushPullComment create push code to pull base comment

func FetchCodeCommentsByLine added in v1.14.0

func FetchCodeCommentsByLine(issue *Issue, currentUser *user_model.User, treePath string, line int64) ([]*Comment, error)

FetchCodeCommentsByLine fetches the code comments for a given treePath and line number

func FindComments added in v1.2.0

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

FindComments returns all comments according options

func GetCommentByID

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

GetCommentByID returns the comment by given ID.

func RemoveReviewRequest added in v1.12.0

func RemoveReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Comment, error)

RemoveReviewRequest remove a review request from one reviewer

func RemoveTeamReviewRequest added in v1.13.0

func RemoveTeamReviewRequest(issue *Issue, reviewer *Team, doer *user_model.User) (*Comment, error)

RemoveTeamReviewRequest remove a review request from one team

func UpdateIssueByAPI added in v1.10.2

func UpdateIssueByAPI(issue *Issue, doer *user_model.User) (statusChangeComment *Comment, titleChanged bool, err error)

UpdateIssueByAPI updates all allowed fields of given issue. If the issue status is changed a statusChangeComment is returned similarly if the title is changed the titleChanged bool is set to true

func (*Comment) APIURL added in v1.12.0

func (c *Comment) APIURL() string

APIURL formats a API-string to the issue-comment

func (*Comment) AfterDelete

func (c *Comment) AfterDelete()

AfterDelete is invoked from XORM after the object is deleted.

func (*Comment) AfterLoad added in v1.3.0

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

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

func (*Comment) BeforeInsert

func (c *Comment) BeforeInsert()

BeforeInsert will be invoked by XORM before inserting a record

func (*Comment) BeforeUpdate

func (c *Comment) BeforeUpdate()

BeforeUpdate will be invoked by XORM before updating a record

func (*Comment) CheckInvalidation added in v1.6.0

func (c *Comment) CheckInvalidation(repo *git.Repository, doer *user_model.User, branch string) error

CheckInvalidation checks if the line of code comment got changed by another commit. If the line got changed the comment is going to be invalidated.

func (*Comment) CodeCommentURL added in v1.6.0

func (c *Comment) CodeCommentURL() string

CodeCommentURL returns the url to a comment in code

func (*Comment) DiffSide added in v1.6.0

func (c *Comment) DiffSide() string

DiffSide returns "previous" if Comment.Line is a LOC of the previous changes and "proposed" if it is a LOC of the proposed changes.

func (*Comment) EventTag

func (c *Comment) EventTag() string

EventTag returns unique event hash tag for comment.

func (*Comment) HTMLURL added in v1.0.0

func (c *Comment) HTMLURL() string

HTMLURL formats a URL-string to the issue-comment

func (*Comment) HashTag

func (c *Comment) HashTag() string

HashTag returns unique hash tag for comment.

func (*Comment) IsResolved added in v1.12.0

func (c *Comment) IsResolved() bool

IsResolved check if an code comment is resolved

func (*Comment) IssueURL added in v1.0.0

func (c *Comment) IssueURL() string

IssueURL formats a URL-string to the issue

func (*Comment) LoadAssigneeUserAndTeam added in v1.13.0

func (c *Comment) LoadAssigneeUserAndTeam() error

LoadAssigneeUserAndTeam if comment.Type is CommentTypeAssignees, then load assignees

func (*Comment) LoadAttachments added in v1.7.0

func (c *Comment) LoadAttachments() error

LoadAttachments loads attachments (it never returns error, the error during `GetAttachmentsByCommentIDCtx` is ignored)

func (*Comment) LoadDepIssueDetails added in v1.6.0

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

LoadDepIssueDetails loads Dependent Issue Details

func (*Comment) LoadIssue added in v1.5.0

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

LoadIssue loads issue from database

func (*Comment) LoadLabel added in v1.1.0

func (c *Comment) LoadLabel() error

LoadLabel if comment.Type is CommentTypeLabel, then load Label

func (*Comment) LoadMilestone added in v1.1.0

func (c *Comment) LoadMilestone() error

LoadMilestone if comment.Type is CommentTypeMilestone, then load milestone

func (*Comment) LoadPoster added in v1.7.0

func (c *Comment) LoadPoster() error

LoadPoster loads comment poster

func (*Comment) LoadProject added in v1.13.0

func (c *Comment) LoadProject() error

LoadProject if comment.Type is CommentTypeProject, then load project.

func (*Comment) LoadPushCommits added in v1.13.0

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

LoadPushCommits Load push commits

func (*Comment) LoadReactions added in v1.4.0

func (c *Comment) LoadReactions(repo *repo_model.Repository) error

LoadReactions loads comment reactions

func (*Comment) LoadRefComment added in v1.10.0

func (comment *Comment) LoadRefComment() (err error)

LoadRefComment loads comment that created this reference from database

func (*Comment) LoadRefIssue added in v1.10.0

func (comment *Comment) LoadRefIssue() (err error)

LoadRefIssue loads comment that created this reference from database

func (*Comment) LoadResolveDoer added in v1.12.0

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

LoadResolveDoer if comment.Type is CommentTypeCode and ResolveDoerID not zero, then load resolveDoer

func (*Comment) LoadReview added in v1.6.0

func (c *Comment) LoadReview() error

LoadReview loads the associated review

func (*Comment) LoadTime added in v1.14.0

func (c *Comment) LoadTime() error

LoadTime loads the associated time for a CommentTypeAddTimeManual

func (*Comment) PRURL added in v1.0.0

func (c *Comment) PRURL() string

PRURL formats a URL-string to the pull-request

func (*Comment) RefCommentHTMLURL added in v1.10.0

func (comment *Comment) RefCommentHTMLURL() string

RefCommentHTMLURL returns the HTML URL for the comment that created this reference

func (*Comment) RefIssueHTMLURL added in v1.10.0

func (comment *Comment) RefIssueHTMLURL() string

RefIssueHTMLURL returns the HTML URL of the issue where this reference was created

func (*Comment) RefIssueIdent added in v1.10.0

func (comment *Comment) RefIssueIdent() string

RefIssueIdent returns the user friendly identity (e.g. "#1234") of the issue where this reference was created

func (*Comment) RefIssueTitle added in v1.10.0

func (comment *Comment) RefIssueTitle() string

RefIssueTitle returns the title of the issue where this reference was created

func (*Comment) UnsignedLine added in v1.6.0

func (c *Comment) UnsignedLine() uint64

UnsignedLine returns the LOC of the code comment without + or -

func (*Comment) UpdateAttachments added in v1.11.0

func (c *Comment) UpdateAttachments(uuids []string) error

UpdateAttachments update attachments by UUIDs for the comment

type CommentList added in v1.7.0

type CommentList []*Comment

CommentList defines a list of comments

func (CommentList) Issues added in v1.9.0

func (comments CommentList) Issues() IssueList

Issues returns all the issues of comments

func (CommentList) LoadAttachments added in v1.9.0

func (comments CommentList) LoadAttachments() error

LoadAttachments loads attachments

func (CommentList) LoadAttributes added in v1.9.0

func (comments CommentList) LoadAttributes() error

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

func (CommentList) LoadIssues added in v1.9.0

func (comments CommentList) LoadIssues() error

LoadIssues loads issues of comments

func (CommentList) LoadPosters added in v1.7.0

func (comments CommentList) LoadPosters() error

LoadPosters loads posters

type CommentType

type CommentType int

CommentType defines whether a comment is just a simple comment, an action (like close) or a reference.

const (
	// 0 Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0)
	CommentTypeComment CommentType = iota
	CommentTypeReopen              // 1
	CommentTypeClose               // 2

	// 3 References.
	CommentTypeIssueRef
	// 4 Reference from a commit (not part of a pull request)
	CommentTypeCommitRef
	// 5 Reference from a comment
	CommentTypeCommentRef
	// 6 Reference from a pull request
	CommentTypePullRef
	// 7 Labels changed
	CommentTypeLabel
	// 8 Milestone changed
	CommentTypeMilestone
	// 9 Assignees changed
	CommentTypeAssignees
	// 10 Change Title
	CommentTypeChangeTitle
	// 11 Delete Branch
	CommentTypeDeleteBranch
	// 12 Start a stopwatch for time tracking
	CommentTypeStartTracking
	// 13 Stop a stopwatch for time tracking
	CommentTypeStopTracking
	// 14 Add time manual for time tracking
	CommentTypeAddTimeManual
	// 15 Cancel a stopwatch for time tracking
	CommentTypeCancelTracking
	// 16 Added a due date
	CommentTypeAddedDeadline
	// 17 Modified the due date
	CommentTypeModifiedDeadline
	// 18 Removed a due date
	CommentTypeRemovedDeadline
	// 19 Dependency added
	CommentTypeAddDependency
	// 20 Dependency removed
	CommentTypeRemoveDependency
	// 21 Comment a line of code
	CommentTypeCode
	// 22 Reviews a pull request by giving general feedback
	CommentTypeReview
	// 23 Lock an issue, giving only collaborators access
	CommentTypeLock
	// 24 Unlocks a previously locked issue
	CommentTypeUnlock
	// 25 Change pull request's target branch
	CommentTypeChangeTargetBranch
	// 26 Delete time manual for time tracking
	CommentTypeDeleteTimeManual
	// 27 add or remove Request from one
	CommentTypeReviewRequest
	// 28 merge pull request
	CommentTypeMergePull
	// 29 push to PR head branch
	CommentTypePullPush
	// 30 Project changed
	CommentTypeProject
	// 31 Project board changed
	CommentTypeProjectBoard
	// 32 Dismiss Review
	CommentTypeDismissReview
	// 33 Change issue ref
	CommentTypeChangeIssueRef
)

Enumerate all the comment types

const (
	CommentTypeUnknown CommentType = -1
)

define unknown comment type

func (CommentType) String added in v1.16.0

func (t CommentType) String() string

type CommitStatus added in v1.2.0

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

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

CommitStatus holds a single Status of a single Commit

func CalcCommitStatus added in v1.3.0

func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus

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

func GetCommitStatuses added in v1.2.0

func GetCommitStatuses(repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error)

GetCommitStatuses returns all statuses for a given commit.

func GetLatestCommitStatus added in v1.2.0

func GetLatestCommitStatus(repoID int64, sha string, listOptions db.ListOptions) ([]*CommitStatus, int64, error)

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

func (*CommitStatus) APIURL added in v1.2.0

func (status *CommitStatus) APIURL() string

APIURL returns the absolute APIURL to this commit-status.

type CommitStatusIndex added in v1.16.0

type CommitStatusIndex struct {
	ID       int64
	RepoID   int64  `xorm:"unique(repo_sha)"`
	SHA      string `xorm:"unique(repo_sha)"`
	MaxIndex int64  `xorm:"index"`
}

CommitStatusIndex represents a table for commit status index

type CommitStatusOptions added in v1.10.0

type CommitStatusOptions struct {
	db.ListOptions
	State    string
	SortType string
}

CommitStatusOptions holds the options for query commit statuses

type ContentEmptyErr added in v1.11.0

type ContentEmptyErr struct{}

ContentEmptyErr represents an content empty error

func (ContentEmptyErr) Error added in v1.11.0

func (ContentEmptyErr) Error() string

type CreateCommentOptions

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

	DependentIssueID int64
	OldMilestoneID   int64
	MilestoneID      int64
	OldProjectID     int64
	ProjectID        int64
	TimeID           int64
	AssigneeID       int64
	AssigneeTeamID   int64
	RemovedAssignee  bool
	OldTitle         string
	NewTitle         string
	OldRef           string
	NewRef           string
	CommitID         int64
	CommitSHA        string
	Patch            string
	LineNum          int64
	TreePath         string
	ReviewID         int64
	Content          string
	Attachments      []string // UUIDs of attachments
	RefRepoID        int64
	RefIssueID       int64
	RefCommentID     int64
	RefAction        references.XRefAction
	RefIsPull        bool
	IsForcePush      bool
	Invalidated      bool
}

CreateCommentOptions defines options for creating comment

type CreateRepoOptions

type CreateRepoOptions struct {
	Name           string
	Description    string
	OriginalURL    string
	GitServiceType api.GitServiceType
	Gitignores     string
	IssueLabels    string
	License        string
	Readme         string
	DefaultBranch  string
	IsPrivate      bool
	IsMirror       bool
	IsTemplate     bool
	AutoInit       bool
	Status         repo_model.RepositoryStatus
	TrustModel     repo_model.TrustModelType
	MirrorInterval string
}

CreateRepoOptions contains the create repository options

type CreateReviewOptions added in v1.6.0

type CreateReviewOptions struct {
	Content      string
	Type         ReviewType
	Issue        *Issue
	Reviewer     *user_model.User
	ReviewerTeam *Team
	Official     bool
	CommitID     string
	Stale        bool
}

CreateReviewOptions represent the options to create a review. Type, Issue and Reviewer are required.

type DeletedBranch added in v1.3.0

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

DeletedBranch struct

func GetDeletedBranchByID added in v1.16.0

func GetDeletedBranchByID(repoID, id int64) (*DeletedBranch, error)

GetDeletedBranchByID get a deleted branch by its ID

func GetDeletedBranches added in v1.16.0

func GetDeletedBranches(repoID int64) ([]*DeletedBranch, error)

GetDeletedBranches returns all the deleted branches

func (*DeletedBranch) LoadUser added in v1.3.0

func (deletedBranch *DeletedBranch) LoadUser()

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

type DependencyInfo added in v1.11.0

type DependencyInfo struct {
	Issue                 `xorm:"extends"`
	repo_model.Repository `xorm:"extends"`
}

DependencyInfo represents high level information about an issue which is a dependency of another issue.

type DependencyType added in v1.6.0

type DependencyType int

DependencyType Defines Dependency Type Constants

const (
	DependencyTypeBlockedBy DependencyType = iota
	DependencyTypeBlocking
)

Define Dependency Types

type ErrAccessTokenEmpty

type ErrAccessTokenEmpty struct{}

ErrAccessTokenEmpty represents a "AccessTokenEmpty" kind of error.

func (ErrAccessTokenEmpty) Error

func (err ErrAccessTokenEmpty) Error() string

type ErrAccessTokenNotExist

type ErrAccessTokenNotExist struct {
	Token string
}

ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.

func (ErrAccessTokenNotExist) Error

func (err ErrAccessTokenNotExist) Error() string

type ErrBranchAlreadyExists added in v1.3.0

type ErrBranchAlreadyExists struct {
	BranchName string
}

ErrBranchAlreadyExists represents an error that branch with such name already exists.

func (ErrBranchAlreadyExists) Error added in v1.3.0

func (err ErrBranchAlreadyExists) Error() string

type ErrBranchDoesNotExist added in v1.13.0

type ErrBranchDoesNotExist struct {
	BranchName string
}

ErrBranchDoesNotExist represents an error that branch with such name does not exist.

func (ErrBranchDoesNotExist) Error added in v1.13.0

func (err ErrBranchDoesNotExist) Error() string

type ErrBranchNameConflict added in v1.3.0

type ErrBranchNameConflict struct {
	BranchName string
}

ErrBranchNameConflict represents an error that branch name conflicts with other branch.

func (ErrBranchNameConflict) Error added in v1.3.0

func (err ErrBranchNameConflict) Error() string

type ErrBranchesEqual added in v1.11.0

type ErrBranchesEqual struct {
	BaseBranchName string
	HeadBranchName string
}

ErrBranchesEqual represents an error that branch name conflicts with other branch.

func (ErrBranchesEqual) Error added in v1.11.0

func (err ErrBranchesEqual) Error() string

type ErrCircularDependency added in v1.6.0

type ErrCircularDependency struct {
	IssueID      int64
	DependencyID int64
}

ErrCircularDependency represents a "DependencyCircular" kind of error.

func (ErrCircularDependency) Error added in v1.6.0

func (err ErrCircularDependency) Error() string

type ErrCommentNotExist

type ErrCommentNotExist struct {
	ID      int64
	IssueID int64
}

ErrCommentNotExist represents a "CommentNotExist" kind of error.

func (ErrCommentNotExist) Error

func (err ErrCommentNotExist) Error() string

type ErrCommitIDDoesNotMatch added in v1.9.0

type ErrCommitIDDoesNotMatch struct {
	GivenCommitID   string
	CurrentCommitID string
}

ErrCommitIDDoesNotMatch represents a "CommitIDDoesNotMatch" kind of error.

func (ErrCommitIDDoesNotMatch) Error added in v1.9.0

func (err ErrCommitIDDoesNotMatch) Error() string

type ErrDependenciesLeft added in v1.6.0

type ErrDependenciesLeft struct {
	IssueID int64
}

ErrDependenciesLeft represents an error where the issue you're trying to close still has dependencies left.

func (ErrDependenciesLeft) Error added in v1.6.0

func (err ErrDependenciesLeft) Error() string

type ErrDependencyExists added in v1.6.0

type ErrDependencyExists struct {
	IssueID      int64
	DependencyID int64
}

ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.

func (ErrDependencyExists) Error added in v1.6.0

func (err ErrDependencyExists) Error() string

type ErrDependencyNotExists added in v1.6.0

type ErrDependencyNotExists struct {
	IssueID      int64
	DependencyID int64
}

ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.

func (ErrDependencyNotExists) Error added in v1.6.0

func (err ErrDependencyNotExists) Error() string

type ErrFilePathInvalid added in v1.9.0

type ErrFilePathInvalid struct {
	Message string
	Path    string
	Name    string
	Type    git.EntryMode
}

ErrFilePathInvalid represents a "FilePathInvalid" kind of error.

func (ErrFilePathInvalid) Error added in v1.9.0

func (err ErrFilePathInvalid) Error() string

type ErrFilePathProtected added in v1.12.0

type ErrFilePathProtected struct {
	Message string
	Path    string
}

ErrFilePathProtected represents a "FilePathProtected" kind of error.

func (ErrFilePathProtected) Error added in v1.12.0

func (err ErrFilePathProtected) Error() string

type ErrFilenameInvalid added in v1.9.0

type ErrFilenameInvalid struct {
	Path string
}

ErrFilenameInvalid represents a "FilenameInvalid" kind of error.

func (ErrFilenameInvalid) Error added in v1.9.0

func (err ErrFilenameInvalid) Error() string

type ErrForbiddenIssueReaction added in v1.11.0

type ErrForbiddenIssueReaction struct {
	Reaction string
}

ErrForbiddenIssueReaction is used when a forbidden reaction was try to created

func (ErrForbiddenIssueReaction) Error added in v1.11.0

func (err ErrForbiddenIssueReaction) Error() string

type ErrForkAlreadyExist added in v1.9.0

type ErrForkAlreadyExist struct {
	Uname    string
	RepoName string
	ForkName string
}

ErrForkAlreadyExist represents a "ForkAlreadyExist" kind of error.

func (ErrForkAlreadyExist) Error added in v1.9.0

func (err ErrForkAlreadyExist) Error() string

type ErrInvalidCloneAddr

type ErrInvalidCloneAddr struct {
	Host               string
	IsURLError         bool
	IsInvalidPath      bool
	IsProtocolInvalid  bool
	IsPermissionDenied bool
	LocalPath          bool
}

ErrInvalidCloneAddr represents a "InvalidCloneAddr" kind of error.

func (*ErrInvalidCloneAddr) Error

func (err *ErrInvalidCloneAddr) Error() string

type ErrInvalidMergeStyle added in v1.4.0

type ErrInvalidMergeStyle struct {
	ID    int64
	Style repo_model.MergeStyle
}

ErrInvalidMergeStyle represents an error if merging with disabled merge strategy

func (ErrInvalidMergeStyle) Error added in v1.4.0

func (err ErrInvalidMergeStyle) Error() string

type ErrInvalidTagName

type ErrInvalidTagName struct {
	TagName string
}

ErrInvalidTagName represents a "InvalidTagName" kind of error.

func (ErrInvalidTagName) Error

func (err ErrInvalidTagName) Error() string

type ErrIssueIsClosed added in v1.11.0

type ErrIssueIsClosed struct {
	ID     int64
	RepoID int64
	Index  int64
}

ErrIssueIsClosed represents a "IssueIsClosed" kind of error.

func (ErrIssueIsClosed) Error added in v1.11.0

func (err ErrIssueIsClosed) Error() string

type ErrIssueLabelTemplateLoad added in v1.10.0

type ErrIssueLabelTemplateLoad struct {
	TemplateFile  string
	OriginalError error
}

ErrIssueLabelTemplateLoad represents a "ErrIssueLabelTemplateLoad" kind of error.

func (ErrIssueLabelTemplateLoad) Error added in v1.10.0

func (err ErrIssueLabelTemplateLoad) Error() string

type ErrIssueNotExist

type ErrIssueNotExist struct {
	ID     int64
	RepoID int64
	Index  int64
}

ErrIssueNotExist represents a "IssueNotExist" kind of error.

func (ErrIssueNotExist) Error

func (err ErrIssueNotExist) Error() string

type ErrIssueStopwatchAlreadyExist added in v1.15.7

type ErrIssueStopwatchAlreadyExist struct {
	UserID  int64
	IssueID int64
}

ErrIssueStopwatchAlreadyExist represents an error that stopwatch is already exist

func (ErrIssueStopwatchAlreadyExist) Error added in v1.15.7

type ErrIssueStopwatchNotExist added in v1.15.7

type ErrIssueStopwatchNotExist struct {
	UserID  int64
	IssueID int64
}

ErrIssueStopwatchNotExist represents an error that stopwatch is not exist

func (ErrIssueStopwatchNotExist) Error added in v1.15.7

func (err ErrIssueStopwatchNotExist) Error() string

type ErrIssueWasClosed added in v1.11.0

type ErrIssueWasClosed struct {
	ID    int64
	Index int64
}

ErrIssueWasClosed is used when close a closed issue

func (ErrIssueWasClosed) Error added in v1.11.0

func (err ErrIssueWasClosed) Error() string

type ErrLFSFileLocked added in v1.11.0

type ErrLFSFileLocked struct {
	RepoID   int64
	Path     string
	UserName string
}

ErrLFSFileLocked represents a "LFSFileLocked" kind of error.

func (ErrLFSFileLocked) Error added in v1.11.0

func (err ErrLFSFileLocked) Error() string

type ErrLFSLockAlreadyExist added in v1.4.0

type ErrLFSLockAlreadyExist struct {
	RepoID int64
	Path   string
}

ErrLFSLockAlreadyExist represents a "LFSLockAlreadyExist" kind of error.

func (ErrLFSLockAlreadyExist) Error added in v1.4.0

func (err ErrLFSLockAlreadyExist) Error() string

type ErrLFSLockNotExist added in v1.4.0

type ErrLFSLockNotExist struct {
	ID     int64
	RepoID int64
	Path   string
}

ErrLFSLockNotExist represents a "LFSLockNotExist" kind of error.

func (ErrLFSLockNotExist) Error added in v1.4.0

func (err ErrLFSLockNotExist) Error() string

type ErrLFSUnauthorizedAction added in v1.4.0

type ErrLFSUnauthorizedAction struct {
	RepoID   int64
	UserName string
	Mode     perm.AccessMode
}

ErrLFSUnauthorizedAction represents a "LFSUnauthorizedAction" kind of error.

func (ErrLFSUnauthorizedAction) Error added in v1.4.0

func (err ErrLFSUnauthorizedAction) Error() string

type ErrLabelNotExist

type ErrLabelNotExist struct {
	LabelID int64
}

ErrLabelNotExist represents a "LabelNotExist" kind of error.

func (ErrLabelNotExist) Error

func (err ErrLabelNotExist) Error() string

type ErrLastOrgOwner

type ErrLastOrgOwner struct {
	UID int64
}

ErrLastOrgOwner represents a "LastOrgOwner" kind of error.

func (ErrLastOrgOwner) Error

func (err ErrLastOrgOwner) Error() string

type ErrMergeConflicts added in v1.11.0

type ErrMergeConflicts struct {
	Style  repo_model.MergeStyle
	StdOut string
	StdErr string
	Err    error
}

ErrMergeConflicts represents an error if merging fails with a conflict

func (ErrMergeConflicts) Error added in v1.11.0

func (err ErrMergeConflicts) Error() string

type ErrMergeUnrelatedHistories added in v1.11.0

type ErrMergeUnrelatedHistories struct {
	Style  repo_model.MergeStyle
	StdOut string
	StdErr string
	Err    error
}

ErrMergeUnrelatedHistories represents an error if merging fails due to unrelated histories

func (ErrMergeUnrelatedHistories) Error added in v1.11.0

func (err ErrMergeUnrelatedHistories) Error() string

type ErrMilestoneNotExist

type ErrMilestoneNotExist struct {
	ID     int64
	RepoID int64
	Name   string
}

ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.

func (ErrMilestoneNotExist) Error

func (err ErrMilestoneNotExist) Error() string

type ErrNewIssueInsert added in v1.10.0

type ErrNewIssueInsert struct {
	OriginalError error
}

ErrNewIssueInsert is used when the INSERT statement in newIssue fails

func (ErrNewIssueInsert) Error added in v1.10.0

func (err ErrNewIssueInsert) Error() string

type ErrNoPendingRepoTransfer added in v1.14.0

type ErrNoPendingRepoTransfer struct {
	RepoID int64
}

ErrNoPendingRepoTransfer is an error type for repositories without a pending transfer request

func (ErrNoPendingRepoTransfer) Error added in v1.14.0

func (e ErrNoPendingRepoTransfer) Error() string

type ErrNotAllowedToMerge added in v1.5.0

type ErrNotAllowedToMerge struct {
	Reason string
}

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

func (ErrNotAllowedToMerge) Error added in v1.5.0

func (err ErrNotAllowedToMerge) Error() string

type ErrNotExist added in v1.10.0

type ErrNotExist struct {
	ID int64
}

ErrNotExist represents a non-exist error.

func (ErrNotExist) Error added in v1.10.0

func (err ErrNotExist) Error() string

type ErrNotValidReviewRequest added in v1.13.0

type ErrNotValidReviewRequest struct {
	Reason string
	UserID int64
	RepoID int64
}

ErrNotValidReviewRequest an not allowed review request modify

func (ErrNotValidReviewRequest) Error added in v1.13.0

func (err ErrNotValidReviewRequest) Error() string

type ErrOrgLabelNotExist added in v1.12.0

type ErrOrgLabelNotExist struct {
	LabelID int64
	OrgID   int64
}

ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.

func (ErrOrgLabelNotExist) Error added in v1.12.0

func (err ErrOrgLabelNotExist) Error() string

type ErrOrgNotExist

type ErrOrgNotExist struct {
	ID   int64
	Name string
}

ErrOrgNotExist represents a "OrgNotExist" kind of error.

func (ErrOrgNotExist) Error added in v1.2.0

func (err ErrOrgNotExist) Error() string

type ErrProjectBoardNotExist added in v1.13.0

type ErrProjectBoardNotExist struct {
	BoardID int64
}

ErrProjectBoardNotExist represents a "ProjectBoardNotExist" kind of error.

func (ErrProjectBoardNotExist) Error added in v1.13.0

func (err ErrProjectBoardNotExist) Error() string

type ErrProjectNotExist added in v1.13.0

type ErrProjectNotExist struct {
	ID     int64
	RepoID int64
}

ErrProjectNotExist represents a "ProjectNotExist" kind of error.

func (ErrProjectNotExist) Error added in v1.13.0

func (err ErrProjectNotExist) Error() string

type ErrProtectedTagName added in v1.15.0

type ErrProtectedTagName struct {
	TagName string
}

ErrProtectedTagName represents a "ProtectedTagName" kind of error.

func (ErrProtectedTagName) Error added in v1.15.0

func (err ErrProtectedTagName) Error() string

type ErrPullRequestAlreadyExists added in v1.0.0

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

ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error

func (ErrPullRequestAlreadyExists) Error added in v1.0.0

func (err ErrPullRequestAlreadyExists) Error() string

Error does pretty-printing :D

type ErrPullRequestHasMerged added in v1.11.0

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

ErrPullRequestHasMerged represents a "PullRequestHasMerged"-error

func (ErrPullRequestHasMerged) Error added in v1.11.0

func (err ErrPullRequestHasMerged) Error() string

Error does pretty-printing :D

type ErrPullRequestHeadRepoMissing added in v1.9.0

type ErrPullRequestHeadRepoMissing struct {
	ID         int64
	HeadRepoID int64
}

ErrPullRequestHeadRepoMissing represents a "ErrPullRequestHeadRepoMissing" error

func (ErrPullRequestHeadRepoMissing) Error added in v1.9.0

Error does pretty-printing :D

type ErrPullRequestNotExist

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

ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.

func (ErrPullRequestNotExist) Error

func (err ErrPullRequestNotExist) Error() string

type ErrPullWasClosed added in v1.11.0

type ErrPullWasClosed struct {
	ID    int64
	Index int64
}

ErrPullWasClosed is used close a closed pull request

func (ErrPullWasClosed) Error added in v1.11.0

func (err ErrPullWasClosed) Error() string

type ErrReactionAlreadyExist added in v1.10.2

type ErrReactionAlreadyExist struct {
	Reaction string
}

ErrReactionAlreadyExist is used when a existing reaction was try to created

func (ErrReactionAlreadyExist) Error added in v1.10.2

func (err ErrReactionAlreadyExist) Error() string

type ErrRebaseConflicts added in v1.11.0

type ErrRebaseConflicts struct {
	Style     repo_model.MergeStyle
	CommitSHA string
	StdOut    string
	StdErr    string
	Err       error
}

ErrRebaseConflicts represents an error if rebase fails with a conflict

func (ErrRebaseConflicts) Error added in v1.11.0

func (err ErrRebaseConflicts) Error() string

type ErrReleaseAlreadyExist

type ErrReleaseAlreadyExist struct {
	TagName string
}

ErrReleaseAlreadyExist represents a "ReleaseAlreadyExist" kind of error.

func (ErrReleaseAlreadyExist) Error

func (err ErrReleaseAlreadyExist) Error() string

type ErrReleaseNotExist

type ErrReleaseNotExist struct {
	ID      int64
	TagName string
}

ErrReleaseNotExist represents a "ReleaseNotExist" kind of error.

func (ErrReleaseNotExist) Error

func (err ErrReleaseNotExist) Error() string

type ErrRepoFileAlreadyExists added in v1.9.0

type ErrRepoFileAlreadyExists struct {
	Path string
}

ErrRepoFileAlreadyExists represents a "RepoFileAlreadyExist" kind of error.

func (ErrRepoFileAlreadyExists) Error added in v1.9.0

func (err ErrRepoFileAlreadyExists) Error() string

type ErrRepoFileDoesNotExist added in v1.9.0

type ErrRepoFileDoesNotExist struct {
	Path string
	Name string
}

ErrRepoFileDoesNotExist represents a "RepoFileDoesNotExist" kind of error.

func (ErrRepoFileDoesNotExist) Error added in v1.9.0

func (err ErrRepoFileDoesNotExist) Error() string

type ErrRepoLabelNotExist added in v1.12.0

type ErrRepoLabelNotExist struct {
	LabelID int64
	RepoID  int64
}

ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.

func (ErrRepoLabelNotExist) Error added in v1.12.0

func (err ErrRepoLabelNotExist) Error() string

type ErrRepoTransferInProgress added in v1.14.0

type ErrRepoTransferInProgress struct {
	Uname string
	Name  string
}

ErrRepoTransferInProgress represents the state of a repository that has an ongoing transfer

func (ErrRepoTransferInProgress) Error added in v1.14.0

func (err ErrRepoTransferInProgress) Error() string

type ErrReviewNotExist added in v1.6.0

type ErrReviewNotExist struct {
	ID int64
}

ErrReviewNotExist represents a "ReviewNotExist" kind of error.

func (ErrReviewNotExist) Error added in v1.6.0

func (err ErrReviewNotExist) Error() string

type ErrSHADoesNotMatch added in v1.9.0

type ErrSHADoesNotMatch struct {
	Path       string
	GivenSHA   string
	CurrentSHA string
}

ErrSHADoesNotMatch represents a "SHADoesNotMatch" kind of error.

func (ErrSHADoesNotMatch) Error added in v1.9.0

func (err ErrSHADoesNotMatch) Error() string

type ErrSHANotFound added in v1.9.0

type ErrSHANotFound struct {
	SHA string
}

ErrSHANotFound represents a "SHADoesNotMatch" kind of error.

func (ErrSHANotFound) Error added in v1.9.0

func (err ErrSHANotFound) Error() string

type ErrSHAOrCommitIDNotProvided added in v1.9.0

type ErrSHAOrCommitIDNotProvided struct{}

ErrSHAOrCommitIDNotProvided represents a "SHAOrCommitIDNotProvided" kind of error.

func (ErrSHAOrCommitIDNotProvided) Error added in v1.9.0

func (err ErrSHAOrCommitIDNotProvided) Error() string

type ErrStopwatchNotExist added in v1.3.0

type ErrStopwatchNotExist struct {
	ID int64
}

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

func (ErrStopwatchNotExist) Error added in v1.3.0

func (err ErrStopwatchNotExist) Error() string

type ErrTagAlreadyExists added in v1.3.0

type ErrTagAlreadyExists struct {
	TagName string
}

ErrTagAlreadyExists represents an error that tag with such name already exists.

func (ErrTagAlreadyExists) Error added in v1.3.0

func (err ErrTagAlreadyExists) Error() string

type ErrTaskDoesNotExist added in v1.10.0

type ErrTaskDoesNotExist struct {
	ID     int64
	RepoID int64
	Type   structs.TaskType
}

ErrTaskDoesNotExist represents a "TaskDoesNotExist" kind of error.

func (ErrTaskDoesNotExist) Error added in v1.10.0

func (err ErrTaskDoesNotExist) Error() string

type ErrTeamAlreadyExist

type ErrTeamAlreadyExist struct {
	OrgID int64
	Name  string
}

ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.

func (ErrTeamAlreadyExist) Error

func (err ErrTeamAlreadyExist) Error() string

type ErrTeamNotExist

type ErrTeamNotExist struct {
	OrgID  int64
	TeamID int64
	Name   string
}

ErrTeamNotExist represents a "TeamNotExist" error

func (ErrTeamNotExist) Error added in v1.10.0

func (err ErrTeamNotExist) Error() string

type ErrTrackedTimeNotExist added in v1.3.0

type ErrTrackedTimeNotExist struct {
	ID int64
}

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

func (ErrTrackedTimeNotExist) Error added in v1.3.0

func (err ErrTrackedTimeNotExist) Error() string

type ErrUnknownDependencyType added in v1.6.0

type ErrUnknownDependencyType struct {
	Type DependencyType
}

ErrUnknownDependencyType represents an error where an unknown dependency type was passed

func (ErrUnknownDependencyType) Error added in v1.6.0

func (err ErrUnknownDependencyType) Error() string

type ErrUpdateTaskNotExist

type ErrUpdateTaskNotExist struct {
	UUID string
}

ErrUpdateTaskNotExist represents a "UpdateTaskNotExist" kind of error.

func (ErrUpdateTaskNotExist) Error

func (err ErrUpdateTaskNotExist) Error() string

type ErrUploadNotExist

type ErrUploadNotExist struct {
	ID   int64
	UUID string
}

ErrUploadNotExist represents a "UploadNotExist" kind of error.

func (ErrUploadNotExist) Error

func (err ErrUploadNotExist) Error() string

type ErrUserCannotCommit added in v1.9.0

type ErrUserCannotCommit struct {
	UserName string
}

ErrUserCannotCommit represents "UserCannotCommit" kind of error.

func (ErrUserCannotCommit) Error added in v1.9.0

func (err ErrUserCannotCommit) Error() string

type ErrUserDoesNotHaveAccessToRepo added in v1.5.0

type ErrUserDoesNotHaveAccessToRepo struct {
	UserID   int64
	RepoName string
}

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

func (ErrUserDoesNotHaveAccessToRepo) Error added in v1.5.0

type ErrUserHasOrgs

type ErrUserHasOrgs struct {
	UID int64
}

ErrUserHasOrgs represents a "UserHasOrgs" kind of error.

func (ErrUserHasOrgs) Error

func (err ErrUserHasOrgs) Error() string

type ErrUserNotAllowedCreateOrg added in v1.1.0

type ErrUserNotAllowedCreateOrg struct{}

ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.

func (ErrUserNotAllowedCreateOrg) Error added in v1.1.0

func (err ErrUserNotAllowedCreateOrg) Error() string

type ErrUserOwnRepos

type ErrUserOwnRepos struct {
	UID int64
}

ErrUserOwnRepos represents a "UserOwnRepos" kind of error.

func (ErrUserOwnRepos) Error

func (err ErrUserOwnRepos) Error() string

type ErrWikiAlreadyExist

type ErrWikiAlreadyExist struct {
	Title string
}

ErrWikiAlreadyExist represents a "WikiAlreadyExist" kind of error.

func (ErrWikiAlreadyExist) Error

func (err ErrWikiAlreadyExist) Error() string

type ErrWikiInvalidFileName added in v1.4.0

type ErrWikiInvalidFileName struct {
	FileName string
}

ErrWikiInvalidFileName represents an invalid wiki file name.

func (ErrWikiInvalidFileName) Error added in v1.4.0

func (err ErrWikiInvalidFileName) Error() string

type ErrWikiReservedName added in v1.4.0

type ErrWikiReservedName struct {
	Title string
}

ErrWikiReservedName represents a reserved name error.

func (ErrWikiReservedName) Error added in v1.4.0

func (err ErrWikiReservedName) Error() string

type FindCommentsOptions added in v1.2.0

type FindCommentsOptions struct {
	db.ListOptions
	RepoID   int64
	IssueID  int64
	ReviewID int64
	Since    int64
	Before   int64
	Line     int64
	TreePath string
	Type     CommentType
}

FindCommentsOptions describes the conditions to Find comments

type FindNotificationOptions added in v1.12.0

type FindNotificationOptions struct {
	db.ListOptions
	UserID            int64
	RepoID            int64
	IssueID           int64
	Status            []NotificationStatus
	Source            []NotificationSource
	UpdatedAfterUnix  int64
	UpdatedBeforeUnix int64
}

FindNotificationOptions represent the filters for notifications. If an ID is 0 it will be ignored.

func (*FindNotificationOptions) ToCond added in v1.12.0

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

ToCond will convert each condition into a xorm-Cond

func (*FindNotificationOptions) ToSession added in v1.12.0

func (opts *FindNotificationOptions) ToSession(e db.Engine) *xorm.Session

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

type FindOrgMembersOpts added in v1.11.0

type FindOrgMembersOpts struct {
	db.ListOptions
	OrgID      int64
	PublicOnly bool
}

FindOrgMembersOpts represensts find org members conditions

type FindOrgOptions added in v1.16.0

type FindOrgOptions struct {
	db.ListOptions
	UserID         int64
	IncludePrivate bool
}

FindOrgOptions finds orgs options

type FindReactionsOptions added in v1.4.0

type FindReactionsOptions struct {
	db.ListOptions
	IssueID   int64
	CommentID int64
	UserID    int64
	Reaction  string
}

FindReactionsOptions describes the conditions to Find reactions

type FindReleasesOptions added in v1.2.0

type FindReleasesOptions struct {
	db.ListOptions
	IncludeDrafts bool
	IncludeTags   bool
	IsPreRelease  util.OptionalBool
	IsDraft       util.OptionalBool
	TagNames      []string
}

FindReleasesOptions describes the conditions to Find releases

type FindReviewOptions added in v1.6.0

type FindReviewOptions struct {
	db.ListOptions
	Type         ReviewType
	IssueID      int64
	ReviewerID   int64
	OfficialOnly bool
}

FindReviewOptions represent possible filters to find reviews

type FindTaskOptions added in v1.10.0

type FindTaskOptions struct {
	Status int
}

FindTaskOptions find all tasks

func (FindTaskOptions) ToConds added in v1.10.0

func (opts FindTaskOptions) ToConds() builder.Cond

ToConds generates conditions for database operation.

type FindTrackedTimesOptions added in v1.3.0

type FindTrackedTimesOptions struct {
	db.ListOptions
	IssueID           int64
	UserID            int64
	RepositoryID      int64
	MilestoneID       int64
	CreatedAfterUnix  int64
	CreatedBeforeUnix int64
}

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

type GenerateRepoOptions added in v1.11.0

type GenerateRepoOptions struct {
	Name        string
	Description string
	Private     bool
	GitContent  bool
	Topics      bool
	GitHooks    bool
	Webhooks    bool
	Avatar      bool
	IssueLabels bool
}

GenerateRepoOptions contains the template units to generate

func (GenerateRepoOptions) IsValid added in v1.11.0

func (gro GenerateRepoOptions) IsValid() bool

IsValid checks whether at least one option is chosen for generation

type GetFeedsOptions added in v1.2.0

type GetFeedsOptions struct {
	RequestedUser   *user_model.User // the user we want activity for
	RequestedTeam   *Team            // the team we want activity for
	Actor           *user_model.User // the user viewing the activity
	IncludePrivate  bool             // include private actions
	OnlyPerformedBy bool             // only actions performed by requested user
	IncludeDeleted  bool             // include deleted actions
	Date            string           // the day we want activity for: YYYY-MM-DD
}

GetFeedsOptions options for retrieving feeds

type GetMilestonesOption added in v1.13.0

type GetMilestonesOption struct {
	db.ListOptions
	RepoID   int64
	State    api.StateType
	Name     string
	SortType string
}

GetMilestonesOption contain options to get milestones

type GetUserTeamOptions added in v1.16.1

type GetUserTeamOptions struct {
	db.ListOptions
	UserID int64
}

GetUserTeamOptions holds the search options.

type GiteaTemplate added in v1.11.0

type GiteaTemplate struct {
	Path    string
	Content []byte
	// contains filtered or unexported fields
}

GiteaTemplate holds information about a .gitea/template file

func (GiteaTemplate) Globs added in v1.11.0

func (gt GiteaTemplate) Globs() []glob.Glob

Globs parses the .gitea/template globs or returns them if they were already parsed

type Issue

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

	DeadlineUnix timeutil.TimeStamp `xorm:"INDEX"`

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

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

	// IsLocked limits commenting abilities to users on an issue
	// with write access
	IsLocked bool `xorm:"NOT NULL DEFAULT false"`

	// For view issue page.
	ShowRole RoleDescriptor `xorm:"-"`
}

Issue represents an issue or pull request of repository.

func GetIssueByID

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

GetIssueByID returns an issue by given ID.

func GetIssueByIndex

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

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

func GetIssueWithAttrsByID added in v1.7.0

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

GetIssueWithAttrsByID returns an issue with attributes by given ID.

func GetIssueWithAttrsByIndex added in v1.7.0

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

GetIssueWithAttrsByIndex returns issue by index in a repository.

func GetIssuesByIDs added in v1.2.0

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

GetIssuesByIDs return issues with the given IDs.

func Issues

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

Issues returns a list of issues by given conditions.

func (*Issue) APIURL added in v1.1.0

func (issue *Issue) APIURL() string

APIURL returns the absolute APIURL to this issue.

func (*Issue) BlockedByDependencies added in v1.6.0

func (issue *Issue) BlockedByDependencies() ([]*DependencyInfo, error)

BlockedByDependencies finds all Dependencies an issue is blocked by

func (*Issue) BlockingDependencies added in v1.6.0

func (issue *Issue) BlockingDependencies() ([]*DependencyInfo, error)

BlockingDependencies returns all blocking dependencies, aka all other issues a given issue blocks

func (*Issue) ChangeContent

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

ChangeContent changes issue content, as the given user.

func (*Issue) ChangeRef added in v1.13.0

func (issue *Issue) ChangeRef(doer *user_model.User, oldRef string) (err error)

ChangeRef changes the branch of this issue, as the given user.

func (*Issue) ChangeStatus

func (issue *Issue) ChangeStatus(doer *user_model.User, isClosed bool) (*Comment, error)

ChangeStatus changes issue status to open or closed.

func (*Issue) ChangeTitle

func (issue *Issue) ChangeTitle(doer *user_model.User, oldTitle string) (err error)

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

func (*Issue) ClearLabels

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

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

func (*Issue) DiffURL added in v1.0.0

func (issue *Issue) DiffURL() string

DiffURL returns the absolute URL to this diff

func (*Issue) FindAndUpdateIssueMentions added in v1.13.2

func (issue *Issue) FindAndUpdateIssueMentions(ctx context.Context, doer *user_model.User, content string) (mentions []*user_model.User, err error)

FindAndUpdateIssueMentions finds users mentioned in the given content string, and saves them in the database.

func (*Issue) GetIsRead added in v1.1.0

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

GetIsRead load the `IsRead` field of the issue

func (*Issue) GetLastComment added in v1.12.0

func (issue *Issue) GetLastComment() (*Comment, error)

GetLastComment return last comment for the current issue.

func (*Issue) GetLastEventLabel added in v1.8.0

func (issue *Issue) GetLastEventLabel() string

GetLastEventLabel returns the localization label for the current issue.

func (*Issue) GetLastEventLabelFake added in v1.9.0

func (issue *Issue) GetLastEventLabelFake() string

GetLastEventLabelFake returns the localization label for the current issue without providing a link in the username.

func (*Issue) GetLastEventTimestamp added in v1.8.0

func (issue *Issue) GetLastEventTimestamp() timeutil.TimeStamp

GetLastEventTimestamp returns the last user visible event timestamp, either the creation of this issue or the close.

func (*Issue) GetPullRequest added in v1.1.0

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

GetPullRequest returns the issue pull request

func (*Issue) GetTasks added in v1.4.0

func (issue *Issue) GetTasks() int

GetTasks returns the amount of tasks in the issues content

func (*Issue) GetTasksDone added in v1.4.0

func (issue *Issue) GetTasksDone() int

GetTasksDone returns the amount of completed tasks in the issues content

func (*Issue) HTMLURL

func (issue *Issue) HTMLURL() string

HTMLURL returns the absolute URL to this issue.

func (*Issue) HasLabel

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

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

func (*Issue) HashTag

func (issue *Issue) HashTag() string

HashTag returns unique hash tag for issue.

func (*Issue) IsOverdue added in v1.5.0

func (issue *Issue) IsOverdue() bool

IsOverdue checks if the issue is overdue

func (*Issue) IsPoster

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

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

func (*Issue) IsTimetrackerEnabled added in v1.5.0

func (issue *Issue) IsTimetrackerEnabled() bool

IsTimetrackerEnabled returns true if the repo enables timetracking

func (issue *Issue) Link() string

Link returns the Link URL to this issue.

func (*Issue) LoadAssignees added in v1.12.0

func (issue *Issue) LoadAssignees() error

LoadAssignees load assignees of this issue.

func (*Issue) LoadAttributes

func (issue *Issue) LoadAttributes() error

LoadAttributes loads the attribute of this issue.

func (*Issue) LoadDiscussComments added in v1.8.0

func (issue *Issue) LoadDiscussComments() error

LoadDiscussComments loads discuss comments

func (*Issue) LoadLabels added in v1.12.0

func (issue *Issue) LoadLabels() error

LoadLabels loads labels

func (*Issue) LoadMilestone added in v1.10.2

func (issue *Issue) LoadMilestone() error

LoadMilestone load milestone of this issue.

func (*Issue) LoadPoster added in v1.7.0

func (issue *Issue) LoadPoster() error

LoadPoster loads poster

func (*Issue) LoadProject added in v1.13.0

func (i *Issue) LoadProject() (err error)

LoadProject load the project the issue was assigned to

func (*Issue) LoadPullRequest added in v1.7.0

func (issue *Issue) LoadPullRequest() error

LoadPullRequest loads pull request info

func (*Issue) LoadRepo added in v1.7.0

func (issue *Issue) LoadRepo() error

LoadRepo loads issue's repository

func (*Issue) PatchURL added in v1.0.0

func (issue *Issue) PatchURL() string

PatchURL returns the absolute URL to this patch

func (*Issue) ProjectBoardID added in v1.13.0

func (i *Issue) ProjectBoardID() int64

ProjectBoardID return project board id if issue was assigned to one

func (*Issue) ProjectID added in v1.13.0

func (i *Issue) ProjectID() int64

ProjectID return project id if issue was assigned to one

func (*Issue) ReadBy

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

ReadBy sets issue to be read by given user.

func (*Issue) ReplaceLabels

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

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

func (*Issue) ResolveMentionsByVisibility added in v1.9.5

func (issue *Issue) ResolveMentionsByVisibility(ctx context.Context, doer *user_model.User, mentions []string) (users []*user_model.User, err error)

ResolveMentionsByVisibility returns the users mentioned in an issue, removing those that don't have access to reading it. Teams are expanded into their users, but organizations are ignored.

func (*Issue) State

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

State returns string representation of issue status.

func (*Issue) ToggleAssignee added in v1.11.0

func (issue *Issue) ToggleAssignee(doer *user_model.User, assigneeID int64) (removed bool, comment *Comment, err error)

ToggleAssignee changes a user between assigned and not assigned for this issue, and make issue comment for it.

func (*Issue) UpdateAttachments added in v1.11.0

func (issue *Issue) UpdateAttachments(uuids []string) (err error)

UpdateAttachments update attachments by UUIDs for the issue

type IssueAssignees added in v1.5.0

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

IssueAssignees saves all issue assignees

type IssueByLabelCount added in v1.16.0

type IssueByLabelCount struct {
	Count int64
	Label string
}

IssueByLabelCount contains the number of issue group by label

type IssueByRepositoryCount added in v1.16.0

type IssueByRepositoryCount struct {
	Count      int64
	OwnerName  string
	Repository string
}

IssueByRepositoryCount contains the number of issue group by repository

type IssueDependency added in v1.6.0

type IssueDependency struct {
	ID           int64              `xorm:"pk autoincr"`
	UserID       int64              `xorm:"NOT NULL"`
	IssueID      int64              `xorm:"UNIQUE(issue_dependency) NOT NULL"`
	DependencyID int64              `xorm:"UNIQUE(issue_dependency) NOT NULL"`
	CreatedUnix  timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix  timeutil.TimeStamp `xorm:"updated"`
}

IssueDependency represents an issue dependency

type IssueIndex added in v1.15.0

type IssueIndex db.ResourceIndex

IssueIndex represents the issue index table

type IssueLabel

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

IssueLabel represents an issue-label relation.

type IssueList added in v1.1.0

type IssueList []*Issue

IssueList defines a list of issues

func (IssueList) GetApprovalCounts added in v1.12.0

func (issues IssueList) GetApprovalCounts() (map[int64][]*ReviewCount, error)

GetApprovalCounts returns a map of issue ID to slice of approval counts FIXME: only returns official counts due to double counting of non-official approvals

func (IssueList) LoadAttachments added in v1.4.0

func (issues IssueList) LoadAttachments() error

LoadAttachments loads attachments

func (IssueList) LoadAttributes added in v1.1.0

func (issues IssueList) LoadAttributes() error

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

func (IssueList) LoadComments added in v1.4.0

func (issues IssueList) LoadComments() error

LoadComments loads comments

func (IssueList) LoadDiscussComments added in v1.8.0

func (issues IssueList) LoadDiscussComments() error

LoadDiscussComments loads discuss comments

func (IssueList) LoadPullRequests added in v1.14.1

func (issues IssueList) LoadPullRequests() error

LoadPullRequests loads pull requests

func (IssueList) LoadRepositories added in v1.1.0

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

LoadRepositories loads issues' all repositories

type IssueLockOptions added in v1.8.0

type IssueLockOptions struct {
	Doer   *user_model.User
	Issue  *Issue
	Reason string
}

IssueLockOptions defines options for locking and/or unlocking an issue/PR

type IssueStats

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

IssueStats represents issue statistic information.

func GetIssueStats

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

GetIssueStats returns issue statistic information by given conditions.

func GetUserIssueStats

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

GetUserIssueStats returns issue statistic information for dashboard by given conditions.

type IssueStatsOptions

type IssueStatsOptions struct {
	RepoID            int64
	Labels            string
	MilestoneID       int64
	AssigneeID        int64
	MentionedID       int64
	PosterID          int64
	ReviewRequestedID int64
	IsPull            util.OptionalBool
	IssueIDs          []int64
}

IssueStatsOptions contains parameters accepted by GetIssueStats.

type IssueUser

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

IssueUser represents an issue-user relation.

type IssueWatch added in v1.2.0

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

IssueWatch is connection request for receiving issue notification.

func GetIssueWatch added in v1.2.0

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

GetIssueWatch returns all IssueWatch objects from db by user and issue the current Web-UI need iw object for watchers AND explicit non-watchers

type IssueWatchList added in v1.11.0

type IssueWatchList []*IssueWatch

IssueWatchList contains IssueWatch

func GetIssueWatchers added in v1.2.0

func GetIssueWatchers(issueID int64, listOptions db.ListOptions) (IssueWatchList, error)

GetIssueWatchers returns watchers/unwatchers of a given issue

type IssuesOptions

type IssuesOptions struct {
	db.ListOptions
	RepoID             int64 // overwrites RepoCond if not 0
	RepoCond           builder.Cond
	AssigneeID         int64
	PosterID           int64
	MentionedID        int64
	ReviewRequestedID  int64
	MilestoneIDs       []int64
	ProjectID          int64
	ProjectBoardID     int64
	IsClosed           util.OptionalBool
	IsPull             util.OptionalBool
	LabelIDs           []int64
	IncludedLabelNames []string
	ExcludedLabelNames []string
	IncludeMilestones  []string
	SortType           string
	IssueIDs           []int64
	UpdatedAfterUnix   int64
	UpdatedBeforeUnix  int64
	// prioritize issues from this repo
	PriorityRepoID int64
	IsArchived     util.OptionalBool
	Org            *Organization    // issues permission scope
	Team           *Team            // issues permission scope
	User           *user_model.User // issues permission scope
}

IssuesOptions represents options of an issue.

type LFSLock added in v1.4.0

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

LFSLock represents a git lfs lock of repository.

func CreateLFSLock added in v1.4.0

func CreateLFSLock(repo *repo_model.Repository, lock *LFSLock) (*LFSLock, error)

CreateLFSLock creates a new lock.

func DeleteLFSLockByID added in v1.4.0

func DeleteLFSLockByID(id int64, repo *repo_model.Repository, u *user_model.User, force bool) (*LFSLock, error)

DeleteLFSLockByID deletes a lock by given ID.

func GetLFSLock added in v1.4.0

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

GetLFSLock returns release by given path.

func GetLFSLockByID added in v1.4.0

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

GetLFSLockByID returns release by given id.

func GetLFSLockByRepoID added in v1.4.0

func GetLFSLockByRepoID(repoID int64, page, pageSize int) ([]*LFSLock, error)

GetLFSLockByRepoID returns a list of locks of repository.

func GetTreePathLock added in v1.16.0

func GetTreePathLock(repoID int64, treePath string) (*LFSLock, error)

GetTreePathLock returns LSF lock for the treePath

func (*LFSLock) BeforeInsert added in v1.4.0

func (l *LFSLock) BeforeInsert()

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

type LFSMetaObject added in v1.1.0

type LFSMetaObject struct {
	ID           int64 `xorm:"pk autoincr"`
	lfs.Pointer  `xorm:"extends"`
	RepositoryID int64              `xorm:"UNIQUE(s) INDEX NOT NULL"`
	Existing     bool               `xorm:"-"`
	CreatedUnix  timeutil.TimeStamp `xorm:"created"`
}

LFSMetaObject stores metadata for LFS tracked files.

func GetLFSMetaObjectByOid added in v1.1.0

func GetLFSMetaObjectByOid(repoID int64, oid string) (*LFSMetaObject, error)

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

func GetLFSMetaObjects added in v1.16.0

func GetLFSMetaObjects(repoID int64, page, pageSize int) ([]*LFSMetaObject, error)

GetLFSMetaObjects returns all LFSMetaObjects associated with a repository

func NewLFSMetaObject added in v1.1.0

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

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

type LFSTokenResponse added in v1.1.0

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

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

type Label

type Label struct {
	ID              int64 `xorm:"pk autoincr"`
	RepoID          int64 `xorm:"INDEX"`
	OrgID           int64 `xorm:"INDEX"`
	Name            string
	Description     string
	Color           string `xorm:"VARCHAR(7)"`
	NumIssues       int
	NumClosedIssues int
	CreatedUnix     timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix     timeutil.TimeStamp `xorm:"INDEX updated"`

	NumOpenIssues     int    `xorm:"-"`
	NumOpenRepoIssues int64  `xorm:"-"`
	IsChecked         bool   `xorm:"-"`
	QueryString       string `xorm:"-"`
	IsSelected        bool   `xorm:"-"`
	IsExcluded        bool   `xorm:"-"`
}

Label represents a label of repository for issues.

func GetLabelByID

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

GetLabelByID returns a label by given ID.

func GetLabelInOrgByID added in v1.12.0

func GetLabelInOrgByID(orgID, labelID int64) (*Label, error)

GetLabelInOrgByID returns a label by ID in given organization.

func GetLabelInOrgByName added in v1.12.0

func GetLabelInOrgByName(orgID int64, labelName string) (*Label, error)

GetLabelInOrgByName returns a label by name in given organization.

func GetLabelInRepoByID

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

GetLabelInRepoByID returns a label by ID in given repository.

func GetLabelInRepoByName added in v1.0.0

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

GetLabelInRepoByName returns a label by name in given repository.

func GetLabelsByIDs added in v1.12.0

func GetLabelsByIDs(labelIDs []int64) ([]*Label, error)

GetLabelsByIDs returns a list of labels by IDs

func GetLabelsByIssueID

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

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

func GetLabelsByOrgID added in v1.12.0

func GetLabelsByOrgID(orgID int64, sortType string, listOptions db.ListOptions) ([]*Label, error)

GetLabelsByOrgID returns all labels that belong to given organization by ID.

func GetLabelsByRepoID

func GetLabelsByRepoID(repoID int64, sortType string, listOptions db.ListOptions) ([]*Label, error)

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

func GetLabelsInOrgByIDs added in v1.12.0

func GetLabelsInOrgByIDs(orgID int64, labelIDs []int64) ([]*Label, error)

GetLabelsInOrgByIDs returns a list of labels by IDs in given organization, it silently ignores label IDs that do not belong to the organization.

func GetLabelsInRepoByIDs

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

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

func (*Label) BelongsToOrg added in v1.12.0

func (label *Label) BelongsToOrg() bool

BelongsToOrg returns true if label is an organization label

func (*Label) BelongsToRepo added in v1.12.0

func (label *Label) BelongsToRepo() bool

BelongsToRepo returns true if label is a repository label

func (*Label) CalOpenIssues

func (label *Label) CalOpenIssues()

CalOpenIssues sets the number of open issues of a label based on the already stored number of closed issues.

func (*Label) CalOpenOrgIssues added in v1.12.0

func (label *Label) CalOpenOrgIssues(repoID, labelID int64)

CalOpenOrgIssues calculates the open issues of a label for a specific repo

func (*Label) ForegroundColor

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

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

func (*Label) LoadSelectedLabelsAfterClick added in v1.8.0

func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64)

LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked

type ListAccessTokensOptions added in v1.13.0

type ListAccessTokensOptions struct {
	db.ListOptions
	Name   string
	UserID int64
}

ListAccessTokensOptions contain filter options

type Milestone

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

	CreatedUnix    timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix    timeutil.TimeStamp `xorm:"INDEX updated"`
	DeadlineUnix   timeutil.TimeStamp
	ClosedDateUnix timeutil.TimeStamp
	DeadlineString string `xorm:"-"`

	TotalTrackedTime int64 `xorm:"-"`
	TimeSinceUpdate  int64 `xorm:"-"`
}

Milestone represents a milestone of repository.

func GetMilestoneByRepoID

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

GetMilestoneByRepoID returns the milestone in a repository.

func GetMilestoneByRepoIDANDName added in v1.12.0

func GetMilestoneByRepoIDANDName(repoID int64, name string) (*Milestone, error)

GetMilestoneByRepoIDANDName return a milestone if one exist by name and repo

func (*Milestone) AfterLoad added in v1.3.0

func (m *Milestone) AfterLoad()

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

func (*Milestone) BeforeUpdate

func (m *Milestone) BeforeUpdate()

BeforeUpdate is invoked from XORM before updating this object.

func (*Milestone) LoadTotalTrackedTime added in v1.11.0

func (m *Milestone) LoadTotalTrackedTime() error

LoadTotalTrackedTime loads the tracked time for the milestone

func (*Milestone) State

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

State returns string representation of milestone status.

type MilestoneList added in v1.5.0

type MilestoneList []*Milestone

MilestoneList is a list of milestones offering additional functionality

func GetMilestones

func GetMilestones(opts GetMilestonesOption) (MilestoneList, int64, error)

GetMilestones returns milestones filtered by GetMilestonesOption's

func GetMilestonesByRepoIDs added in v1.11.0

func GetMilestonesByRepoIDs(repoIDs []int64, page int, isClosed bool, sortType string) (MilestoneList, error)

GetMilestonesByRepoIDs returns a list of milestones of given repositories and status.

func SearchMilestones added in v1.11.4

func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error)

SearchMilestones search milestones

func (MilestoneList) LoadTotalTrackedTimes added in v1.5.0

func (milestones MilestoneList) LoadTotalTrackedTimes() error

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

type MilestonesStats added in v1.11.0

type MilestonesStats struct {
	OpenCount, ClosedCount int64
}

MilestonesStats represents milestone statistic information.

func GetMilestonesStatsByRepoCond added in v1.12.0

func GetMilestonesStatsByRepoCond(repoCond builder.Cond) (*MilestonesStats, error)

GetMilestonesStatsByRepoCond returns milestone statistic information for dashboard by given conditions.

func GetMilestonesStatsByRepoCondAndKw added in v1.15.0

func GetMilestonesStatsByRepoCondAndKw(repoCond builder.Cond, keyword string) (*MilestonesStats, error)

GetMilestonesStatsByRepoCondAndKw returns milestone statistic information for dashboard by given repo conditions and name keyword.

func (MilestonesStats) Total added in v1.11.4

func (m MilestonesStats) Total() int64

Total returns the total counts of milestones

type MinimalOrg added in v1.15.0

type MinimalOrg = Organization

MinimalOrg represents a simple orgnization with only needed columns

func GetUserOrgsList added in v1.15.0

func GetUserOrgsList(user *user_model.User) ([]*MinimalOrg, error)

GetUserOrgsList returns one user's all orgs list

type NewCommitStatusOptions added in v1.2.0

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

NewCommitStatusOptions holds options for creating a CommitStatus

type NewIssueOptions

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

NewIssueOptions represents the options of a new issue.

type Notification added in v1.1.0

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

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

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

	UpdatedBy int64 `xorm:"INDEX NOT NULL"`

	Issue      *Issue                 `xorm:"-"`
	Repository *repo_model.Repository `xorm:"-"`
	Comment    *Comment               `xorm:"-"`
	User       *user_model.User       `xorm:"-"`

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

Notification represents a notification

func GetNotificationByID added in v1.12.0

func GetNotificationByID(notificationID int64) (*Notification, error)

GetNotificationByID return notification by ID

func SetNotificationStatus added in v1.1.0

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

SetNotificationStatus change the notification status

func (*Notification) APIURL added in v1.12.0

func (n *Notification) APIURL() string

APIURL formats a URL-string to the notification

func (*Notification) GetIssue added in v1.1.0

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

GetIssue returns the issue of the notification

func (*Notification) GetRepo added in v1.1.0

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

GetRepo returns the repo of the notification

func (*Notification) HTMLURL added in v1.11.0

func (n *Notification) HTMLURL() string

HTMLURL formats a URL-string to the notification

func (*Notification) LoadAttributes added in v1.12.0

func (n *Notification) LoadAttributes() (err error)

LoadAttributes load Repo Issue User and Comment if not loaded

type NotificationList added in v1.11.0

type NotificationList []*Notification

NotificationList contains a list of notifications

func GetNotifications added in v1.12.0

func GetNotifications(opts *FindNotificationOptions) (NotificationList, error)

GetNotifications returns all notifications that fit to the given options.

func NotificationsForUser added in v1.1.0

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

NotificationsForUser returns notifications for a given user and status

func (NotificationList) LoadAttributes added in v1.12.0

func (nl NotificationList) LoadAttributes() error

LoadAttributes load Repo Issue User and Comment if not loaded

func (NotificationList) LoadComments added in v1.11.0

func (nl NotificationList) LoadComments() ([]int, error)

LoadComments loads comments from database

func (NotificationList) LoadIssues added in v1.11.0

func (nl NotificationList) LoadIssues() ([]int, error)

LoadIssues loads issues from database

func (NotificationList) LoadRepos added in v1.11.0

func (nl NotificationList) LoadRepos() (RepositoryList, []int, error)

LoadRepos loads repositories from database

func (NotificationList) Without added in v1.11.4

func (nl NotificationList) Without(failures []int) NotificationList

Without returns the notification list without the failures

type NotificationSource added in v1.1.0

type NotificationSource uint8

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

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

type NotificationStatus added in v1.1.0

type NotificationStatus uint8

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

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

type OrgUser

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

OrgUser represents an organization-user relation.

func GetOrgUsersByOrgID

func GetOrgUsersByOrgID(opts *FindOrgMembersOpts) ([]*OrgUser, error)

GetOrgUsersByOrgID returns all organization-user relations by organization ID.

func GetOrgUsersByUserID

func GetOrgUsersByUserID(uid int64, opts *SearchOrganizationsOptions) ([]*OrgUser, error)

GetOrgUsersByUserID returns all organization-user relations by user ID.

type Organization added in v1.16.0

type Organization user_model.User

Organization represents an organization

func FindOrgs added in v1.16.0

func FindOrgs(opts FindOrgOptions) ([]*Organization, error)

FindOrgs returns a list of organizations according given conditions

func GetOrgByID added in v1.16.0

func GetOrgByID(id int64) (*Organization, error)

GetOrgByID returns the user object by given ID if exists.

func GetOrgByIDCtx added in v1.16.0

func GetOrgByIDCtx(ctx context.Context, id int64) (*Organization, error)

GetOrgByIDCtx returns the user object by given ID if exists.

func GetOrgByName

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

GetOrgByName returns organization by given name.

func GetOrgsCanCreateRepoByUserID added in v1.11.0

func GetOrgsCanCreateRepoByUserID(userID int64) ([]*Organization, error)

GetOrgsCanCreateRepoByUserID returns a list of organizations where given user ID are allowed to create repos.

func GetOwnedOrgsByUserID

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

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

func GetOwnedOrgsByUserIDDesc

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

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

func OrgFromUser added in v1.16.0

func OrgFromUser(user *user_model.User) *Organization

OrgFromUser converts user to organization

func (*Organization) AccessibleReposEnv added in v1.16.0

func (org *Organization) AccessibleReposEnv(userID int64) (AccessibleReposEnvironment, error)

AccessibleReposEnv builds an AccessibleReposEnvironment for the repositories in `org` that are accessible to the specified user.

func (*Organization) AccessibleTeamReposEnv added in v1.16.0

func (org *Organization) AccessibleTeamReposEnv(team *Team) AccessibleReposEnvironment

AccessibleTeamReposEnv an AccessibleReposEnvironment for the repositories in `org` that are accessible to the specified team.

func (*Organization) AddMember added in v1.16.0

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

AddMember adds new member to organization.

func (*Organization) AsUser added in v1.16.0

func (org *Organization) AsUser() *user_model.User

AsUser returns the org as user object

func (org *Organization) AvatarLink() string

AvatarLink returns the full avatar link with http host

func (*Organization) CanCreateOrgRepo added in v1.16.0

func (org *Organization) CanCreateOrgRepo(uid int64) (bool, error)

CanCreateOrgRepo returns true if given user can create repo in organization

func (*Organization) CanCreateRepo added in v1.16.0

func (org *Organization) CanCreateRepo() bool

CanCreateRepo returns if user login can create a repository NOTE: functions calling this assume a failure due to repository count limit; if new checks are added, those functions should be revised

func (*Organization) CustomAvatarRelativePath added in v1.16.0

func (org *Organization) CustomAvatarRelativePath() string

CustomAvatarRelativePath returns user custom avatar relative path.

func (*Organization) DisplayName added in v1.16.0

func (org *Organization) DisplayName() string

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

func (*Organization) GetMembers added in v1.16.0

func (org *Organization) GetMembers() (user_model.UserList, map[int64]bool, error)

GetMembers returns all members of organization.

func (*Organization) GetOrgUserMaxAuthorizeLevel added in v1.16.0

func (org *Organization) GetOrgUserMaxAuthorizeLevel(uid int64) (perm.AccessMode, error)

GetOrgUserMaxAuthorizeLevel returns highest authorize level of user in an organization

func (*Organization) GetOwnerTeam added in v1.16.0

func (org *Organization) GetOwnerTeam() (*Team, error)

GetOwnerTeam returns owner team of organization.

func (*Organization) GetTeam added in v1.16.0

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

GetTeam returns named team of organization.

func (*Organization) GetUserTeamIDs added in v1.16.0

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

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

func (*Organization) GetUserTeams added in v1.16.0

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

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

func (*Organization) HTMLURL added in v1.16.0

func (org *Organization) HTMLURL() string

HTMLURL returns the organization's full link.

func (*Organization) HasMemberWithUserID added in v1.16.0

func (org *Organization) HasMemberWithUserID(userID int64) bool

HasMemberWithUserID returns true if user with userID is part of the u organisation.

func (org *Organization) HomeLink() string

HomeLink returns the user or organization home page link.

func (*Organization) IsOrgMember added in v1.16.0

func (org *Organization) IsOrgMember(uid int64) (bool, error)

IsOrgMember returns true if given user is member of organization.

func (*Organization) IsOwnedBy added in v1.16.0

func (org *Organization) IsOwnedBy(uid int64) (bool, error)

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

func (*Organization) LoadTeams added in v1.16.0

func (org *Organization) LoadTeams() ([]*Team, error)

LoadTeams load teams if not loaded.

func (org *Organization) OrganisationLink() string

OrganisationLink returns the organization sub page link.

func (*Organization) RemoveMember added in v1.16.0

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

RemoveMember removes member from organization.

func (*Organization) RemoveOrgRepo added in v1.16.0

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

RemoveOrgRepo removes all team-repository relations of organization.

func (*Organization) ShortName added in v1.16.0

func (org *Organization) ShortName(length int) string

ShortName ellipses username to length

func (Organization) TableName added in v1.16.0

func (Organization) TableName() string

TableName represents the real table name of Organization

func (*Organization) TeamsWithAccessToRepo added in v1.16.0

func (org *Organization) TeamsWithAccessToRepo(repoID int64, mode perm.AccessMode) ([]*Team, error)

TeamsWithAccessToRepo returns all teams that have given access level to the repository.

type Permission added in v1.7.0

type Permission struct {
	AccessMode perm_model.AccessMode
	Units      []*repo_model.RepoUnit
	UnitsMode  map[unit.Type]perm_model.AccessMode
}

Permission contains all the permissions related variables to a repository for a user

func GetUserRepoPermission added in v1.7.0

func GetUserRepoPermission(repo *repo_model.Repository, user *user_model.User) (Permission, error)

GetUserRepoPermission returns the user permissions to the repository

func (*Permission) CanAccess added in v1.7.0

func (p *Permission) CanAccess(mode perm_model.AccessMode, unitType unit.Type) bool

CanAccess returns true if user has mode access to the unit of the repository

func (*Permission) CanAccessAny added in v1.7.0

func (p *Permission) CanAccessAny(mode perm_model.AccessMode, unitTypes ...unit.Type) bool

CanAccessAny returns true if user has mode access to any of the units of the repository

func (*Permission) CanRead added in v1.7.0

func (p *Permission) CanRead(unitType unit.Type) bool

CanRead returns true if user could read to this unit

func (*Permission) CanReadAny added in v1.7.0

func (p *Permission) CanReadAny(unitTypes ...unit.Type) bool

CanReadAny returns true if user has read access to any of the units of the repository

func (*Permission) CanReadIssuesOrPulls added in v1.7.0

func (p *Permission) CanReadIssuesOrPulls(isPull bool) bool

CanReadIssuesOrPulls returns true if isPull is true and user could read pull requests and returns true if isPull is false and user could read to issues

func (*Permission) CanWrite added in v1.7.0

func (p *Permission) CanWrite(unitType unit.Type) bool

CanWrite returns true if user could write to this unit

func (*Permission) CanWriteIssuesOrPulls added in v1.7.0

func (p *Permission) CanWriteIssuesOrPulls(isPull bool) bool

CanWriteIssuesOrPulls returns true if isPull is true and user could write to pull requests and returns true if isPull is false and user could write to issues

func (*Permission) ColorFormat added in v1.9.0

func (p *Permission) ColorFormat(s fmt.State)

ColorFormat writes a colored string for these Permissions

func (*Permission) HasAccess added in v1.7.0

func (p *Permission) HasAccess() bool

HasAccess returns true if the current user has at least read access to any unit of this repository

func (*Permission) IsAdmin added in v1.7.0

func (p *Permission) IsAdmin() bool

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

func (*Permission) IsOwner added in v1.7.0

func (p *Permission) IsOwner() bool

IsOwner returns true if current user is the owner of repository.

func (*Permission) UnitAccessMode added in v1.7.0

func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode

UnitAccessMode returns current user accessmode to the specify unit of the repository

type Project added in v1.13.0

type Project struct {
	ID          int64  `xorm:"pk autoincr"`
	Title       string `xorm:"INDEX NOT NULL"`
	Description string `xorm:"TEXT"`
	RepoID      int64  `xorm:"INDEX"`
	CreatorID   int64  `xorm:"NOT NULL"`
	IsClosed    bool   `xorm:"INDEX"`
	BoardType   ProjectBoardType
	Type        ProjectType

	RenderedContent string `xorm:"-"`

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

Project represents a project board

func GetProjectByID added in v1.13.0

func GetProjectByID(id int64) (*Project, error)

GetProjectByID returns the projects in a repository

func GetProjects added in v1.13.0

func GetProjects(opts ProjectSearchOptions) ([]*Project, int64, error)

GetProjects returns a list of all projects that have been created in the repository

func (*Project) NumClosedIssues added in v1.13.0

func (p *Project) NumClosedIssues() int

NumClosedIssues return counter of closed issues assigned to a project

func (*Project) NumIssues added in v1.13.0

func (p *Project) NumIssues() int

NumIssues return counter of all issues assigned to a project

func (*Project) NumOpenIssues added in v1.13.0

func (p *Project) NumOpenIssues() int

NumOpenIssues return counter of open issues assigned to a project

type ProjectBoard added in v1.13.0

type ProjectBoard struct {
	ID      int64 `xorm:"pk autoincr"`
	Title   string
	Default bool   `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific board will be assigned to this board
	Sorting int8   `xorm:"NOT NULL DEFAULT 0"`
	Color   string `xorm:"VARCHAR(7)"`

	ProjectID int64 `xorm:"INDEX NOT NULL"`
	CreatorID int64 `xorm:"NOT NULL"`

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

	Issues []*Issue `xorm:"-"`
}

ProjectBoard is used to represent boards on a project

func GetProjectBoard added in v1.13.0

func GetProjectBoard(boardID int64) (*ProjectBoard, error)

GetProjectBoard fetches the current board of a project

func (*ProjectBoard) LoadIssues added in v1.13.0

func (b *ProjectBoard) LoadIssues() (IssueList, error)

LoadIssues load issues assigned to this board

type ProjectBoardList added in v1.13.0

type ProjectBoardList []*ProjectBoard

ProjectBoardList is a list of all project boards in a repository

func GetProjectBoards added in v1.13.0

func GetProjectBoards(projectID int64) (ProjectBoardList, error)

GetProjectBoards fetches all boards related to a project if no default board set, first board is a temporary "Uncategorized" board

func (ProjectBoardList) LoadIssues added in v1.13.0

func (bs ProjectBoardList) LoadIssues() (IssueList, error)

LoadIssues load issues assigned to the boards

type ProjectBoardType added in v1.13.0

type ProjectBoardType uint8

ProjectBoardType is used to represent a project board type

const (
	// ProjectBoardTypeNone is a project board type that has no predefined columns
	ProjectBoardTypeNone ProjectBoardType = iota

	// ProjectBoardTypeBasicKanban is a project board type that has basic predefined columns
	ProjectBoardTypeBasicKanban

	// ProjectBoardTypeBugTriage is a project board type that has predefined columns suited to hunting down bugs
	ProjectBoardTypeBugTriage
)

type ProjectIssue added in v1.13.0

type ProjectIssue struct {
	ID        int64 `xorm:"pk autoincr"`
	IssueID   int64 `xorm:"INDEX"`
	ProjectID int64 `xorm:"INDEX"`

	// If 0, then it has not been added to a specific board in the project
	ProjectBoardID int64 `xorm:"INDEX"`
	Sorting        int64 `xorm:"NOT NULL DEFAULT 0"`
}

ProjectIssue saves relation from issue to a project

type ProjectSearchOptions added in v1.13.0

type ProjectSearchOptions struct {
	RepoID   int64
	Page     int
	IsClosed util.OptionalBool
	SortType string
	Type     ProjectType
}

ProjectSearchOptions are options for GetProjects

type ProjectType added in v1.13.0

type ProjectType uint8

ProjectType is used to identify the type of project in question and ownership

const (
	// ProjectTypeIndividual is a type of project board that is owned by an individual
	ProjectTypeIndividual ProjectType = iota + 1

	// ProjectTypeRepository is a project that is tied to a repository
	ProjectTypeRepository

	// ProjectTypeOrganization is a project that is tied to an organisation
	ProjectTypeOrganization
)

type ProjectsConfig added in v1.13.0

type ProjectsConfig struct {
	BoardType   ProjectBoardType
	Translation string
}

ProjectsConfig is used to identify the type of board that is being created

func GetProjectsConfig added in v1.13.0

func GetProjectsConfig() []ProjectsConfig

GetProjectsConfig retrieves the types of configurations projects could have

type ProtectedBranch added in v1.1.0

type ProtectedBranch struct {
	ID                            int64  `xorm:"pk autoincr"`
	RepoID                        int64  `xorm:"UNIQUE(s)"`
	BranchName                    string `xorm:"UNIQUE(s)"`
	CanPush                       bool   `xorm:"NOT NULL DEFAULT false"`
	EnableWhitelist               bool
	WhitelistUserIDs              []int64  `xorm:"JSON TEXT"`
	WhitelistTeamIDs              []int64  `xorm:"JSON TEXT"`
	EnableMergeWhitelist          bool     `xorm:"NOT NULL DEFAULT false"`
	WhitelistDeployKeys           bool     `xorm:"NOT NULL DEFAULT false"`
	MergeWhitelistUserIDs         []int64  `xorm:"JSON TEXT"`
	MergeWhitelistTeamIDs         []int64  `xorm:"JSON TEXT"`
	EnableStatusCheck             bool     `xorm:"NOT NULL DEFAULT false"`
	StatusCheckContexts           []string `xorm:"JSON TEXT"`
	EnableApprovalsWhitelist      bool     `xorm:"NOT NULL DEFAULT false"`
	ApprovalsWhitelistUserIDs     []int64  `xorm:"JSON TEXT"`
	ApprovalsWhitelistTeamIDs     []int64  `xorm:"JSON TEXT"`
	RequiredApprovals             int64    `xorm:"NOT NULL DEFAULT 0"`
	BlockOnRejectedReviews        bool     `xorm:"NOT NULL DEFAULT false"`
	BlockOnOfficialReviewRequests bool     `xorm:"NOT NULL DEFAULT false"`
	BlockOnOutdatedBranch         bool     `xorm:"NOT NULL DEFAULT false"`
	DismissStaleApprovals         bool     `xorm:"NOT NULL DEFAULT false"`
	RequireSignedCommits          bool     `xorm:"NOT NULL DEFAULT false"`
	ProtectedFilePatterns         string   `xorm:"TEXT"`
	UnprotectedFilePatterns       string   `xorm:"TEXT"`

	CreatedUnix timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

ProtectedBranch struct

func GetProtectedBranchBy added in v1.1.0

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

GetProtectedBranchBy getting protected branch by ID/Name

func GetProtectedBranches added in v1.16.0

func GetProtectedBranches(repoID int64) ([]*ProtectedBranch, error)

GetProtectedBranches get all protected branches

func (*ProtectedBranch) CanUserPush added in v1.3.0

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

CanUserPush returns if some user could push to this protected branch

func (*ProtectedBranch) GetGrantedApprovalsCount added in v1.7.0

func (protectBranch *ProtectedBranch) GetGrantedApprovalsCount(pr *PullRequest) int64

GetGrantedApprovalsCount returns the number of granted approvals for pr. A granted approval must be authored by a user in an approval whitelist.

func (*ProtectedBranch) GetProtectedFilePatterns added in v1.12.0

func (protectBranch *ProtectedBranch) GetProtectedFilePatterns() []glob.Glob

GetProtectedFilePatterns parses a semicolon separated list of protected file patterns and returns a glob.Glob slice

func (*ProtectedBranch) GetUnprotectedFilePatterns added in v1.16.0

func (protectBranch *ProtectedBranch) GetUnprotectedFilePatterns() []glob.Glob

GetUnprotectedFilePatterns parses a semicolon separated list of unprotected file patterns and returns a glob.Glob slice

func (*ProtectedBranch) HasEnoughApprovals added in v1.7.0

func (protectBranch *ProtectedBranch) HasEnoughApprovals(pr *PullRequest) bool

HasEnoughApprovals returns true if pr has enough granted approvals.

func (*ProtectedBranch) IsProtected added in v1.2.0

func (protectBranch *ProtectedBranch) IsProtected() bool

IsProtected returns if the branch is protected

func (*ProtectedBranch) IsProtectedFile added in v1.13.0

func (protectBranch *ProtectedBranch) IsProtectedFile(patterns []glob.Glob, path string) bool

IsProtectedFile return if path is protected

func (*ProtectedBranch) IsUnprotectedFile added in v1.16.0

func (protectBranch *ProtectedBranch) IsUnprotectedFile(patterns []glob.Glob, path string) bool

IsUnprotectedFile return if path is unprotected

func (*ProtectedBranch) MergeBlockedByOfficialReviewRequests added in v1.14.0

func (protectBranch *ProtectedBranch) MergeBlockedByOfficialReviewRequests(pr *PullRequest) bool

MergeBlockedByOfficialReviewRequests block merge because of some review request to official reviewer of from official review

func (*ProtectedBranch) MergeBlockedByOutdatedBranch added in v1.12.0

func (protectBranch *ProtectedBranch) MergeBlockedByOutdatedBranch(pr *PullRequest) bool

MergeBlockedByOutdatedBranch returns true if merge is blocked by an outdated head branch

func (*ProtectedBranch) MergeBlockedByProtectedFiles added in v1.13.0

func (protectBranch *ProtectedBranch) MergeBlockedByProtectedFiles(pr *PullRequest) bool

MergeBlockedByProtectedFiles returns true if merge is blocked by protected files change

func (*ProtectedBranch) MergeBlockedByRejectedReview added in v1.11.0

func (protectBranch *ProtectedBranch) MergeBlockedByRejectedReview(pr *PullRequest) bool

MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews

type ProtectedTag added in v1.15.0

type ProtectedTag struct {
	ID               int64 `xorm:"pk autoincr"`
	RepoID           int64
	NamePattern      string
	RegexPattern     *regexp.Regexp `xorm:"-"`
	GlobPattern      glob.Glob      `xorm:"-"`
	AllowlistUserIDs []int64        `xorm:"JSON TEXT"`
	AllowlistTeamIDs []int64        `xorm:"JSON TEXT"`

	CreatedUnix timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}

ProtectedTag struct

func GetProtectedTagByID added in v1.15.0

func GetProtectedTagByID(id int64) (*ProtectedTag, error)

GetProtectedTagByID gets the protected tag with the specific id

func GetProtectedTags added in v1.16.0

func GetProtectedTags(repoID int64) ([]*ProtectedTag, error)

GetProtectedTags gets all protected tags of the repository

func (*ProtectedTag) EnsureCompiledPattern added in v1.15.0

func (pt *ProtectedTag) EnsureCompiledPattern() error

EnsureCompiledPattern ensures the glob pattern is compiled

type PullRequest

type PullRequest struct {
	ID              int64 `xorm:"pk autoincr"`
	Type            PullRequestType
	Status          PullRequestStatus
	ConflictedFiles []string `xorm:"TEXT JSON"`
	CommitsAhead    int
	CommitsBehind   int

	ChangedProtectedFiles []string `xorm:"TEXT JSON"`

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

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

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

	Flow PullRequestFlow `xorm:"NOT NULL DEFAULT 0"`
	// contains filtered or unexported fields
}

PullRequest represents relation between pull request and repositories.

func GetAllUnmergedAgitPullRequestByPoster added in v1.16.0

func GetAllUnmergedAgitPullRequestByPoster(uid int64) ([]*PullRequest, error)

GetAllUnmergedAgitPullRequestByPoster get all unmerged agit flow pull request By poster id.

func GetLatestPullRequestByHeadInfo added in v1.9.0

func GetLatestPullRequestByHeadInfo(repoID int64, branch string) (*PullRequest, error)

GetLatestPullRequestByHeadInfo returns the latest pull request (regardless of its status) by given head information (repo and branch).

func GetPullRequestByID

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

GetPullRequestByID returns a pull request by given ID.

func GetPullRequestByIndex added in v1.0.0

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

GetPullRequestByIndex returns a pull request by the given index

func GetPullRequestByIssueID

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

GetPullRequestByIssueID returns pull request by given issue ID.

func GetPullRequestByIssueIDWithNoAttributes added in v1.12.0

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

GetPullRequestByIssueIDWithNoAttributes returns pull request with no attributes loaded by given issue ID.

func GetUnmergedPullRequest

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

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

func GetUnmergedPullRequestsByBaseInfo

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

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

func GetUnmergedPullRequestsByHeadInfo

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

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

func PullRequests added in v1.0.0

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

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

func (*PullRequest) CanAutoMerge

func (pr *PullRequest) CanAutoMerge() bool

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

func (*PullRequest) GetApprovalCounts added in v1.12.0

func (pr *PullRequest) GetApprovalCounts() ([]*ReviewCount, error)

GetApprovalCounts returns the approval counts by type FIXME: Only returns official counts due to double counting of non-official counts

func (*PullRequest) GetApprovers added in v1.11.0

func (pr *PullRequest) GetApprovers() string

GetApprovers returns the approvers of the pull request

func (*PullRequest) GetBaseBranchHTMLURL added in v1.14.0

func (pr *PullRequest) GetBaseBranchHTMLURL() string

GetBaseBranchHTMLURL returns the HTML URL of the base branch

func (*PullRequest) GetDefaultMergeMessage added in v1.4.0

func (pr *PullRequest) GetDefaultMergeMessage() (string, error)

GetDefaultMergeMessage returns default message used when merging pull request

func (*PullRequest) GetDefaultSquashMessage added in v1.4.0

func (pr *PullRequest) GetDefaultSquashMessage() (string, error)

GetDefaultSquashMessage returns default message used when squash and merging pull request

func (*PullRequest) GetGitRefName added in v1.4.0

func (pr *PullRequest) GetGitRefName() string

GetGitRefName returns git ref for hidden pull request branch

func (*PullRequest) GetHeadBranchHTMLURL added in v1.14.0

func (pr *PullRequest) GetHeadBranchHTMLURL() string

GetHeadBranchHTMLURL returns the HTML URL of the head branch

func (*PullRequest) GetWorkInProgressPrefix added in v1.6.0

func (pr *PullRequest) GetWorkInProgressPrefix() string

GetWorkInProgressPrefix returns the prefix used to mark the pull request as a work in progress. It returns an empty string when none were found

func (*PullRequest) IsChecking

func (pr *PullRequest) IsChecking() bool

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

func (*PullRequest) IsEmpty added in v1.14.0

func (pr *PullRequest) IsEmpty() bool

IsEmpty returns true if this pull request is empty.

func (*PullRequest) IsFilesConflicted added in v1.8.0

func (pr *PullRequest) IsFilesConflicted() bool

IsFilesConflicted determines if the Pull Request has changes conflicting with the target branch.

func (*PullRequest) IsSameRepo added in v1.12.0

func (pr *PullRequest) IsSameRepo() bool

IsSameRepo returns true if base repo and head repo is the same

func (*PullRequest) IsWorkInProgress added in v1.6.0

func (pr *PullRequest) IsWorkInProgress() bool

IsWorkInProgress determine if the Pull Request is a Work In Progress by its title

func (*PullRequest) LoadAttributes

func (pr *PullRequest) LoadAttributes() error

LoadAttributes loads pull request attributes from database

func (*PullRequest) LoadBaseRepo added in v1.10.0

func (pr *PullRequest) LoadBaseRepo() error

LoadBaseRepo loads the target repository

func (*PullRequest) LoadHeadRepo added in v1.10.0

func (pr *PullRequest) LoadHeadRepo() error

LoadHeadRepo loads the head repository

func (*PullRequest) LoadIssue

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

LoadIssue loads issue information from database

func (*PullRequest) LoadProtectedBranch added in v1.7.0

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

LoadProtectedBranch loads the protected branch of the base branch

func (*PullRequest) Mergeable added in v1.16.7

func (pr *PullRequest) Mergeable() bool

Mergeable returns if the pullrequest is mergeable.

func (*PullRequest) MustHeadUserName added in v1.10.0

func (pr *PullRequest) MustHeadUserName() string

MustHeadUserName returns the HeadRepo's username if failed return blank

func (*PullRequest) ResolveCrossReferences added in v1.11.0

func (pr *PullRequest) ResolveCrossReferences() ([]*Comment, error)

ResolveCrossReferences will return the list of references to close/reopen by this PR

func (*PullRequest) SetMerged added in v1.9.0

func (pr *PullRequest) SetMerged() (bool, error)

SetMerged sets a pull request to merged and closes the corresponding issue

func (*PullRequest) Update

func (pr *PullRequest) Update() error

Update updates all fields of pull request.

func (*PullRequest) UpdateCols

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

UpdateCols updates specific fields of pull request.

func (*PullRequest) UpdateColsIfNotMerged added in v1.11.1

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

UpdateColsIfNotMerged updates specific fields of a pull request if it has not been merged

func (*PullRequest) UpdateCommitDivergence added in v1.12.0

func (pr *PullRequest) UpdateCommitDivergence(ahead, behind int) error

UpdateCommitDivergence update Divergence of a pull request

type PullRequestFlow added in v1.16.0

type PullRequestFlow int

PullRequestFlow the flow of pull request

const (
	// PullRequestFlowGithub github flow from head branch to base branch
	PullRequestFlowGithub PullRequestFlow = iota
	// PullRequestFlowAGit Agit flow pull request, head branch is not exist
	PullRequestFlowAGit
)

type PullRequestList

type PullRequestList []*PullRequest

PullRequestList defines a list of pull requests

func (PullRequestList) InvalidateCodeComments added in v1.6.0

func (prs PullRequestList) InvalidateCodeComments(doer *user_model.User, repo *git.Repository, branch string) error

InvalidateCodeComments will lookup the prs for code comments which got invalidated by change

func (PullRequestList) LoadAttributes

func (prs PullRequestList) LoadAttributes() error

LoadAttributes load all the prs attributes

type PullRequestStatus

type PullRequestStatus int

PullRequestStatus defines pull request status

const (
	PullRequestStatusConflict PullRequestStatus = iota
	PullRequestStatusChecking
	PullRequestStatusMergeable
	PullRequestStatusManuallyMerged
	PullRequestStatusError
	PullRequestStatusEmpty
)

Enumerate all the pull request status

type PullRequestType

type PullRequestType int

PullRequestType defines pull request type

const (
	PullRequestGitea PullRequestType = iota
	PullRequestGit
)

Enumerate all the pull request types

type PullRequestsOptions added in v1.0.0

type PullRequestsOptions struct {
	db.ListOptions
	State       string
	SortType    string
	Labels      []string
	MilestoneID int64
}

PullRequestsOptions holds the options for PRs

type PushActionContent added in v1.13.0

type PushActionContent struct {
	IsForcePush bool     `json:"is_force_push"`
	CommitIDs   []string `json:"commit_ids"`
}

PushActionContent is content of push pull comment

type Reaction added in v1.4.0

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

Reaction represents a reactions on issues and comments.

func CreateCommentReaction added in v1.4.0

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

CreateCommentReaction creates a reaction on comment.

func CreateIssueReaction added in v1.4.0

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

CreateIssueReaction creates a reaction on issue.

func CreateReaction added in v1.4.0

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

CreateReaction creates reaction for issue or comment.

func (*Reaction) LoadUser added in v1.11.0

func (r *Reaction) LoadUser() (*user_model.User, error)

LoadUser load user of reaction

type ReactionList added in v1.4.0

type ReactionList []*Reaction

ReactionList represents list of reactions

func FindCommentReactions added in v1.11.0

func FindCommentReactions(comment *Comment) (ReactionList, int64, error)

FindCommentReactions returns a ReactionList of all reactions from an comment

func FindIssueReactions added in v1.11.0

func FindIssueReactions(issue *Issue, listOptions db.ListOptions) (ReactionList, int64, error)

FindIssueReactions returns a ReactionList of all reactions from an issue

func (ReactionList) GetFirstUsers added in v1.4.0

func (list ReactionList) GetFirstUsers() string

GetFirstUsers returns first reacted user display names separated by comma

func (ReactionList) GetMoreUserCount added in v1.4.0

func (list ReactionList) GetMoreUserCount() int

GetMoreUserCount returns count of not shown users in reaction tooltip

func (ReactionList) GroupByType added in v1.4.0

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

GroupByType returns reactions grouped by type

func (ReactionList) HasUser added in v1.4.0

func (list ReactionList) HasUser(userID int64) bool

HasUser check if user has reacted

func (ReactionList) LoadUsers added in v1.4.0

func (list ReactionList) LoadUsers(repo *repo_model.Repository) ([]*user_model.User, error)

LoadUsers loads reactions' all users

type ReactionOptions added in v1.4.0

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

ReactionOptions defines options for creating or deleting reactions

type Release

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

Release represents a release of repository.

func GetLatestReleaseByRepoID added in v1.12.0

func GetLatestReleaseByRepoID(repoID int64) (*Release, error)

GetLatestReleaseByRepoID returns the latest release for a repository

func GetRelease

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

GetRelease returns release by given ID.

func GetReleaseByID

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

GetReleaseByID returns release with given ID.

func GetReleasesByRepoID

func GetReleasesByRepoID(repoID int64, opts FindReleasesOptions) ([]*Release, error)

GetReleasesByRepoID returns a list of releases of repository.

func GetReleasesByRepoIDAndNames added in v1.1.0

func GetReleasesByRepoIDAndNames(ctx context.Context, repoID int64, tagNames []string) (rels []*Release, err error)

GetReleasesByRepoIDAndNames returns a list of releases of repository according repoID and tagNames.

func (*Release) APIURL added in v1.1.0

func (r *Release) APIURL() string

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

func (*Release) HTMLURL added in v1.12.0

func (r *Release) HTMLURL() string

HTMLURL the url for a release on the web UI. release must have attributes loaded

func (*Release) LoadAttributes added in v1.1.0

func (r *Release) LoadAttributes() error

LoadAttributes load repo and publisher attributes for a release

func (*Release) TarURL added in v1.1.0

func (r *Release) TarURL() string

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

func (*Release) ZipURL added in v1.1.0

func (r *Release) ZipURL() string

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

type RenamedBranch added in v1.16.0

type RenamedBranch struct {
	ID          int64 `xorm:"pk autoincr"`
	RepoID      int64 `xorm:"INDEX NOT NULL"`
	From        string
	To          string
	CreatedUnix timeutil.TimeStamp `xorm:"created"`
}

RenamedBranch provide renamed branch log will check it when a branch can't be found

func FindRenamedBranch added in v1.16.0

func FindRenamedBranch(repoID int64, from string) (branch *RenamedBranch, exist bool, err error)

FindRenamedBranch check if a branch was renamed

type RepoTransfer added in v1.14.0

type RepoTransfer struct {
	ID          int64 `xorm:"pk autoincr"`
	DoerID      int64
	Doer        *user_model.User `xorm:"-"`
	RecipientID int64
	Recipient   *user_model.User `xorm:"-"`
	RepoID      int64
	TeamIDs     []int64
	Teams       []*Team `xorm:"-"`

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

RepoTransfer is used to manage repository transfers

func GetPendingRepositoryTransfer added in v1.14.0

func GetPendingRepositoryTransfer(repo *repo_model.Repository) (*RepoTransfer, error)

GetPendingRepositoryTransfer fetches the most recent and ongoing transfer process for the repository

func (*RepoTransfer) CanUserAcceptTransfer added in v1.14.0

func (r *RepoTransfer) CanUserAcceptTransfer(u *user_model.User) bool

CanUserAcceptTransfer checks if the user has the rights to accept/decline a repo transfer. For user, it checks if it's himself For organizations, it checks if the user is able to create repos

func (*RepoTransfer) LoadAttributes added in v1.14.0

func (r *RepoTransfer) LoadAttributes() error

LoadAttributes fetches the transfer recipient from the database

type RepositoryList

type RepositoryList []*repo_model.Repository

RepositoryList contains a list of repositories

func RepositoryListOfMap added in v1.2.0

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

RepositoryListOfMap make list from values of map

func SearchRepository added in v1.10.0

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

SearchRepository returns repositories based on search options, it returns results in given range and number of total results.

func SearchRepositoryByCondition added in v1.11.4

func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loadAttributes bool) (RepositoryList, int64, error)

SearchRepositoryByCondition search repositories by condition

func SearchRepositoryByName

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

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

func (RepositoryList) Len added in v1.4.0

func (repos RepositoryList) Len() int

func (RepositoryList) Less added in v1.4.0

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

func (RepositoryList) LoadAttributes

func (repos RepositoryList) LoadAttributes() error

LoadAttributes loads the attributes for the given RepositoryList

func (RepositoryList) Swap added in v1.4.0

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

type Review added in v1.6.0

type Review struct {
	ID               int64 `xorm:"pk autoincr"`
	Type             ReviewType
	Reviewer         *user_model.User `xorm:"-"`
	ReviewerID       int64            `xorm:"index"`
	ReviewerTeamID   int64            `xorm:"NOT NULL DEFAULT 0"`
	ReviewerTeam     *Team            `xorm:"-"`
	OriginalAuthor   string
	OriginalAuthorID int64
	Issue            *Issue `xorm:"-"`
	IssueID          int64  `xorm:"index"`
	Content          string `xorm:"TEXT"`
	// Official is a review made by an assigned approver (counts towards approval)
	Official  bool   `xorm:"NOT NULL DEFAULT false"`
	CommitID  string `xorm:"VARCHAR(40)"`
	Stale     bool   `xorm:"NOT NULL DEFAULT false"`
	Dismissed bool   `xorm:"NOT NULL DEFAULT false"`

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

	// CodeComments are the initial code comments of the review
	CodeComments CodeComments `xorm:"-"`

	Comments []*Comment `xorm:"-"`
}

Review represents collection of code comments giving feedback for a PR

func CreateReview added in v1.6.0

func CreateReview(opts CreateReviewOptions) (*Review, error)

CreateReview creates a new review based on opts

func FindReviews added in v1.6.0

func FindReviews(opts FindReviewOptions) ([]*Review, error)

FindReviews returns reviews passing FindReviewOptions

func GetCurrentReview added in v1.6.0

func GetCurrentReview(reviewer *user_model.User, issue *Issue) (*Review, error)

GetCurrentReview returns the current pending review of reviewer for given issue

func GetReviewByID added in v1.6.0

func GetReviewByID(id int64) (*Review, error)

GetReviewByID returns the review by the given ID

func GetReviewByIssueIDAndUserID added in v1.13.0

func GetReviewByIssueIDAndUserID(issueID, userID int64) (*Review, error)

GetReviewByIssueIDAndUserID get the latest review of reviewer for a pull request

func GetReviewersByIssueID added in v1.11.0

func GetReviewersByIssueID(issueID int64) ([]*Review, error)

GetReviewersByIssueID gets the latest review of each reviewer for a pull request

func GetReviewersFromOriginalAuthorsByIssueID added in v1.13.0

func GetReviewersFromOriginalAuthorsByIssueID(issueID int64) ([]*Review, error)

GetReviewersFromOriginalAuthorsByIssueID gets the latest review of each original authors for a pull request

func GetTeamReviewerByIssueIDAndTeamID added in v1.13.0

func GetTeamReviewerByIssueIDAndTeamID(issueID, teamID int64) (review *Review, err error)

GetTeamReviewerByIssueIDAndTeamID get the latest review request of reviewer team for a pull request

func (*Review) GetCodeCommentsCount added in v1.12.0

func (r *Review) GetCodeCommentsCount() int

GetCodeCommentsCount return count of CodeComments a Review has

func (*Review) HTMLURL added in v1.12.0

func (r *Review) HTMLURL() string

HTMLURL formats a URL-string to the related review issue-comment

func (*Review) LoadAttributes added in v1.6.0

func (r *Review) LoadAttributes() error

LoadAttributes loads all attributes except CodeComments

func (*Review) LoadCodeComments added in v1.6.0

func (r *Review) LoadCodeComments() error

LoadCodeComments loads CodeComments

func (*Review) LoadReviewer added in v1.11.0

func (r *Review) LoadReviewer() error

LoadReviewer loads reviewer

func (*Review) LoadReviewerTeam added in v1.13.0

func (r *Review) LoadReviewerTeam() error

LoadReviewerTeam loads reviewer team

type ReviewCount added in v1.12.0

type ReviewCount struct {
	IssueID int64
	Type    ReviewType
	Count   int64
}

ReviewCount represents a count of Reviews

type ReviewType added in v1.6.0

type ReviewType int

ReviewType defines the sort of feedback a review gives

const (
	// ReviewTypePending is a review which is not published yet
	ReviewTypePending ReviewType = iota
	// ReviewTypeApprove approves changes
	ReviewTypeApprove
	// ReviewTypeComment gives general feedback
	ReviewTypeComment
	// ReviewTypeReject gives feedback blocking merge
	ReviewTypeReject
	// ReviewTypeRequest request review from others
	ReviewTypeRequest
)
const ReviewTypeUnknown ReviewType = -1

ReviewTypeUnknown unknown review type

func (ReviewType) Icon added in v1.6.0

func (rt ReviewType) Icon() string

Icon returns the corresponding icon for the review type

type RoleDescriptor added in v1.16.0

type RoleDescriptor int

RoleDescriptor defines comment tag type

const (
	RoleDescriptorNone RoleDescriptor = iota
	RoleDescriptorPoster
	RoleDescriptorWriter
	RoleDescriptorOwner
)

Enumerate all the role tags.

func (RoleDescriptor) HasRole added in v1.16.0

func (rd RoleDescriptor) HasRole(role string) bool

HasRole returns if a certain role is enabled on the RoleDescriptor.

func (RoleDescriptor) WithRole added in v1.16.0

func (rd RoleDescriptor) WithRole(role RoleDescriptor) RoleDescriptor

WithRole enable a specific tag on the RoleDescriptor.

type SearchMembersOptions added in v1.12.0

type SearchMembersOptions struct {
	db.ListOptions
}

SearchMembersOptions holds the search options

type SearchOrderBy added in v1.3.0

type SearchOrderBy string

SearchOrderBy is used to sort the result

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

Strings for sorting result

func (SearchOrderBy) String added in v1.3.0

func (s SearchOrderBy) String() string

type SearchOrgTeamOptions added in v1.16.1

type SearchOrgTeamOptions struct {
	db.ListOptions
	Keyword     string
	OrgID       int64
	IncludeDesc bool
}

SearchOrgTeamOptions holds the search options

type SearchOrganizationsOptions added in v1.12.0

type SearchOrganizationsOptions struct {
	db.ListOptions
	All bool
}

SearchOrganizationsOptions options to filter organizations

type SearchRepoOptions

type SearchRepoOptions struct {
	db.ListOptions
	Actor           *user_model.User
	Keyword         string
	OwnerID         int64
	PriorityOwnerID int64
	TeamID          int64
	OrderBy         db.SearchOrderBy
	Private         bool // Include private repositories in results
	StarredByID     int64
	WatchedByID     int64
	AllPublic       bool // Include also all public repositories of users and public organisations
	AllLimited      bool // Include also all public repositories of limited organisations
	// None -> include public and private
	// True -> include just private
	// False -> include just public
	IsPrivate util.OptionalBool
	// None -> include collaborative AND non-collaborative
	// True -> include just collaborative
	// False -> include just non-collaborative
	Collaborate util.OptionalBool
	// None -> include forks AND non-forks
	// True -> include just forks
	// False -> include just non-forks
	Fork util.OptionalBool
	// None -> include templates AND non-templates
	// True -> include just templates
	// False -> include just non-templates
	Template util.OptionalBool
	// None -> include mirrors AND non-mirrors
	// True -> include just mirrors
	// False -> include just non-mirrors
	Mirror util.OptionalBool
	// None -> include archived AND non-archived
	// True -> include just archived
	// False -> include just non-archived
	Archived util.OptionalBool
	// only search topic name
	TopicOnly bool
	// include description in keyword search
	IncludeDescription bool
	// None -> include has milestones AND has no milestone
	// True -> include just has milestones
	// False -> include just has no milestone
	HasMilestones util.OptionalBool
	// LowerNames represents valid lower names to restrict to
	LowerNames []string
}

SearchRepoOptions holds the search options

type SignCommitWithStatuses added in v1.2.0

type SignCommitWithStatuses struct {
	Status   *CommitStatus
	Statuses []*CommitStatus
	*asymkey_model.SignCommit
}

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

func ConvertFromGitCommit added in v1.16.0

func ConvertFromGitCommit(commits []*git.Commit, repo *repo_model.Repository) []*SignCommitWithStatuses

ConvertFromGitCommit converts git commits into SignCommitWithStatuses

func ParseCommitsWithStatus added in v1.2.0

func ParseCommitsWithStatus(oldCommits []*asymkey_model.SignCommit, repo *repo_model.Repository) []*SignCommitWithStatuses

ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state

type Statistic

type Statistic struct {
	Counter struct {
		User, Org, PublicKey,
		Repo, Watch, Star, Action, Access,
		Issue, IssueClosed, IssueOpen,
		Comment, Oauth, Follow,
		Mirror, Release, AuthSource, Webhook,
		Milestone, Label, HookTask,
		Team, UpdateTask, Project,
		ProjectBoard, Attachment int64
		IssueByLabel      []IssueByLabelCount
		IssueByRepository []IssueByRepositoryCount
	}
}

Statistic contains the database statistics

func GetStatistic

func GetStatistic() (stats Statistic)

GetStatistic returns the database statistics

type Stopwatch added in v1.3.0

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

Stopwatch represents a stopwatch for time tracking.

func GetUserStopwatches added in v1.11.0

func GetUserStopwatches(userID int64, listOptions db.ListOptions) ([]*Stopwatch, error)

GetUserStopwatches return list of all stopwatches of a user

func HasUserStopwatch added in v1.3.0

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

HasUserStopwatch returns true if the user has a stopwatch

func (Stopwatch) Duration added in v1.14.0

func (s Stopwatch) Duration() string

Duration returns a human-readable duration string based on local server time

func (Stopwatch) Seconds added in v1.14.0

func (s Stopwatch) Seconds() int64

Seconds returns the amount of time passed since creation, based on local server time

type Task added in v1.10.0

type Task struct {
	ID             int64
	DoerID         int64                  `xorm:"index"` // operator
	Doer           *user_model.User       `xorm:"-"`
	OwnerID        int64                  `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
	Owner          *user_model.User       `xorm:"-"`
	RepoID         int64                  `xorm:"index"`
	Repo           *repo_model.Repository `xorm:"-"`
	Type           structs.TaskType
	Status         structs.TaskStatus `xorm:"index"`
	StartTime      timeutil.TimeStamp
	EndTime        timeutil.TimeStamp
	PayloadContent string             `xorm:"TEXT"`
	Message        string             `xorm:"TEXT"` // if task failed, saved the error reason
	Created        timeutil.TimeStamp `xorm:"created"`
}

Task represents a task

func FindTasks added in v1.10.0

func FindTasks(opts FindTaskOptions) ([]*Task, error)

FindTasks find all tasks

func GetMigratingTask added in v1.10.0

func GetMigratingTask(repoID int64) (*Task, error)

GetMigratingTask returns the migrating task by repo's id

func GetMigratingTaskByID added in v1.13.0

func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, error)

GetMigratingTaskByID returns the migrating task by repo's id

func (*Task) LoadDoer added in v1.10.0

func (task *Task) LoadDoer() error

LoadDoer loads do user

func (*Task) LoadOwner added in v1.10.0

func (task *Task) LoadOwner() error

LoadOwner loads owner user

func (*Task) LoadRepo added in v1.10.0

func (task *Task) LoadRepo() error

LoadRepo loads repository of the task

func (*Task) MigrateConfig added in v1.10.0

func (task *Task) MigrateConfig() (*migration.MigrateOptions, error)

MigrateConfig returns task config when migrate repository

func (*Task) UpdateCols added in v1.10.0

func (task *Task) UpdateCols(cols ...string) error

UpdateCols updates some columns

type Team

type Team struct {
	ID                      int64 `xorm:"pk autoincr"`
	OrgID                   int64 `xorm:"INDEX"`
	LowerName               string
	Name                    string
	Description             string
	AccessMode              perm.AccessMode          `xorm:"'authorize'"`
	Repos                   []*repo_model.Repository `xorm:"-"`
	Members                 []*user_model.User       `xorm:"-"`
	NumRepos                int
	NumMembers              int
	Units                   []*TeamUnit `xorm:"-"`
	IncludesAllRepositories bool        `xorm:"NOT NULL DEFAULT false"`
	CanCreateOrgRepo        bool        `xorm:"NOT NULL DEFAULT false"`
}

Team represents a organization team.

func GetRepoTeams added in v1.16.0

func GetRepoTeams(repo *repo_model.Repository) ([]*Team, error)

GetRepoTeams gets the list of teams that has access to the repository

func GetReviewerTeams added in v1.16.0

func GetReviewerTeams(repo *repo_model.Repository) ([]*Team, error)

GetReviewerTeams get all teams can be requested to review

func GetTeam

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

GetTeam returns team by given team name and organization.

func GetTeamByID

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

GetTeamByID returns team by given ID.

func GetTeamsWithAccessToRepo added in v1.3.0

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

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

func GetUserOrgTeams added in v1.8.0

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

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

func GetUserTeams

func GetUserTeams(opts *GetUserTeamOptions) ([]*Team, int64, error)

GetUserTeams search for org teams. Caller is responsible to check permissions.

func SearchOrgTeams added in v1.16.1

func SearchOrgTeams(opts *SearchOrgTeamOptions) ([]*Team, int64, error)

SearchOrgTeams search for org teams. Caller is responsible to check permissions.

func (*Team) AddAllRepositories added in v1.11.0

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

AddAllRepositories adds all repositories to the team

func (*Team) AddMember

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

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

func (*Team) AddRepository

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

AddRepository adds new repository to team of organization.

func (*Team) ColorFormat added in v1.9.0

func (t *Team) ColorFormat(s fmt.State)

ColorFormat provides a basic color format for a Team

func (*Team) GetMembers

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

GetMembers returns paginated members in team of organization.

func (*Team) GetRepositories

func (t *Team) GetRepositories(opts *SearchOrgTeamOptions) error

GetRepositories returns paginated repositories in team of organization.

func (*Team) GetUnitNames added in v1.6.0

func (t *Team) GetUnitNames() (res []string)

GetUnitNames returns the team units names

func (*Team) GetUnits added in v1.8.0

func (t *Team) GetUnits() error

GetUnits return a list of available units for a team

func (*Team) GetUnitsMap added in v1.16.0

func (t *Team) GetUnitsMap() map[string]string

GetUnitsMap returns the team units permissions

func (*Team) HasRepository

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

HasRepository returns true if given repository belong to team.

func (*Team) IsMember

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

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

func (*Team) IsOwnerTeam

func (t *Team) IsOwnerTeam() bool

IsOwnerTeam returns true if team is owner team.

func (*Team) RemoveAllRepositories added in v1.11.0

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

RemoveAllRepositories removes all repositories from team and recalculates access

func (*Team) RemoveMember

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

RemoveMember removes member from team of organization.

func (*Team) RemoveRepository

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

RemoveRepository removes repository from team of organization. If the team shall include all repositories the request is ignored.

func (*Team) UnitAccessMode added in v1.16.0

func (t *Team) UnitAccessMode(tp unit.Type) perm.AccessMode

UnitAccessMode returns if the team has the given unit type enabled

func (*Team) UnitEnabled added in v1.2.0

func (t *Team) UnitEnabled(tp unit.Type) bool

UnitEnabled returns if the team has the given unit type enabled

type TeamRepo

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

TeamRepo represents an team-repository relation.

type TeamUnit added in v1.5.0

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

TeamUnit describes all units of a repository

func (*TeamUnit) Unit added in v1.5.0

func (t *TeamUnit) Unit() unit.Unit

Unit returns Unit

type TeamUser

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

TeamUser represents an team-user relation.

type TrackedTime added in v1.3.0

type TrackedTime struct {
	ID          int64            `xorm:"pk autoincr"`
	IssueID     int64            `xorm:"INDEX"`
	Issue       *Issue           `xorm:"-"`
	UserID      int64            `xorm:"INDEX"`
	User        *user_model.User `xorm:"-"`
	Created     time.Time        `xorm:"-"`
	CreatedUnix int64            `xorm:"created"`
	Time        int64            `xorm:"NOT NULL"`
	Deleted     bool             `xorm:"NOT NULL DEFAULT false"`
}

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

func AddTime added in v1.3.0

func AddTime(user *user_model.User, issue *Issue, amount int64, created time.Time) (*TrackedTime, error)

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

func GetTrackedTimeByID added in v1.11.0

func GetTrackedTimeByID(id int64) (*TrackedTime, error)

GetTrackedTimeByID returns raw TrackedTime without loading attributes by id

func (*TrackedTime) AfterLoad added in v1.3.0

func (t *TrackedTime) AfterLoad()

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

func (*TrackedTime) LoadAttributes added in v1.11.0

func (t *TrackedTime) LoadAttributes() (err error)

LoadAttributes load Issue, User

type TrackedTimeList added in v1.11.0

type TrackedTimeList []*TrackedTime

TrackedTimeList is a List of TrackedTime's

func GetTrackedTimes added in v1.3.0

func GetTrackedTimes(opts *FindTrackedTimesOptions) (TrackedTimeList, error)

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

func (TrackedTimeList) LoadAttributes added in v1.11.0

func (tl TrackedTimeList) LoadAttributes() (err error)

LoadAttributes load Issue, User

type TranslatableMessage added in v1.15.0

type TranslatableMessage struct {
	Format string
	Args   []interface{} `json:"omitempty"`
}

TranslatableMessage represents JSON struct that can be translated with a Locale

type Upload

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

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

func GetUploadByUUID

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

GetUploadByUUID returns the Upload by UUID

func GetUploadsByUUIDs

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

GetUploadsByUUIDs returns multiple uploads by UUIDS

func NewUpload

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

NewUpload creates a new upload object.

func (*Upload) LocalPath

func (upload *Upload) LocalPath() string

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

type UserHeatmapData added in v1.7.0

type UserHeatmapData struct {
	Timestamp     timeutil.TimeStamp `json:"timestamp"`
	Contributions int64              `json:"contributions"`
}

UserHeatmapData represents the data needed to create a heatmap

func GetUserHeatmapDataByUser added in v1.7.0

func GetUserHeatmapDataByUser(user, doer *user_model.User) ([]*UserHeatmapData, error)

GetUserHeatmapDataByUser returns an array of UserHeatmapData

func GetUserHeatmapDataByUserTeam added in v1.14.0

func GetUserHeatmapDataByUserTeam(user *user_model.User, team *Team, doer *user_model.User) ([]*UserHeatmapData, error)

GetUserHeatmapDataByUserTeam returns an array of UserHeatmapData

type UserIDCount added in v1.12.0

type UserIDCount struct {
	UserID int64
	Count  int64
}

UserIDCount is a simple coalition of UserID and Count

func GetUIDsAndNotificationCounts added in v1.12.0

func GetUIDsAndNotificationCounts(since, until timeutil.TimeStamp) ([]UserIDCount, error)

GetUIDsAndNotificationCounts between the two provided times

type UserIssueStatsOptions added in v1.4.0

type UserIssueStatsOptions struct {
	UserID     int64
	RepoIDs    []int64
	FilterMode int
	IsPull     bool
	IsClosed   bool
	IssueIDs   []int64
	IsArchived util.OptionalBool
	LabelIDs   []int64
	RepoCond   builder.Cond
	Org        *Organization
	Team       *Team
}

UserIssueStatsOptions contains parameters accepted by GetUserIssueStats.

type WhitelistOptions added in v1.7.0

type WhitelistOptions struct {
	UserIDs []int64
	TeamIDs []int64

	MergeUserIDs []int64
	MergeTeamIDs []int64

	ApprovalsUserIDs []int64
	ApprovalsTeamIDs []int64
}

WhitelistOptions represent all sorts of whitelists used for protected branches

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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