models

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 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"
	EnvIsDeployKey  = "GITEA_IS_DEPLOY_KEY"
	EnvPRID         = "GITEA_PR_ID"
	EnvIsInternal   = "GITEA_INTERNAL_PUSH"
	EnvAppURL       = "GITEA_ROOT_URL"
)

env keys for git hooks need

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

Filter modes.

View Source
const 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 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 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
	NotResolvedIP      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.