issues

package
v0.0.0-...-0ce574d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

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

Filter modes.

View Source
const (
	// MaxQueryParameters represents the max query parameters
	// When queries are broken down in parts because of the number
	// of parameters, attempt to break by this amount
	MaxQueryParameters = 300
)

Variables

View Source
var ErrCommentAlreadyChanged = util.NewInvalidArgumentErrorf("the comment is already changed")
View Source
var ErrIssueAlreadyChanged = util.NewInvalidArgumentErrorf("the issue is already changed")
View Source
var ErrIssueMaxPinReached = util.NewInvalidArgumentErrorf("the max number of pinned issues has been readched")
View Source
var ErrMustCollaborator = util.NewPermissionDeniedErrorf("user must be a collaborator")

Functions

func AddDeletePRBranchComment

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

AddDeletePRBranchComment adds delete branch comment for pull request issue

func BuildLabelNamesIssueIDsCondition

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

BuildLabelNamesIssueIDsCondition returns a builder where get issue ids match label names

func CanMaintainerWriteToBranch

func CanMaintainerWriteToBranch(ctx context.Context, p access_model.Permission, branch string, user *user_model.User) bool

CanMaintainerWriteToBranch check whether user is a maintainer and could write to the branch

func CanMarkConversation

func CanMarkConversation(ctx context.Context, 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 CancelStopwatch

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

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

func ChangeIssueContent

func ChangeIssueContent(ctx context.Context, issue *Issue, doer *user_model.User, content string, contentVersion int) (err error)

ChangeIssueContent changes issue content, as the given user.

func ChangeIssueRef

func ChangeIssueRef(ctx context.Context, issue *Issue, doer *user_model.User, oldRef string) (err error)

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

func ChangeIssueTimeEstimate

func ChangeIssueTimeEstimate(ctx context.Context, issue *Issue, doer *user_model.User, timeEstimate int64) error

ChangeIssueTimeEstimate changes the plan time of this issue, as the given user.

func ChangeIssueTitle

func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User, oldTitle string) (err error)

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

func ChangeMilestoneStatus

func ChangeMilestoneStatus(ctx context.Context, m *Milestone, isClosed bool) (err error)

ChangeMilestoneStatus changes the milestone open/closed status.

func ChangeMilestoneStatusByRepoIDAndID

func ChangeMilestoneStatusByRepoIDAndID(ctx context.Context, repoID, milestoneID int64, isClosed bool) error

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

func CheckIssueWatch

func CheckIssueWatch(ctx context.Context, 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 ClearIssueLabels

func ClearIssueLabels(ctx context.Context, issue *Issue, doer *user_model.User) (err error)

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

func CommentHashTag

func CommentHashTag(id int64) string

CommentHashTag returns unique hash tag for comment id.

func CommentTypeIsRef

func CommentTypeIsRef(t CommentType) bool

CommentTypeIsRef returns true if CommentType is a reference from another issue

func CountCommentTypeLabelWithEmptyLabel

func CountCommentTypeLabelWithEmptyLabel(ctx context.Context) (int64, error)

CountCommentTypeLabelWithEmptyLabel count label comments with empty label

func CountCommentTypeLabelWithOutsideLabels

func CountCommentTypeLabelWithOutsideLabels(ctx context.Context) (int64, error)

CountCommentTypeLabelWithOutsideLabels count label comments with outside label

func CountComments

func CountComments(ctx context.Context, opts *FindCommentsOptions) (int64, error)

CountComments count all comments according options by ignoring pagination

func CountIssueLabelWithOutsideLabels

func CountIssueLabelWithOutsideLabels(ctx context.Context) (int64, error)

CountIssueLabelWithOutsideLabels count label comments with outside label

func CountIssueWatchers

func CountIssueWatchers(ctx context.Context, issueID int64) (int64, error)

CountIssueWatchers count watchers/unwatchers of a given issue

func CountIssues

func CountIssues(ctx context.Context, opts *IssuesOptions, otherConds ...builder.Cond) (int64, error)

CountIssues number return of issues by given conditions.

func CountIssuesByRepo

func CountIssuesByRepo(ctx context.Context, opts *IssuesOptions) (map[int64]int64, error)

CountIssuesByRepo map from repoID to number of issues matching the options

func CountLabelsByOrgID

func CountLabelsByOrgID(ctx context.Context, orgID int64) (int64, error)

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

func CountLabelsByRepoID

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

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

func CountMilestonesMap

func CountMilestonesMap(ctx context.Context, opts FindMilestoneOptions) (map[int64]int64, error)

CountMilestonesByRepoCondAndKw map from repo conditions and the keyword of milestones' name to number of milestones matching the options`

func CountOrphanedIssueLabels

func CountOrphanedIssueLabels(ctx context.Context) (int64, error)

CountOrphanedIssueLabels return count of IssueLabels witch have no label behind anymore

func CountOrphanedIssues

func CountOrphanedIssues(ctx context.Context) (int64, error)

CountOrphanedIssues count issues without a repo

func CountOrphanedLabels

func CountOrphanedLabels(ctx context.Context) (int64, error)

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

func CountReviews

func CountReviews(ctx context.Context, opts FindReviewOptions) (int64, error)

CountReviews returns count of reviews passing FindReviewOptions

func CountTrackedTimes

func CountTrackedTimes(ctx context.Context, opts *FindTrackedTimesOptions) (int64, error)

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

func CountUserStopwatches

func CountUserStopwatches(ctx context.Context, userID int64) (int64, error)

CountUserStopwatches return count of all stopwatches of a user

func CreateIssueDependency

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

CreateIssueDependency creates a new dependency for an issue

func CreateIssueStopwatch

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

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

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

func CreateOrUpdateIssueWatch

func CreateOrUpdateIssueWatch(ctx context.Context, userID, issueID int64, isWatching bool) error

CreateOrUpdateIssueWatch set watching for a user and issue

func DeleteComment

func DeleteComment(ctx context.Context, comment *Comment) error

DeleteComment deletes the comment

func DeleteCommentReaction

func DeleteCommentReaction(ctx context.Context, doerID, issueID, commentID int64, content string) error

DeleteCommentReaction deletes a reaction on comment.

func DeleteIssueLabel

func DeleteIssueLabel(ctx context.Context, issue *Issue, label *Label, doer *user_model.User) error

DeleteIssueLabel deletes issue-label relation.

func DeleteIssueReaction

func DeleteIssueReaction(ctx context.Context, doerID, issueID int64, content string) error

DeleteIssueReaction deletes a reaction on issue.

func DeleteIssueUserTimes

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

DeleteIssueUserTimes deletes times for issue

func DeleteIssuesByRepoID

func DeleteIssuesByRepoID(ctx context.Context, repoID int64) (attachmentPaths []string, err error)

DeleteIssuesByRepoID deletes issues by repositories id

func DeleteLabel

func DeleteLabel(ctx context.Context, id, labelID int64) error

DeleteLabel delete a label

func DeleteLabelsByRepoID

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

DeleteLabelsByRepoID deletes labels of some repository

func DeleteMilestoneByRepoID

func DeleteMilestoneByRepoID(ctx context.Context, repoID, id int64) error

DeleteMilestoneByRepoID deletes a milestone from a repository.

func DeleteOrphanedIssueLabels

func DeleteOrphanedIssueLabels(ctx context.Context) error

DeleteOrphanedIssueLabels delete IssueLabels witch have no label behind anymore

func DeleteOrphanedIssues

func DeleteOrphanedIssues(ctx context.Context) error

DeleteOrphanedIssues delete issues without a repo

func DeleteOrphanedLabels

func DeleteOrphanedLabels(ctx context.Context) error

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

func DeletePullsByBaseRepoID

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

DeletePullsByBaseRepoID deletes all pull requests by the base repository ID

func DeleteReaction

func DeleteReaction(ctx context.Context, opts *ReactionOptions) error

DeleteReaction deletes reaction for issue or comment.

func DeleteReview

func DeleteReview(ctx context.Context, r *Review) error

DeleteReview delete a review and it's code comments

func DeleteTime

func DeleteTime(ctx context.Context, t *TrackedTime) error

DeleteTime delete a specific Time

func DismissReview

func DismissReview(ctx context.Context, review *Review, isDismiss bool) (err error)

DismissReview change the dismiss status of a review

func FindAndUpdateIssueMentions

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

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

func FinishIssueStopwatch

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

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

FinishIssueStopwatchIfPossible if stopwatch exist then finish it otherwise ignore

func FixCommentTypeLabelWithEmptyLabel

func FixCommentTypeLabelWithEmptyLabel(ctx context.Context) (int64, error)

FixCommentTypeLabelWithEmptyLabel count label comments with empty label

func FixCommentTypeLabelWithOutsideLabels

func FixCommentTypeLabelWithOutsideLabels(ctx context.Context) (int64, error)

FixCommentTypeLabelWithOutsideLabels count label comments with outside label

func FixIssueLabelWithOutsideLabels

func FixIssueLabelWithOutsideLabels(ctx context.Context) (int64, error)

FixIssueLabelWithOutsideLabels fix label comments with outside label

func GetAssigneeIDsByIssue

func GetAssigneeIDsByIssue(ctx context.Context, 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 GetGrantedApprovalsCount

func GetGrantedApprovalsCount(ctx context.Context, protectBranch *git_model.ProtectedBranch, pr *PullRequest) int64

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

func GetIssueIDsByRepoID

func GetIssueIDsByRepoID(ctx context.Context, repoID int64) ([]int64, error)

GetIssueIDsByRepoID returns all issue ids by repo id

func GetIssueMentionIDs

func GetIssueMentionIDs(ctx context.Context, issueID int64) ([]int64, error)

GetIssueMentionIDs returns all mentioned user IDs of an issue.

func GetIssueTotalTrackedTime

func GetIssueTotalTrackedTime(ctx context.Context, opts *IssuesOptions, isClosed optional.Option[bool]) (int64, error)

GetIssueTotalTrackedTime returns the total tracked time for issues by given conditions.

func GetIssueWatchersIDs

func GetIssueWatchersIDs(ctx context.Context, 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 GetLabelIDsByNames

func GetLabelIDsByNames(ctx context.Context, labelNames []string) ([]int64, error)

GetLabelIDsByNames returns a list of labelIDs by names. It doesn't filter them by repo or org, so it could return labels belonging to different repos/orgs. It's used for filtering issues via indexer, otherwise it would be useless. Since it could return labels with the same name, so the length of returned ids could be more than the length of names.

func GetLabelIDsInRepoByNames

func GetLabelIDsInRepoByNames(ctx context.Context, 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 GetMilestoneIDsByNames

func GetMilestoneIDsByNames(ctx context.Context, names []string) ([]int64, error)

GetMilestoneIDsByNames returns a list of milestone ids by given names. It doesn't filter them by repo, so it could return milestones belonging to different repos. It's used for filtering issues via indexer, otherwise it would be useless. Since it could return milestones with the same name, so the length of returned ids could be more than the length of names.

func GetParticipantsIDsByIssueID

func GetParticipantsIDsByIssueID(ctx context.Context, 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

func GetPullRequestIDsByCheckStatus(ctx context.Context, status PullRequestStatus) ([]int64, error)

GetPullRequestIDsByCheckStatus returns all pull requests according the special checking status.

func GetTrackedSeconds

func GetTrackedSeconds(ctx context.Context, opts FindTrackedTimesOptions) (trackedSeconds int64, err error)

GetTrackedSeconds return sum of seconds

func HasEnoughApprovals

func HasEnoughApprovals(ctx context.Context, protectBranch *git_model.ProtectedBranch, pr *PullRequest) bool

HasEnoughApprovals returns true if pr has enough granted approvals.

func HasIssueContentHistory

func HasIssueContentHistory(dbCtx context.Context, issueID, commentID int64) (bool, error)

HasIssueContentHistory check if a ContentHistory entry exists

func HasIssueLabel

func HasIssueLabel(ctx context.Context, issueID, labelID int64) bool

HasIssueLabel returns true if issue has been labeled.

func HasMergedPullRequestInRepo

func HasMergedPullRequestInRepo(ctx context.Context, repoID, posterID int64) (bool, error)

HasMergedPullRequestInRepo returns whether the user(poster) has merged pull-request in the repo

func HasMilestoneByRepoID

func HasMilestoneByRepoID(ctx context.Context, repoID, id int64) (bool, error)

HasMilestoneByRepoID returns if the milestone exists in the repository.

func HasUnmergedPullRequestsByHeadInfo

func HasUnmergedPullRequestsByHeadInfo(ctx context.Context, 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 HasUserStopwatch

func HasUserStopwatch(ctx context.Context, userID int64) (exists bool, sw *Stopwatch, issue *Issue, err error)

HasUserStopwatch returns true if the user has a stopwatch

func HasWorkInProgressPrefix

func HasWorkInProgressPrefix(title string) bool

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

func InsertIssueComments

func InsertIssueComments(ctx context.Context, comments []*Comment) error

InsertIssueComments inserts many comments of issues.

func InsertIssues

func InsertIssues(ctx context.Context, issues ...*Issue) error

InsertIssues insert issues to database

func InsertMilestones

func InsertMilestones(ctx context.Context, ms ...*Milestone) (err error)

InsertMilestones creates milestones of repository.

func InsertPullRequests

func InsertPullRequests(ctx context.Context, prs ...*PullRequest) error

InsertPullRequests inserted pull requests

func InsertReviews

func InsertReviews(ctx context.Context, reviews []*Review) error

InsertReviews inserts review and review comments

func IsContentEmptyErr

func IsContentEmptyErr(err error) bool

IsContentEmptyErr returns true if err is a ContentEmptyErr

func IsErrCircularDependency

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 IsErrDependenciesLeft

func IsErrDependenciesLeft(err error) bool

IsErrDependenciesLeft checks if an error is a ErrDependenciesLeft.

func IsErrDependencyExists

func IsErrDependencyExists(err error) bool

IsErrDependencyExists checks if an error is a ErrDependencyExists.

func IsErrDependencyNotExists

func IsErrDependencyNotExists(err error) bool

IsErrDependencyNotExists checks if an error is a ErrDependencyExists.

func IsErrForbiddenIssueReaction

func IsErrForbiddenIssueReaction(err error) bool

IsErrForbiddenIssueReaction checks if an error is a ErrForbiddenIssueReaction.

func IsErrIssueIsClosed

func IsErrIssueIsClosed(err error) bool

IsErrIssueIsClosed checks if an error is a ErrIssueNotExist.

func IsErrIssueMaxPinReached

func IsErrIssueMaxPinReached(err error) bool

IsErrIssueMaxPinReached returns if the error is, that the User can't pin more Issues

func IsErrIssueNotExist

func IsErrIssueNotExist(err error) bool

IsErrIssueNotExist checks if an error is a ErrIssueNotExist.

func IsErrIssueWasClosed

func IsErrIssueWasClosed(err error) bool

IsErrIssueWasClosed checks if an error is a ErrIssueWasClosed.

func IsErrLabelNotExist

func IsErrLabelNotExist(err error) bool

IsErrLabelNotExist checks if an error is a ErrLabelNotExist.

func IsErrMilestoneNotExist

func IsErrMilestoneNotExist(err error) bool

IsErrMilestoneNotExist checks if an error is a ErrMilestoneNotExist.

func IsErrNewIssueInsert

func IsErrNewIssueInsert(err error) bool

IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert.

func IsErrNotValidReviewRequest

func IsErrNotValidReviewRequest(err error) bool

IsErrNotValidReviewRequest checks if an error is a ErrNotValidReviewRequest.

func IsErrOrgLabelNotExist

func IsErrOrgLabelNotExist(err error) bool

IsErrOrgLabelNotExist checks if an error is a OrgErrLabelNotExist.

func IsErrPullRequestAlreadyExists

func IsErrPullRequestAlreadyExists(err error) bool

IsErrPullRequestAlreadyExists checks if an error is a ErrPullRequestAlreadyExists.

func IsErrPullRequestNotExist

func IsErrPullRequestNotExist(err error) bool

IsErrPullRequestNotExist checks if an error is a ErrPullRequestNotExist.

func IsErrPullWasClosed

func IsErrPullWasClosed(err error) bool

IsErrPullWasClosed checks if an error is a ErrErrPullWasClosed.

func IsErrReactionAlreadyExist

func IsErrReactionAlreadyExist(err error) bool

IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist.

func IsErrRepoLabelNotExist

func IsErrRepoLabelNotExist(err error) bool

IsErrRepoLabelNotExist checks if an error is a RepoErrLabelNotExist.

func IsErrReviewNotExist

func IsErrReviewNotExist(err error) bool

IsErrReviewNotExist checks if an error is a ErrReviewNotExist.

func IsErrReviewRequestOnClosedPR

func IsErrReviewRequestOnClosedPR(err error) bool

IsErrReviewRequestOnClosedPR checks if an error is an ErrReviewRequestOnClosedPR.

func IsErrUnknownDependencyType

func IsErrUnknownDependencyType(err error) bool

IsErrUnknownDependencyType checks if an error is ErrUnknownDependencyType

func IsNewPinAllowed

func IsNewPinAllowed(ctx context.Context, repoID int64, isPull bool) (bool, error)

IsNewPinAllowed returns if a new Issue or Pull request can be pinned

func IsOfficialReviewer

func IsOfficialReviewer(ctx context.Context, issue *Issue, reviewer *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

func IsOfficialReviewerTeam(ctx context.Context, issue *Issue, team *organization.Team) (bool, error)

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

func IsUserAssignedToIssue

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

IsUserAssignedToIssue returns true when the user is assigned to the issue

func IsUserParticipantsOfIssue

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

IsUserParticipantsOfIssue return true if user is participants of an issue

func IssueAssignOrRemoveProject

func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_model.User, newProjectID, newColumnID int64) error

IssueAssignOrRemoveProject changes the project associated with an issue If newProjectID is 0, the issue is removed from the project

func IssueIDs

func IssueIDs(ctx context.Context, opts *IssuesOptions, otherConds ...builder.Cond) ([]int64, int64, error)

IssueIDs returns a list of issue ids by given conditions.

func IssueNoDependenciesLeft

func IssueNoDependenciesLeft(ctx context.Context, issue *Issue) (bool, error)

IssueNoDependenciesLeft checks if issue can be closed

func KeepLimitedContentHistory

func KeepLimitedContentHistory(ctx context.Context, issueID, commentID int64, limit int)

KeepLimitedContentHistory keeps at most `limit` history revisions, it will hard delete out-dated revisions, sorting by revision interval we can ignore all errors in this function, so we just log them

func LoadIssuesFromColumnList

func LoadIssuesFromColumnList(ctx context.Context, bs project_model.ColumnList, opts *IssuesOptions) (map[int64]IssueList, error)

LoadIssuesFromColumnList load issues assigned to the columns

func LockIssue

func LockIssue(ctx context.Context, opts *IssueLockOptions) error

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

func MakeIDsFromAPIAssigneesToAdd

func MakeIDsFromAPIAssigneesToAdd(ctx context.Context, oneAssignee string, multipleAssignees []string) (assigneeIDs []int64, err error)

MakeIDsFromAPIAssigneesToAdd returns an array with all assignee IDs

func MarkConversation

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

MarkConversation Add or remove Conversation mark for a code comment

func MarkReviewsAsNotStale

func MarkReviewsAsNotStale(ctx context.Context, issueID int64, commitID string) (err error)

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

func MarkReviewsAsStale

func MarkReviewsAsStale(ctx context.Context, issueID int64) (err error)

MarkReviewsAsStale marks existing reviews as stale

func MergeBlockedByOfficialReviewRequests

func MergeBlockedByOfficialReviewRequests(ctx context.Context, protectBranch *git_model.ProtectedBranch, pr *PullRequest) bool

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

func MergeBlockedByOutdatedBranch

func MergeBlockedByOutdatedBranch(protectBranch *git_model.ProtectedBranch, pr *PullRequest) bool

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

func MergeBlockedByRejectedReview

func MergeBlockedByRejectedReview(ctx context.Context, protectBranch *git_model.ProtectedBranch, pr *PullRequest) bool

MergeBlockedByRejectedReview returns true if merge is blocked by rejected reviews

func NewIssue

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

NewIssue creates new issue with labels for repository. The title will be cut off at 255 characters if it's longer than 255 characters.

func NewIssueLabel

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

NewIssueLabel creates a new issue-label relation.

func NewIssueLabels

func NewIssueLabels(ctx context.Context, issue *Issue, labels []*Label, doer *user_model.User) (err error)

NewIssueLabels creates a list of issue-label relations.

func NewIssueUsers

func NewIssueUsers(ctx context.Context, repo *repo_model.Repository, issue *Issue) error

NewIssueUsers inserts an issue related users

func NewIssueWithIndex

func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssueOptions) (err error)

NewIssueWithIndex creates issue with given index

func NewLabel

func NewLabel(ctx context.Context, l *Label) error

NewLabel creates a new label

func NewLabels

func NewLabels(ctx context.Context, labels ...*Label) error

NewLabels creates new labels

func NewMilestone

func NewMilestone(ctx context.Context, m *Milestone) (err error)

NewMilestone creates new milestone of repository.

func NewPullRequest

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

NewPullRequest creates new pull request with labels for repository.

func QueryIssueContentHistoryEditedCountMap

func QueryIssueContentHistoryEditedCountMap(dbCtx context.Context, issueID int64) (map[int64]int, error)

QueryIssueContentHistoryEditedCountMap query related history count of each comment (comment_id = 0 means the main issue) only return the count map for "edited" (history revision count > 1) issues or comments.

func RecalculateIssueIndexForRepo

func RecalculateIssueIndexForRepo(ctx context.Context, 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 RemoveDuplicateExclusiveIssueLabels

func RemoveDuplicateExclusiveIssueLabels(ctx context.Context, issue *Issue, label *Label, doer *user_model.User) (err error)

Remove all issue labels in the given exclusive scope

func RemoveIssueDependency

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

RemoveIssueDependency removes a dependency from an issue

func RemoveIssueWatchersByRepoID

func RemoveIssueWatchersByRepoID(ctx context.Context, userID, repoID int64) error

RemoveIssueWatchersByRepoID remove issue watchers by repoID

func ReplaceIssueLabels

func ReplaceIssueLabels(ctx context.Context, issue *Issue, labels []*Label, doer *user_model.User) (err error)

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

func ResolveIssueMentionsByVisibility

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

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

func ReviewExists

func ReviewExists(ctx context.Context, issue *Issue, treePath string, line int64) (bool, error)

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

func SaveIssueContentHistory

func SaveIssueContentHistory(ctx context.Context, posterID, issueID, commentID int64, editTime timeutil.TimeStamp, contentText string, isFirstCreated bool) error

SaveIssueContentHistory save history

func SoftDeleteIssueContentHistory

func SoftDeleteIssueContentHistory(dbCtx context.Context, historyID int64) error

SoftDeleteIssueContentHistory soft delete

func StopwatchExists

func StopwatchExists(ctx context.Context, userID, issueID int64) bool

StopwatchExists returns true if the stopwatch exists

func SubmitReview

func SubmitReview(ctx context.Context, 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 TokenizeCodeOwnersLine

func TokenizeCodeOwnersLine(line string) []string

func TotalTimesForEachUser

func TotalTimesForEachUser(ctx context.Context, options *FindTrackedTimesOptions) (map[*user_model.User]int64, error)

TotalTimesForEachUser returns the spent time in seconds for each user by an issue

func UnlockIssue

func UnlockIssue(ctx context.Context, opts *IssueLockOptions) error

UnlockIssue unlocks a previously locked issue.

func UpdateAllowEdits

func UpdateAllowEdits(ctx context.Context, pr *PullRequest) error

UpdateAllowEdits update if PR can be edited from maintainers

func UpdateComment

func UpdateComment(ctx context.Context, c *Comment, contentVersion int, doer *user_model.User) error

UpdateComment updates information of comment.

func UpdateCommentInvalidate

func UpdateCommentInvalidate(ctx context.Context, c *Comment) error

UpdateCommentInvalidate updates comment invalidated column

func UpdateCommentsMigrationsByType

func UpdateCommentsMigrationsByType(ctx context.Context, 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 UpdateIssueAttachments

func UpdateIssueAttachments(ctx context.Context, issueID int64, uuids []string) (err error)

UpdateIssueAttachments update attachments by UUIDs for the issue

func UpdateIssueCols

func UpdateIssueCols(ctx context.Context, issue *Issue, cols ...string) error

UpdateIssueCols updates cols of issue

func UpdateIssueDeadline

func UpdateIssueDeadline(ctx context.Context, 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(ctx context.Context, 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

func UpdateIssuesMigrationsByType(ctx context.Context, 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(ctx context.Context, l *Label) error

UpdateLabel updates label information.

func UpdateMilestone

func UpdateMilestone(ctx context.Context, m *Milestone, oldIsClosed bool) error

UpdateMilestone updates information of given milestone.

func UpdateMilestoneCounters

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

UpdateMilestoneCounters calculates NumIssues, NumClosesIssues and Completeness

func UpdateReactionsMigrationsByType

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

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

func UpdateReviewsMigrationsByType

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

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

Types

type AssignedIssuesOptions

type AssignedIssuesOptions struct {
	db.ListOptions
	AssigneeID  int64
	RepoOwnerID int64
}

func (*AssignedIssuesOptions) ToConds

func (opts *AssignedIssuesOptions) ToConds() builder.Cond

type CodeComments

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

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

func FetchCodeComments

func FetchCodeComments(ctx context.Context, issue *Issue, currentUser *user_model.User, showOutdatedComments bool) (CodeComments, error)

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

type CodeOwnerRule

type CodeOwnerRule struct {
	Rule     *regexp.Regexp
	Negative bool
	Users    []*user_model.User
	Teams    []*org_model.Team
}

func GetCodeOwnersFromContent

func GetCodeOwnersFromContent(ctx context.Context, data string) ([]*CodeOwnerRule, []string)

GetCodeOwnersFromContent returns the code owners configuration Return empty slice if files missing Return warning messages on parsing errors We're trying to do the best we can when parsing a file. Invalid lines are skipped. Non-existent users and teams too.

func ParseCodeOwnersLine

func ParseCodeOwnersLine(ctx context.Context, tokens []string) (*CodeOwnerRule, []string)

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_model.Project `xorm:"-"`
	Project          *project_model.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     *organization.Team `xorm:"-"`
	ResolveDoerID    int64
	ResolveDoer      *user_model.User `xorm:"-"`
	OldTitle         string
	NewTitle         string
	OldRef           string
	NewRef           string
	DependentIssueID int64  `xorm:"index"` // This is used by issue_service.deleteIssue
	DependentIssue   *Issue `xorm:"-"`

	CommitID        int64
	Line            int64 // - previous line / + proposed line
	TreePath        string
	Content         string        `xorm:"LONGTEXT"`
	ContentVersion  int           `xorm:"NOT NULL DEFAULT 0"`
	RenderedContent template.HTML `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(64)"`

	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

	CommentMetaData *CommentMetaData `xorm:"JSON TEXT"` // put all non-index metadata in a single field

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

	Commits     []*git_model.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

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

AddReviewRequest add a review request from one reviewer

func AddTeamReviewRequest

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

AddTeamReviewRequest add a review request from one team

func ChangeIssueStatus

func ChangeIssueStatus(ctx context.Context, issue *Issue, doer *user_model.User, isClosed bool) (*Comment, error)

ChangeIssueStatus changes issue status to open or closed.

func CreateAutoMergeComment

func CreateAutoMergeComment(ctx context.Context, typ CommentType, pr *PullRequest, doer *user_model.User) (comment *Comment, err error)

CreateAutoMergeComment is a internal function, only use it for CommentTypePRScheduledToAutoMerge and CommentTypePRUnScheduledToAutoMerge CommentTypes

func CreateComment

func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error)

CreateComment creates comment with context

func GetCommentByID

func GetCommentByID(ctx context.Context, id int64) (*Comment, error)

GetCommentByID returns the comment by given ID.

func RemoveReviewRequest

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

RemoveReviewRequest remove a review request from one reviewer

func RemoveTeamReviewRequest

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

RemoveTeamReviewRequest remove a review request from one team

func ToggleIssueAssignee

func ToggleIssueAssignee(ctx context.Context, issue *Issue, doer *user_model.User, assigneeID int64) (removed bool, comment *Comment, err error)

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

func (*Comment) APIURL

func (c *Comment) APIURL(ctx context.Context) string

APIURL formats a API-string to the issue-comment

func (*Comment) AddCrossReferences

func (c *Comment) AddCrossReferences(stdCtx context.Context, doer *user_model.User, removeOld bool) error

AddCrossReferences add cross references

func (*Comment) AfterDelete

func (c *Comment) AfterDelete(ctx context.Context)

AfterDelete is invoked from XORM after the object is deleted.

func (*Comment) AfterLoad

func (c *Comment) AfterLoad()

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 (c *Comment) CodeCommentLink(ctx context.Context) string

CodeCommentLink returns the url to a comment in code

func (*Comment) DiffSide

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

func (c *Comment) GetExternalID() int64

GetExternalID ExternalUserRemappable interface

func (*Comment) GetExternalName

func (c *Comment) GetExternalName() string

GetExternalName ExternalUserRemappable interface

func (*Comment) GetUserID

func (c *Comment) GetUserID() int64

GetUserID ExternalUserRemappable interface

func (*Comment) HTMLURL

func (c *Comment) HTMLURL(ctx context.Context) string

HTMLURL formats a URL-string to the issue-comment

func (*Comment) HasOriginalAuthor

func (c *Comment) HasOriginalAuthor() bool

HasOriginalAuthor returns if a comment was migrated and has an original author.

func (*Comment) HashTag

func (c *Comment) HashTag() string

HashTag returns unique hash tag for comment.

func (*Comment) IsResolved

func (c *Comment) IsResolved() bool

IsResolved check if an code comment is resolved

func (*Comment) IssueURL

func (c *Comment) IssueURL(ctx context.Context) string

IssueURL formats a URL-string to the issue

func (c *Comment) Link(ctx context.Context) string

Link formats a relative URL-string to the issue-comment

func (*Comment) LoadAssigneeUserAndTeam

func (c *Comment) LoadAssigneeUserAndTeam(ctx context.Context) error

LoadAssigneeUserAndTeam if comment.Type is CommentTypeAssignees, then load assignees

func (*Comment) LoadAttachments

func (c *Comment) LoadAttachments(ctx context.Context) error

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

func (*Comment) LoadDepIssueDetails

func (c *Comment) LoadDepIssueDetails(ctx context.Context) (err error)

LoadDepIssueDetails loads Dependent Issue Details

func (*Comment) LoadIssue

func (c *Comment) LoadIssue(ctx context.Context) (err error)

LoadIssue loads the issue reference for the comment

func (*Comment) LoadLabel

func (c *Comment) LoadLabel(ctx context.Context) error

LoadLabel if comment.Type is CommentTypeLabel, then load Label

func (*Comment) LoadMilestone

func (c *Comment) LoadMilestone(ctx context.Context) error

LoadMilestone if comment.Type is CommentTypeMilestone, then load milestone

func (*Comment) LoadPoster

func (c *Comment) LoadPoster(ctx context.Context) (err error)

LoadPoster loads comment poster

func (*Comment) LoadProject

func (c *Comment) LoadProject(ctx context.Context) error

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

func (*Comment) LoadPushCommits

func (c *Comment) LoadPushCommits(ctx context.Context) (err error)

LoadPushCommits Load push commits

func (*Comment) LoadReactions

func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository) (err error)

LoadReactions loads comment reactions

func (*Comment) LoadRefComment

func (c *Comment) LoadRefComment(ctx context.Context) (err error)

LoadRefComment loads comment that created this reference from database

func (*Comment) LoadRefIssue

func (c *Comment) LoadRefIssue(ctx context.Context) (err error)

LoadRefIssue loads comment that created this reference from database

func (*Comment) LoadResolveDoer

func (c *Comment) LoadResolveDoer(ctx context.Context) (err error)

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

func (*Comment) LoadReview

func (c *Comment) LoadReview(ctx context.Context) error

LoadReview loads the associated review

func (*Comment) LoadTime

func (c *Comment) LoadTime(ctx context.Context) error

LoadTime loads the associated time for a CommentTypeAddTimeManual

func (*Comment) PRURL

func (c *Comment) PRURL(ctx context.Context) string

PRURL formats a URL-string to the pull-request

func (c *Comment) RefCommentLink(ctx context.Context) string

RefCommentLink returns the relative URL for the comment that created this reference

func (*Comment) RefIssueIdent

func (c *Comment) RefIssueIdent(ctx context.Context) string

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

func (c *Comment) RefIssueLink(ctx context.Context) string

RefIssueLink returns the relative URL of the issue where this reference was created

func (*Comment) RefIssueTitle

func (c *Comment) RefIssueTitle(ctx context.Context) string

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

func (*Comment) RemapExternalUser

func (c *Comment) RemapExternalUser(externalName string, externalID, userID int64) error

RemapExternalUser ExternalUserRemappable interface

func (*Comment) UnsignedLine

func (c *Comment) UnsignedLine() uint64

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

func (*Comment) UpdateAttachments

func (c *Comment) UpdateAttachments(ctx context.Context, uuids []string) error

UpdateAttachments update attachments by UUIDs for the comment

type CommentList

type CommentList []*Comment

CommentList defines a list of comments

func FetchCodeCommentsByLine

func FetchCodeCommentsByLine(ctx context.Context, issue *Issue, currentUser *user_model.User, treePath string, line int64, showOutdatedComments bool) (CommentList, error)

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

func FindComments

func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, error)

FindComments returns all comments according options

func (CommentList) Issues

func (comments CommentList) Issues() IssueList

Issues returns all the issues of comments

func (CommentList) LoadAttachments

func (comments CommentList) LoadAttachments(ctx context.Context) (err error)

LoadAttachments loads attachments

func (CommentList) LoadAttachmentsByIssue

func (comments CommentList) LoadAttachmentsByIssue(ctx context.Context) error

LoadAttachmentsByIssue loads attachments by issue id

func (CommentList) LoadAttributes

func (comments CommentList) LoadAttributes(ctx context.Context) (err error)

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

func (CommentList) LoadIssues

func (comments CommentList) LoadIssues(ctx context.Context) error

LoadIssues loads issues of comments

func (CommentList) LoadPosters

func (comments CommentList) LoadPosters(ctx context.Context) error

LoadPosters loads posters

type CommentMetaData

type CommentMetaData struct {
	ProjectColumnID    int64  `json:"project_column_id,omitempty"`
	ProjectColumnTitle string `json:"project_column_title,omitempty"`
	ProjectTitle       string `json:"project_title,omitempty"`
}

CommentMetaData stores metadata for a comment, these data will not be changed once inserted into database

type CommentType

type CommentType int

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

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

	CommentTypeReopen // 1
	CommentTypeClose  // 2

	CommentTypeIssueRef   // 3 References.
	CommentTypeCommitRef  // 4 Reference from a commit (not part of a pull request)
	CommentTypeCommentRef // 5 Reference from a comment
	CommentTypePullRef    // 6 Reference from a pull request

	CommentTypeLabel        // 7 Labels changed
	CommentTypeMilestone    // 8 Milestone changed
	CommentTypeAssignees    // 9 Assignees changed
	CommentTypeChangeTitle  // 10 Change Title
	CommentTypeDeleteBranch // 11 Delete Branch

	CommentTypeStartTracking    // 12 Start a stopwatch for time tracking
	CommentTypeStopTracking     // 13 Stop a stopwatch for time tracking
	CommentTypeAddTimeManual    // 14 Add time manual for time tracking
	CommentTypeCancelTracking   // 15 Cancel a stopwatch for time tracking
	CommentTypeAddedDeadline    // 16 Added a due date
	CommentTypeModifiedDeadline // 17 Modified the due date
	CommentTypeRemovedDeadline  // 18 Removed a due date

	CommentTypeAddDependency    // 19 Dependency added
	CommentTypeRemoveDependency // 20 Dependency removed

	CommentTypeCode   // 21 Comment a line of code
	CommentTypeReview // 22 Reviews a pull request by giving general feedback

	CommentTypeLock   // 23 Lock an issue, giving only collaborators access
	CommentTypeUnlock // 24 Unlocks a previously locked issue

	CommentTypeChangeTargetBranch // 25 Change pull request's target branch

	CommentTypeDeleteTimeManual // 26 Delete time manual for time tracking

	CommentTypeReviewRequest   // 27 add or remove Request from one
	CommentTypeMergePull       // 28 merge pull request
	CommentTypePullRequestPush // 29 push to PR head branch

	CommentTypeProject       // 30 Project changed
	CommentTypeProjectColumn // 31 Project column changed

	CommentTypeDismissReview // 32 Dismiss Review

	CommentTypeChangeIssueRef // 33 Change issue ref

	CommentTypePRScheduledToAutoMerge   // 34 pr was scheduled to auto merge when checks succeed
	CommentTypePRUnScheduledToAutoMerge // 35 pr was un scheduled to auto merge when checks succeed

	CommentTypePin   // 36 pin Issue
	CommentTypeUnpin // 37 unpin Issue

	CommentTypeChangeTimeEstimate // 38 Change time estimate
)
const CommentTypeUndefined CommentType = -1

CommentTypeUndefined is used to search for comments of any type

func AsCommentType

func AsCommentType(typeName string) CommentType

func (CommentType) HasAttachmentSupport

func (t CommentType) HasAttachmentSupport() bool

func (CommentType) HasContentSupport

func (t CommentType) HasContentSupport() bool

func (CommentType) HasMailReplySupport

func (t CommentType) HasMailReplySupport() bool

func (CommentType) String

func (t CommentType) String() string

type ContentEmptyErr

type ContentEmptyErr struct{}

ContentEmptyErr represents an content empty error

func (ContentEmptyErr) Error

func (ContentEmptyErr) Error() string

type ContentHistory

type ContentHistory struct {
	ID             int64 `xorm:"pk autoincr"`
	PosterID       int64
	IssueID        int64              `xorm:"INDEX"`
	CommentID      int64              `xorm:"INDEX"`
	EditedUnix     timeutil.TimeStamp `xorm:"INDEX"`
	ContentText    string             `xorm:"LONGTEXT"`
	IsFirstCreated bool
	IsDeleted      bool
}

ContentHistory save issue/comment content history revisions.

func GetIssueContentHistoryAndPrev

func GetIssueContentHistoryAndPrev(dbCtx context.Context, issueID, id int64) (history, prevHistory *ContentHistory, err error)

GetIssueContentHistoryAndPrev get a history and the previous non-deleted history (to compare)

func GetIssueContentHistoryByID

func GetIssueContentHistoryByID(dbCtx context.Context, id int64) (*ContentHistory, error)

GetIssueContentHistoryByID get issue content history

func (*ContentHistory) TableName

func (m *ContentHistory) TableName() string

TableName provides the real table name

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
	ProjectTitle       string
	ProjectColumnID    int64
	ProjectColumnTitle string
	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 CreateReviewOptions

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

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

type DependencyInfo

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

type DependencyType int

DependencyType Defines Dependency Type Constants

const (
	DependencyTypeBlockedBy DependencyType = iota
	DependencyTypeBlocking
)

Define Dependency Types

type ErrCircularDependency

type ErrCircularDependency struct {
	IssueID      int64
	DependencyID int64
}

ErrCircularDependency represents a "DependencyCircular" kind of error.

func (ErrCircularDependency) Error

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

func (ErrCommentNotExist) Unwrap

func (err ErrCommentNotExist) Unwrap() error

type ErrDependenciesLeft

type ErrDependenciesLeft struct {
	IssueID int64
}

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

func (ErrDependenciesLeft) Error

func (err ErrDependenciesLeft) Error() string

type ErrDependencyExists

type ErrDependencyExists struct {
	IssueID      int64
	DependencyID int64
}

ErrDependencyExists represents a "DependencyAlreadyExists" kind of error.

func (ErrDependencyExists) Error

func (err ErrDependencyExists) Error() string

func (ErrDependencyExists) Unwrap

func (err ErrDependencyExists) Unwrap() error

type ErrDependencyNotExists

type ErrDependencyNotExists struct {
	IssueID      int64
	DependencyID int64
}

ErrDependencyNotExists represents a "DependencyAlreadyExists" kind of error.

func (ErrDependencyNotExists) Error

func (err ErrDependencyNotExists) Error() string

func (ErrDependencyNotExists) Unwrap

func (err ErrDependencyNotExists) Unwrap() error

type ErrForbiddenIssueReaction

type ErrForbiddenIssueReaction struct {
	Reaction string
}

ErrForbiddenIssueReaction is used when a forbidden reaction was try to created

func (ErrForbiddenIssueReaction) Error

func (err ErrForbiddenIssueReaction) Error() string

func (ErrForbiddenIssueReaction) Unwrap

func (err ErrForbiddenIssueReaction) Unwrap() error

type ErrIssueContentHistoryNotExist

type ErrIssueContentHistoryNotExist struct {
	ID int64
}

ErrIssueContentHistoryNotExist not exist error

func (ErrIssueContentHistoryNotExist) Error

Error error string

func (ErrIssueContentHistoryNotExist) Unwrap

type ErrIssueIsClosed

type ErrIssueIsClosed struct {
	ID     int64
	RepoID int64
	Index  int64
}

ErrIssueIsClosed represents a "IssueIsClosed" kind of error.

func (ErrIssueIsClosed) Error

func (err ErrIssueIsClosed) 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

func (ErrIssueNotExist) Unwrap

func (err ErrIssueNotExist) Unwrap() error

type ErrIssueStopwatchNotExist

type ErrIssueStopwatchNotExist struct {
	UserID  int64
	IssueID int64
}

ErrIssueStopwatchNotExist represents an error that stopwatch is not exist

func (ErrIssueStopwatchNotExist) Error

func (err ErrIssueStopwatchNotExist) Error() string

func (ErrIssueStopwatchNotExist) Unwrap

func (err ErrIssueStopwatchNotExist) Unwrap() error

type ErrIssueWasClosed

type ErrIssueWasClosed struct {
	ID    int64
	Index int64
}

ErrIssueWasClosed is used when close a closed issue

func (ErrIssueWasClosed) Error

func (err ErrIssueWasClosed) Error() string

type ErrLabelNotExist

type ErrLabelNotExist struct {
	LabelID int64
}

ErrLabelNotExist represents a "LabelNotExist" kind of error.

func (ErrLabelNotExist) Error

func (err ErrLabelNotExist) Error() string

func (ErrLabelNotExist) Unwrap

func (err ErrLabelNotExist) Unwrap() error

type ErrMilestoneNotExist

type ErrMilestoneNotExist struct {
	ID     int64
	RepoID int64
	Name   string
}

ErrMilestoneNotExist represents a "MilestoneNotExist" kind of error.

func (ErrMilestoneNotExist) Error

func (err ErrMilestoneNotExist) Error() string

func (ErrMilestoneNotExist) Unwrap

func (err ErrMilestoneNotExist) Unwrap() error

type ErrNewIssueInsert

type ErrNewIssueInsert struct {
	OriginalError error
}

ErrNewIssueInsert is used when the INSERT statement in newIssue fails

func (ErrNewIssueInsert) Error

func (err ErrNewIssueInsert) Error() string

type ErrNotValidReviewRequest

type ErrNotValidReviewRequest struct {
	Reason string
	UserID int64
	RepoID int64
}

ErrNotValidReviewRequest an not allowed review request modify

func (ErrNotValidReviewRequest) Error

func (err ErrNotValidReviewRequest) Error() string

func (ErrNotValidReviewRequest) Unwrap

func (err ErrNotValidReviewRequest) Unwrap() error

type ErrOrgLabelNotExist

type ErrOrgLabelNotExist struct {
	LabelID int64
	OrgID   int64
}

ErrOrgLabelNotExist represents a "OrgLabelNotExist" kind of error.

func (ErrOrgLabelNotExist) Error

func (err ErrOrgLabelNotExist) Error() string

func (ErrOrgLabelNotExist) Unwrap

func (err ErrOrgLabelNotExist) Unwrap() error

type ErrPullRequestAlreadyExists

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

ErrPullRequestAlreadyExists represents a "PullRequestAlreadyExists"-error

func (ErrPullRequestAlreadyExists) Error

func (err ErrPullRequestAlreadyExists) Error() string

Error does pretty-printing :D

func (ErrPullRequestAlreadyExists) Unwrap

func (err ErrPullRequestAlreadyExists) Unwrap() error

type ErrPullRequestNotExist

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

ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.

func (ErrPullRequestNotExist) Error

func (err ErrPullRequestNotExist) Error() string

func (ErrPullRequestNotExist) Unwrap

func (err ErrPullRequestNotExist) Unwrap() error

type ErrPullWasClosed

type ErrPullWasClosed struct {
	ID    int64
	Index int64
}

ErrPullWasClosed is used close a closed pull request

func (ErrPullWasClosed) Error

func (err ErrPullWasClosed) Error() string

type ErrReactionAlreadyExist

type ErrReactionAlreadyExist struct {
	Reaction string
}

ErrReactionAlreadyExist is used when a existing reaction was try to created

func (ErrReactionAlreadyExist) Error

func (err ErrReactionAlreadyExist) Error() string

func (ErrReactionAlreadyExist) Unwrap

func (err ErrReactionAlreadyExist) Unwrap() error

type ErrRepoLabelNotExist

type ErrRepoLabelNotExist struct {
	LabelID int64
	RepoID  int64
}

ErrRepoLabelNotExist represents a "RepoLabelNotExist" kind of error.

func (ErrRepoLabelNotExist) Error

func (err ErrRepoLabelNotExist) Error() string

func (ErrRepoLabelNotExist) Unwrap

func (err ErrRepoLabelNotExist) Unwrap() error

type ErrReviewNotExist

type ErrReviewNotExist struct {
	ID int64
}

ErrReviewNotExist represents a "ReviewNotExist" kind of error.

func (ErrReviewNotExist) Error

func (err ErrReviewNotExist) Error() string

func (ErrReviewNotExist) Unwrap

func (err ErrReviewNotExist) Unwrap() error

type ErrReviewRequestOnClosedPR

type ErrReviewRequestOnClosedPR struct{}

ErrReviewRequestOnClosedPR represents an error when an user tries to request a re-review on a closed or merged PR.

func (ErrReviewRequestOnClosedPR) Error

func (err ErrReviewRequestOnClosedPR) Error() string

func (ErrReviewRequestOnClosedPR) Unwrap

func (err ErrReviewRequestOnClosedPR) Unwrap() error

type ErrUnknownDependencyType

type ErrUnknownDependencyType struct {
	Type DependencyType
}

ErrUnknownDependencyType represents an error where an unknown dependency type was passed

func (ErrUnknownDependencyType) Error

func (err ErrUnknownDependencyType) Error() string

func (ErrUnknownDependencyType) Unwrap

func (err ErrUnknownDependencyType) Unwrap() error

type ErrUserMustCollaborator

type ErrUserMustCollaborator struct {
	UserID   int64
	RepoName string
}

ErrUserMustCollaborator represents an error that the user must be a collaborator to a given repo.

type FindCommentsOptions

type FindCommentsOptions struct {
	db.ListOptions
	RepoID      int64
	IssueID     int64
	ReviewID    int64
	Since       int64
	Before      int64
	Line        int64
	TreePath    string
	Type        CommentType
	IssueIDs    []int64
	Invalidated optional.Option[bool]
	IsPull      optional.Option[bool]
}

FindCommentsOptions describes the conditions to Find comments

func (FindCommentsOptions) ToConds

func (opts FindCommentsOptions) ToConds() builder.Cond

ToConds implements FindOptions interface

type FindMilestoneOptions

type FindMilestoneOptions struct {
	db.ListOptions
	RepoID   int64
	IsClosed optional.Option[bool]
	Name     string
	SortType string
	RepoCond builder.Cond
	RepoIDs  []int64
}

FindMilestoneOptions contain options to get milestones

func (FindMilestoneOptions) ToConds

func (opts FindMilestoneOptions) ToConds() builder.Cond

func (FindMilestoneOptions) ToOrders

func (opts FindMilestoneOptions) ToOrders() string

type FindReactionsOptions

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

FindReactionsOptions describes the conditions to Find reactions

type FindReviewOptions

type FindReviewOptions struct {
	db.ListOptions
	Types        []ReviewType
	IssueID      int64
	ReviewerID   int64
	OfficialOnly bool
	Dismissed    optional.Option[bool]
}

FindReviewOptions represent possible filters to find reviews

type FindTrackedTimesOptions

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

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

func (*FindTrackedTimesOptions) ToConds

func (opts *FindTrackedTimesOptions) ToConds() builder.Cond

toCond will convert each condition into a xorm-Cond

func (*FindTrackedTimesOptions) ToJoins

func (opts *FindTrackedTimesOptions) ToJoins() []db.JoinFunc

type Issue

type Issue struct {
	ID               int64                  `xorm:"pk autoincr"`
	RepoID           int64                  `xorm:"INDEX UNIQUE(repo_index)"`
	Repo             *repo_model.Repository `xorm:"-"`
	Index            int64                  `xorm:"UNIQUE(repo_index)"` // Index in one repository.
	PosterID         int64                  `xorm:"INDEX"`
	Poster           *user_model.User       `xorm:"-"`
	OriginalAuthor   string
	OriginalAuthorID int64         `xorm:"index"`
	Title            string        `xorm:"name"`
	Content          string        `xorm:"LONGTEXT"`
	RenderedContent  template.HTML `xorm:"-"`
	ContentVersion   int           `xorm:"NOT NULL DEFAULT 0"`
	Labels           []*Label      `xorm:"-"`

	MilestoneID int64      `xorm:"INDEX"`
	Milestone   *Milestone `xorm:"-"`

	Project    *project_model.Project `xorm:"-"`
	Priority   int
	AssigneeID int64            `xorm:"-"`
	Assignee   *user_model.User `xorm:"-"`

	IsClosed    bool         `xorm:"INDEX"`
	IsRead      bool         `xorm:"-"`
	IsPull      bool         `xorm:"INDEX"` // Indicates whether is a pull request or not.
	PullRequest *PullRequest `xorm:"-"`
	NumComments int

	// TODO: RemoveIssueRef: see "repo/issue/branch_selector_field.tmpl"
	Ref string

	PinOrder int `xorm:"DEFAULT 0"`

	DeadlineUnix timeutil.TimeStamp `xorm:"INDEX"`

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

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

	Comments         CommentList        `xorm:"-"`
	Reactions        ReactionList       `xorm:"-"`
	TotalTrackedTime int64              `xorm:"-"`
	Assignees        []*user_model.User `xorm:"-"`

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

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

	// Time estimate
	TimeEstimate int64 `xorm:"NOT NULL DEFAULT 0"`
	// contains filtered or unexported fields
}

Issue represents an issue or pull request of repository.

func GetAssignedIssues

func GetAssignedIssues(ctx context.Context, opts *AssignedIssuesOptions) ([]*Issue, int64, error)

func GetIssueByID

func GetIssueByID(ctx context.Context, id int64) (*Issue, error)

GetIssueByID returns an issue by given ID.

func GetIssueByIndex

func GetIssueByIndex(ctx context.Context, repoID, index int64) (*Issue, error)

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

func GetIssueWithAttrsByIndex

func GetIssueWithAttrsByIndex(ctx context.Context, repoID, index int64) (*Issue, error)

GetIssueWithAttrsByIndex returns issue by index in a repository.

func (*Issue) APIURL

func (issue *Issue) APIURL(ctx context.Context) string

APIURL returns the absolute APIURL to this issue.

func (*Issue) AddCrossReferences

func (issue *Issue) AddCrossReferences(stdCtx context.Context, doer *user_model.User, removeOld bool) error

AddCrossReferences add cross repositories references.

func (*Issue) BlockedByDependencies

func (issue *Issue) BlockedByDependencies(ctx context.Context, opts db.ListOptions) (issueDeps []*DependencyInfo, err error)

BlockedByDependencies finds all Dependencies an issue is blocked by

func (*Issue) BlockingDependencies

func (issue *Issue) BlockingDependencies(ctx context.Context) (issueDeps []*DependencyInfo, err error)

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

func (*Issue) DiffURL

func (issue *Issue) DiffURL() string

DiffURL returns the absolute URL to this diff

func (*Issue) GetExternalID

func (issue *Issue) GetExternalID() int64

GetExternalID ExternalUserRemappable interface

func (*Issue) GetExternalName

func (issue *Issue) GetExternalName() string

GetExternalName ExternalUserRemappable interface

func (*Issue) GetIsRead

func (issue *Issue) GetIsRead(ctx context.Context, userID int64) error

GetIsRead load the `IsRead` field of the issue

func (*Issue) GetLastComment

func (issue *Issue) GetLastComment(ctx context.Context) (*Comment, error)

GetLastComment return last comment for the current issue.

func (*Issue) GetLastEventLabel

func (issue *Issue) GetLastEventLabel() string

GetLastEventLabel returns the localization label for the current issue.

func (*Issue) GetLastEventLabelFake

func (issue *Issue) GetLastEventLabelFake() string

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

func (*Issue) GetLastEventTimestamp

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

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

func (*Issue) GetParticipantIDsByIssue

func (issue *Issue) GetParticipantIDsByIssue(ctx context.Context) ([]int64, error)

GetParticipantIDsByIssue returns all userIDs who are participated in comments of an issue and issue author

func (*Issue) GetTasks

func (issue *Issue) GetTasks() int

GetTasks returns the amount of tasks in the issues content

func (*Issue) GetTasksDone

func (issue *Issue) GetTasksDone() int

GetTasksDone returns the amount of completed tasks in the issues content

func (*Issue) GetUserID

func (issue *Issue) GetUserID() int64

GetUserID ExternalUserRemappable interface

func (*Issue) HTMLURL

func (issue *Issue) HTMLURL() string

HTMLURL returns the absolute URL to this issue.

func (*Issue) HasOriginalAuthor

func (issue *Issue) HasOriginalAuthor() bool

HasOriginalAuthor returns if an issue was migrated and has an original author.

func (*Issue) HashTag

func (issue *Issue) HashTag() string

HashTag returns unique hash tag for issue.

func (*Issue) IsOverdue

func (issue *Issue) IsOverdue() bool

IsOverdue checks if the issue is overdue

func (*Issue) IsPinned

func (issue *Issue) IsPinned() bool

IsPinned returns if a Issue is pinned

func (*Issue) IsPoster

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

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

func (*Issue) IsTimetrackerEnabled

func (issue *Issue) IsTimetrackerEnabled(ctx context.Context) bool

IsTimetrackerEnabled returns true if the repo enables timetracking

func (issue *Issue) Link() string

Link returns the issue's relative URL.

func (*Issue) LoadAssignees

func (issue *Issue) LoadAssignees(ctx context.Context) (err error)

LoadAssignees load assignees of this issue.

func (*Issue) LoadAttachments

func (issue *Issue) LoadAttachments(ctx context.Context) (err error)

func (*Issue) LoadAttributes

func (issue *Issue) LoadAttributes(ctx context.Context) (err error)

LoadAttributes loads the attribute of this issue.

func (*Issue) LoadDiscussComments

func (issue *Issue) LoadDiscussComments(ctx context.Context) error

LoadDiscussComments loads discuss comments

func (*Issue) LoadLabels

func (issue *Issue) LoadLabels(ctx context.Context) (err error)

LoadLabels loads labels

func (*Issue) LoadMilestone

func (issue *Issue) LoadMilestone(ctx context.Context) (err error)

LoadMilestone load milestone of this issue.

func (*Issue) LoadPoster

func (issue *Issue) LoadPoster(ctx context.Context) (err error)

LoadPoster loads poster

func (*Issue) LoadProject

func (issue *Issue) LoadProject(ctx context.Context) (err error)

LoadProject load the project the issue was assigned to

func (*Issue) LoadPullRequest

func (issue *Issue) LoadPullRequest(ctx context.Context) (err error)

LoadPullRequest loads pull request info

func (*Issue) LoadRepo

func (issue *Issue) LoadRepo(ctx context.Context) (err error)

LoadRepo loads issue's repository

func (*Issue) LoadTotalTimes

func (issue *Issue) LoadTotalTimes(ctx context.Context) (err error)

LoadTotalTimes load total tracked time

func (*Issue) MovePin

func (issue *Issue) MovePin(ctx context.Context, newPosition int) error

MovePin moves a Pinned Issue to a new Position

func (*Issue) PatchURL

func (issue *Issue) PatchURL() string

PatchURL returns the absolute URL to this patch

func (*Issue) Pin

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

Pin pins a Issue

func (*Issue) PinOrUnpin

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

PinOrUnpin pins or unpins a Issue

func (*Issue) ProjectColumnID

func (issue *Issue) ProjectColumnID(ctx context.Context) int64

ProjectColumnID return project column id if issue was assigned to one

func (*Issue) RemapExternalUser

func (issue *Issue) RemapExternalUser(externalName string, externalID, userID int64) error

RemapExternalUser ExternalUserRemappable interface

func (*Issue) ResetAttributesLoaded

func (issue *Issue) ResetAttributesLoaded()

func (*Issue) State

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

State returns string representation of issue status.

func (*Issue) Unpin

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

UnpinIssue unpins a Issue

type IssueAssignees

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

IssueAssignees saves all issue assignees

type IssueContentListItem

type IssueContentListItem struct {
	UserID         int64
	UserName       string
	UserFullName   string
	UserAvatarLink string

	HistoryID      int64
	EditedUnix     timeutil.TimeStamp
	IsFirstCreated bool
	IsDeleted      bool
}

IssueContentListItem the list for web ui

func FetchIssueContentHistoryList

func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error)

FetchIssueContentHistoryList fetch list

type IssueDependency

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

IssueDependency represents an issue dependency

type IssueIndex

type IssueIndex db.ResourceIndex

IssueIndex represents the issue index table

type IssueLabel

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

IssueLabel represents an issue-label relation.

type IssueList

type IssueList []*Issue

IssueList defines a list of issues

func GetIssuesByIDs

func GetIssuesByIDs(ctx context.Context, issueIDs []int64, keepOrder ...bool) (IssueList, error)

GetIssuesByIDs return issues with the given IDs. If keepOrder is true, the order of the returned issues will be the same as the given IDs.

func GetPinnedIssues

func GetPinnedIssues(ctx context.Context, repoID int64, isPull bool) (IssueList, error)

GetPinnedIssues returns the pinned Issues for the given Repo and type

func Issues

func Issues(ctx context.Context, opts *IssuesOptions) (IssueList, error)

Issues returns a list of issues by given conditions.

func LoadIssuesFromColumn

func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *IssuesOptions) (IssueList, error)

LoadIssuesFromColumn load issues assigned to this column

func (IssueList) GetApprovalCounts

func (issues IssueList) GetApprovalCounts(ctx context.Context) (map[int64][]*ReviewCount, error)

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

func (IssueList) LoadAssignees

func (issues IssueList) LoadAssignees(ctx context.Context) error

func (IssueList) LoadAttachments

func (issues IssueList) LoadAttachments(ctx context.Context) (err error)

LoadAttachments loads attachments

func (IssueList) LoadAttributes

func (issues IssueList) LoadAttributes(ctx context.Context) error

loadAttributes loads all attributes, expect for attachments and comments

func (IssueList) LoadComments

func (issues IssueList) LoadComments(ctx context.Context) error

LoadComments loads comments

func (IssueList) LoadDiscussComments

func (issues IssueList) LoadDiscussComments(ctx context.Context) error

LoadDiscussComments loads discuss comments

func (IssueList) LoadIsRead

func (issues IssueList) LoadIsRead(ctx context.Context, userID int64) error

func (IssueList) LoadLabels

func (issues IssueList) LoadLabels(ctx context.Context) error

func (IssueList) LoadMilestones

func (issues IssueList) LoadMilestones(ctx context.Context) error

func (IssueList) LoadPosters

func (issues IssueList) LoadPosters(ctx context.Context) error

func (IssueList) LoadProjects

func (issues IssueList) LoadProjects(ctx context.Context) error

func (IssueList) LoadPullRequests

func (issues IssueList) LoadPullRequests(ctx context.Context) error

LoadPullRequests loads pull requests

func (IssueList) LoadRepositories

func (issues IssueList) LoadRepositories(ctx context.Context) (repo_model.RepositoryList, error)

LoadRepositories loads issues' all repositories

type IssueLockOptions

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

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

type IssueStats

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

IssueStats represents issue statistic information.

func GetIssueStats

func GetIssueStats(ctx context.Context, opts *IssuesOptions) (*IssueStats, error)

GetIssueStats returns issue statistic information by given conditions.

type IssueUser

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

IssueUser represents an issue-user relation.

type IssueWatch

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

IssueWatch is connection request for receiving issue notification.

func GetIssueWatch

func GetIssueWatch(ctx context.Context, userID, issueID int64) (iw *IssueWatch, exists bool, err error)

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

type IssueWatchList

type IssueWatchList []*IssueWatch

IssueWatchList contains IssueWatch

func GetIssueWatchers

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

GetIssueWatchers returns watchers/unwatchers of a given issue

type IssuesOptions

type IssuesOptions struct {
	Paginator          *db.ListOptions
	RepoIDs            []int64 // overwrites RepoCond if the length is not 0
	AllPublic          bool    // include also all public repositories
	RepoCond           builder.Cond
	AssigneeID         optional.Option[int64]
	PosterID           optional.Option[int64]
	MentionedID        int64
	ReviewRequestedID  int64
	ReviewedID         int64
	SubscriberID       int64
	MilestoneIDs       []int64
	ProjectID          int64
	ProjectColumnID    int64
	IsClosed           optional.Option[bool]
	IsPull             optional.Option[bool]
	LabelIDs           []int64
	IncludedLabelNames []string
	ExcludedLabelNames []string
	IncludeMilestones  []string
	SortType           string
	IssueIDs           []int64
	UpdatedAfterUnix   int64
	UpdatedBeforeUnix  int64
	// prioritize issues from this repo
	PriorityRepoID int64
	IsArchived     optional.Option[bool]
	Org            *organization.Organization // issues permission scope
	Team           *organization.Team         // issues permission scope
	User           *user_model.User           // issues permission scope
}

IssuesOptions represents options of an issue.

func (*IssuesOptions) Copy

func (o *IssuesOptions) Copy(edit ...func(options *IssuesOptions)) *IssuesOptions

Copy returns a copy of the options. Be careful, it's not a deep copy, so `IssuesOptions.RepoIDs = {...}` is OK while `IssuesOptions.RepoIDs[0] = ...` is not.

type Label

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

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

	ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT NULL"`
}

Label represents a label of repository for issues.

func GetLabelByID

func GetLabelByID(ctx context.Context, labelID int64) (*Label, error)

GetLabelByID returns a label by given ID.

func GetLabelInOrgByID

func GetLabelInOrgByID(ctx context.Context, orgID, labelID int64) (*Label, error)

GetLabelInOrgByID returns a label by ID in given organization.

func GetLabelInOrgByName

func GetLabelInOrgByName(ctx context.Context, orgID int64, labelName string) (*Label, error)

GetLabelInOrgByName returns a label by name in given organization.

func GetLabelInRepoByID

func GetLabelInRepoByID(ctx context.Context, repoID, labelID int64) (*Label, error)

GetLabelInRepoByID returns a label by ID in given repository.

func GetLabelInRepoByName

func GetLabelInRepoByName(ctx context.Context, repoID int64, labelName string) (*Label, error)

GetLabelInRepoByName returns a label by name in given repository.

func GetLabelsByIDs

func GetLabelsByIDs(ctx context.Context, labelIDs []int64, cols ...string) ([]*Label, error)

GetLabelsByIDs returns a list of labels by IDs

func GetLabelsByIssueID

func GetLabelsByIssueID(ctx context.Context, issueID int64) ([]*Label, error)

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

func GetLabelsByOrgID

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

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

func GetLabelsByRepoID

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

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

func GetLabelsInOrgByIDs

func GetLabelsInOrgByIDs(ctx context.Context, orgID int64, labelIDs []int64) ([]*Label, error)

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

func GetLabelsInRepoByIDs

func GetLabelsInRepoByIDs(ctx context.Context, repoID int64, labelIDs []int64) ([]*Label, error)

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

func RemoveDuplicateExclusiveLabels

func RemoveDuplicateExclusiveLabels(labels []*Label) []*Label

Ensure only one label of a given scope exists, with labels at the end of the array getting preference over earlier ones.

func (*Label) BelongsToOrg

func (l *Label) BelongsToOrg() bool

BelongsToOrg returns true if label is an organization label

func (*Label) BelongsToRepo

func (l *Label) BelongsToRepo() bool

BelongsToRepo returns true if label is a repository label

func (*Label) CalOpenIssues

func (l *Label) CalOpenIssues()

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

func (*Label) CalOpenOrgIssues

func (l *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64)

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

func (*Label) ExclusiveScope

func (l *Label) ExclusiveScope() string

ExclusiveScope returns scope substring of label name, or empty string if none exists

func (*Label) IsArchived

func (l *Label) IsArchived() bool

IsArchived returns true if label is an archived

func (*Label) LoadSelectedLabelsAfterClick

func (l *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64, currentSelectedExclusiveScopes []string)

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

func (*Label) SetArchived

func (l *Label) SetArchived(isArchived bool)

SetArchived set the label as archived

type Milestone

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

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

	TotalTrackedTime int64 `xorm:"-"`
}

Milestone represents a milestone of repository.

func GetMilestoneByRepoID

func GetMilestoneByRepoID(ctx context.Context, repoID, id int64) (*Milestone, error)

GetMilestoneByRepoID returns the milestone in a repository.

func GetMilestoneByRepoIDANDName

func GetMilestoneByRepoIDANDName(ctx context.Context, repoID int64, name string) (*Milestone, error)

GetMilestoneByRepoIDANDName return a milestone if one exist by name and repo

func (*Milestone) AfterLoad

func (m *Milestone) AfterLoad()

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

func (*Milestone) BeforeUpdate

func (m *Milestone) BeforeUpdate()

BeforeUpdate is invoked from XORM before updating this object.

func (*Milestone) LoadTotalTrackedTime

func (m *Milestone) LoadTotalTrackedTime(ctx context.Context) error

LoadTotalTrackedTime loads the tracked time for the milestone

func (*Milestone) State

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

State returns string representation of milestone status.

type MilestoneList

type MilestoneList []*Milestone

MilestoneList is a list of milestones offering additional functionality

func (MilestoneList) LoadTotalTrackedTimes

func (milestones MilestoneList) LoadTotalTrackedTimes(ctx context.Context) error

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

type MilestonesStats

type MilestonesStats struct {
	OpenCount, ClosedCount int64
}

MilestonesStats represents milestone statistic information.

func GetMilestonesStatsByRepoCondAndKw

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

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

func (MilestonesStats) Total

func (m MilestonesStats) Total() int64

Total returns the total counts of milestones

type NewIssueOptions

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

NewIssueOptions represents the options of a new issue.

type PullRequest

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

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

	IssueID                 int64  `xorm:"INDEX"`
	Issue                   *Issue `xorm:"-"`
	Index                   int64
	RequestedReviewers      []*user_model.User `xorm:"-"`
	RequestedReviewersTeams []*org_model.Team  `xorm:"-"`

	HeadRepoID          int64                  `xorm:"INDEX"`
	HeadRepo            *repo_model.Repository `xorm:"-"`
	BaseRepoID          int64                  `xorm:"INDEX"`
	BaseRepo            *repo_model.Repository `xorm:"-"`
	HeadBranch          string
	HeadCommitID        string `xorm:"-"`
	BaseBranch          string
	MergeBase           string `xorm:"VARCHAR(64)"`
	AllowMaintainerEdit bool   `xorm:"NOT NULL DEFAULT false"`

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

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

PullRequest represents relation between pull request and repositories.

func GetAllUnmergedAgitPullRequestByPoster

func GetAllUnmergedAgitPullRequestByPoster(ctx context.Context, uid int64) ([]*PullRequest, error)

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

func GetLatestPullRequestByHeadInfo

func GetLatestPullRequestByHeadInfo(ctx context.Context, repoID int64, branch string) (*PullRequest, error)

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

func GetPullRequestByBaseHeadInfo

func GetPullRequestByBaseHeadInfo(ctx context.Context, baseID, headID int64, base, head string) (*PullRequest, error)

GetPullRequestByBaseHeadInfo returns the pull request by given base and head

func GetPullRequestByID

func GetPullRequestByID(ctx context.Context, id int64) (*PullRequest, error)

GetPullRequestByID returns a pull request by given ID.

func GetPullRequestByIndex

func GetPullRequestByIndex(ctx context.Context, repoID, index int64) (*PullRequest, error)

GetPullRequestByIndex returns a pull request by the given index

func GetPullRequestByIssueID

func GetPullRequestByIssueID(ctx context.Context, issueID int64) (*PullRequest, error)

GetPullRequestByIssueID returns pull request by given issue ID.

func GetPullRequestByIssueIDWithNoAttributes

func GetPullRequestByIssueIDWithNoAttributes(ctx context.Context, issueID int64) (*PullRequest, error)

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

func GetPullRequestByMergedCommit

func GetPullRequestByMergedCommit(ctx context.Context, repoID int64, sha string) (*PullRequest, error)

GetPullRequestByMergedCommit returns a merged pull request by the given commit

func GetUnmergedPullRequest

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

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

func GetUnmergedPullRequestsByBaseInfo

func GetUnmergedPullRequestsByBaseInfo(ctx context.Context, repoID int64, branch string) ([]*PullRequest, error)

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

func GetUnmergedPullRequestsByHeadInfo

func GetUnmergedPullRequestsByHeadInfo(ctx context.Context, repoID int64, branch string) ([]*PullRequest, error)

GetUnmergedPullRequestsByHeadInfo returns all pull requests that are open and has not been merged

func (*PullRequest) CanAutoMerge

func (pr *PullRequest) CanAutoMerge() bool

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

func (*PullRequest) GetApprovalCounts

func (pr *PullRequest) GetApprovalCounts(ctx context.Context) ([]*ReviewCount, error)

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

func (*PullRequest) GetApprovers

func (pr *PullRequest) GetApprovers(ctx context.Context) string

GetApprovers returns the approvers of the pull request

func (pr *PullRequest) GetBaseBranchLink(ctx context.Context) string

GetBaseBranchLink returns the relative URL of the base branch

func (*PullRequest) GetGitHeadBranchRefName

func (pr *PullRequest) GetGitHeadBranchRefName() string

func (*PullRequest) GetGitRefName

func (pr *PullRequest) GetGitRefName() string

GetGitRefName returns git ref for hidden pull request branch

func (pr *PullRequest) GetHeadBranchLink(ctx context.Context) string

GetHeadBranchLink returns the relative URL of the head branch

func (*PullRequest) GetReviewCommentsCount

func (pr *PullRequest) GetReviewCommentsCount(ctx context.Context) int

GetReviewCommentsCount returns the number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)

func (*PullRequest) GetWorkInProgressPrefix

func (pr *PullRequest) GetWorkInProgressPrefix(ctx context.Context) string

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

func (*PullRequest) IsAgitFlow

func (pr *PullRequest) IsAgitFlow() bool

func (*PullRequest) IsAncestor

func (pr *PullRequest) IsAncestor() bool

IsAncestor returns true if the Head Commit of this PR is an ancestor of the Base Commit

func (*PullRequest) IsChecking

func (pr *PullRequest) IsChecking() bool

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

func (*PullRequest) IsEmpty

func (pr *PullRequest) IsEmpty() bool

IsEmpty returns true if this pull request is empty.

func (*PullRequest) IsFilesConflicted

func (pr *PullRequest) IsFilesConflicted() bool

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

func (*PullRequest) IsFromFork

func (pr *PullRequest) IsFromFork() bool

IsFromFork return true if this PR is from a fork.

func (*PullRequest) IsSameRepo

func (pr *PullRequest) IsSameRepo() bool

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

func (*PullRequest) IsWorkInProgress

func (pr *PullRequest) IsWorkInProgress(ctx context.Context) bool

IsWorkInProgress determine if the Pull Request is a Work In Progress by its title Issue must be set before this method can be called.

func (*PullRequest) LoadAttributes

func (pr *PullRequest) LoadAttributes(ctx context.Context) (err error)

LoadAttributes loads pull request attributes from database Note: don't try to get Issue because will end up recursive querying.

func (*PullRequest) LoadBaseRepo

func (pr *PullRequest) LoadBaseRepo(ctx context.Context) (err error)

LoadBaseRepo loads the target repository. ErrRepoNotExist may be returned.

func (*PullRequest) LoadHeadRepo

func (pr *PullRequest) LoadHeadRepo(ctx context.Context) (err error)

LoadHeadRepo loads the head repository, pr.HeadRepo will remain nil if it does not exist and thus ErrRepoNotExist will never be returned

func (*PullRequest) LoadIssue

func (pr *PullRequest) LoadIssue(ctx context.Context) (err error)

LoadIssue loads issue information from database

func (*PullRequest) LoadRequestedReviewers

func (pr *PullRequest) LoadRequestedReviewers(ctx context.Context) error

LoadRequestedReviewers loads the requested reviewers.

func (*PullRequest) LoadRequestedReviewersTeams

func (pr *PullRequest) LoadRequestedReviewersTeams(ctx context.Context) error

LoadRequestedReviewersTeams loads the requested reviewers teams.

func (*PullRequest) Mergeable

func (pr *PullRequest) Mergeable(ctx context.Context) bool

Mergeable returns if the pullrequest is mergeable.

func (*PullRequest) MustHeadUserName

func (pr *PullRequest) MustHeadUserName(ctx context.Context) string

MustHeadUserName returns the HeadRepo's username if failed return blank

func (*PullRequest) ResolveCrossReferences

func (pr *PullRequest) ResolveCrossReferences(ctx context.Context) ([]*Comment, error)

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

func (*PullRequest) SetMerged

func (pr *PullRequest) SetMerged(ctx context.Context) (bool, error)

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

func (*PullRequest) String

func (pr *PullRequest) String() string

func (*PullRequest) Update

func (pr *PullRequest) Update(ctx context.Context) error

Update updates all fields of pull request.

func (*PullRequest) UpdateCols

func (pr *PullRequest) UpdateCols(ctx context.Context, cols ...string) error

UpdateCols updates specific fields of pull request.

func (*PullRequest) UpdateColsIfNotMerged

func (pr *PullRequest) UpdateColsIfNotMerged(ctx context.Context, cols ...string) error

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

func (*PullRequest) UpdateCommitDivergence

func (pr *PullRequest) UpdateCommitDivergence(ctx context.Context, ahead, behind int) error

UpdateCommitDivergence update Divergence of a pull request

type PullRequestFlow

type PullRequestFlow int

PullRequestFlow the flow of pull request

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

type PullRequestList

type PullRequestList []*PullRequest

PullRequestList defines a list of pull requests

func GetPullRequestByIssueIDs

func GetPullRequestByIssueIDs(ctx context.Context, issueIDs []int64) (PullRequestList, error)

GetPullRequestByIssueIDs returns all pull requests by issue ids

func PullRequests

func PullRequests(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) (PullRequestList, int64, error)

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

func (PullRequestList) GetIssueIDs

func (prs PullRequestList) GetIssueIDs() []int64

GetIssueIDs returns all issue ids

func (PullRequestList) LoadAttributes

func (prs PullRequestList) LoadAttributes(ctx context.Context) error

func (PullRequestList) LoadIssues

func (prs PullRequestList) LoadIssues(ctx context.Context) (IssueList, error)

func (PullRequestList) LoadRepositories

func (prs PullRequestList) LoadRepositories(ctx context.Context) error

func (PullRequestList) LoadReviewCommentsCounts

func (prs PullRequestList) LoadReviewCommentsCounts(ctx context.Context) (map[int64]int, error)

func (PullRequestList) LoadReviews

func (prs PullRequestList) LoadReviews(ctx context.Context) (ReviewList, error)

type PullRequestStatus

type PullRequestStatus int

PullRequestStatus defines pull request status

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

Enumerate all the pull request status

func (PullRequestStatus) String

func (status PullRequestStatus) String() string

type PullRequestType

type PullRequestType int

PullRequestType defines pull request type

const (
	PullRequestGitea PullRequestType = iota
	PullRequestGit
)

Enumerate all the pull request types

type PullRequestsOptions

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

PullRequestsOptions holds the options for PRs

type PushActionContent

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

PushActionContent is content of push pull comment

type Reaction

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

Reaction represents a reactions on issues and comments.

func CreateReaction

func CreateReaction(ctx context.Context, opts *ReactionOptions) (*Reaction, error)

CreateReaction creates reaction for issue or comment.

func (*Reaction) GetExternalID

func (r *Reaction) GetExternalID() int64

GetExternalID ExternalUserRemappable interface

func (*Reaction) GetExternalName

func (r *Reaction) GetExternalName() string

GetExternalName ExternalUserRemappable interface

func (*Reaction) GetUserID

func (r *Reaction) GetUserID() int64

GetUserID ExternalUserRemappable interface

func (*Reaction) LoadUser

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

LoadUser load user of reaction

func (*Reaction) RemapExternalUser

func (r *Reaction) RemapExternalUser(externalName string, externalID, userID int64) error

RemapExternalUser ExternalUserRemappable interface

type ReactionList

type ReactionList []*Reaction

ReactionList represents list of reactions

func FindCommentReactions

func FindCommentReactions(ctx context.Context, issueID, commentID int64) (ReactionList, int64, error)

FindCommentReactions returns a ReactionList of all reactions from an comment

func FindIssueReactions

func FindIssueReactions(ctx context.Context, issueID int64, listOptions db.ListOptions) (ReactionList, int64, error)

FindIssueReactions returns a ReactionList of all reactions from an issue

func FindReactions

func FindReactions(ctx context.Context, opts FindReactionsOptions) (ReactionList, int64, error)

FindReactions returns a ReactionList of all reactions from an issue or a comment

func (ReactionList) GetFirstUsers

func (list ReactionList) GetFirstUsers() string

GetFirstUsers returns first reacted user display names separated by comma

func (ReactionList) GetMoreUserCount

func (list ReactionList) GetMoreUserCount() int

GetMoreUserCount returns count of not shown users in reaction tooltip

func (ReactionList) GroupByType

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

GroupByType returns reactions grouped by type

func (ReactionList) HasUser

func (list ReactionList) HasUser(userID int64) bool

HasUser check if user has reacted

func (ReactionList) LoadUsers

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

LoadUsers loads reactions' all users

type ReactionOptions

type ReactionOptions struct {
	Type      string
	DoerID    int64
	IssueID   int64
	CommentID int64
}

ReactionOptions defines options for creating or deleting reactions

type Review

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

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

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

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

Review represents collection of code comments giving feedback for a PR

func CreateReview

func CreateReview(ctx context.Context, opts CreateReviewOptions) (*Review, error)

CreateReview creates a new review based on opts

func GetCurrentReview

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

GetCurrentReview returns the current pending review of reviewer for given issue

func GetReviewByID

func GetReviewByID(ctx context.Context, id int64) (*Review, error)

GetReviewByID returns the review by the given ID

func GetReviewByIssueIDAndUserID

func GetReviewByIssueIDAndUserID(ctx context.Context, issueID, userID int64) (*Review, error)

GetReviewByIssueIDAndUserID get the latest review of reviewer for a pull request

func GetTeamReviewerByIssueIDAndTeamID

func GetTeamReviewerByIssueIDAndTeamID(ctx context.Context, issueID, teamID int64) (*Review, error)

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

func (*Review) GetCodeCommentsCount

func (r *Review) GetCodeCommentsCount(ctx context.Context) int

GetCodeCommentsCount return count of CodeComments a Review has

func (*Review) GetExternalID

func (r *Review) GetExternalID() int64

GetExternalID ExternalUserRemappable interface

func (*Review) GetExternalName

func (r *Review) GetExternalName() string

GetExternalName ExternalUserRemappable interface

func (*Review) GetUserID

func (r *Review) GetUserID() int64

GetUserID ExternalUserRemappable interface

func (*Review) HTMLTypeColorName

func (r *Review) HTMLTypeColorName() string

HTMLTypeColorName returns the color used in the ui indicating the review

func (*Review) HTMLURL

func (r *Review) HTMLURL(ctx context.Context) string

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

func (*Review) LoadAttributes

func (r *Review) LoadAttributes(ctx context.Context) (err error)

LoadAttributes loads all attributes except CodeComments

func (*Review) LoadCodeComments

func (r *Review) LoadCodeComments(ctx context.Context) (err error)

LoadCodeComments loads CodeComments

func (*Review) LoadIssue

func (r *Review) LoadIssue(ctx context.Context) (err error)

func (*Review) LoadReviewer

func (r *Review) LoadReviewer(ctx context.Context) (err error)

LoadReviewer loads reviewer

func (*Review) LoadReviewerTeam

func (r *Review) LoadReviewerTeam(ctx context.Context) (err error)

LoadReviewerTeam loads reviewer team

func (*Review) RemapExternalUser

func (r *Review) RemapExternalUser(externalName string, externalID, userID int64) error

RemapExternalUser ExternalUserRemappable interface

func (*Review) TooltipContent

func (r *Review) TooltipContent() string

TooltipContent returns the locale string describing the review type

type ReviewCount

type ReviewCount struct {
	IssueID int64
	Type    ReviewType
	Count   int64
}

ReviewCount represents a count of Reviews

type ReviewList

type ReviewList []*Review

func FindLatestReviews

func FindLatestReviews(ctx context.Context, opts FindReviewOptions) (ReviewList, error)

FindLatestReviews returns only latest reviews per user, passing FindReviewOptions

func FindReviews

func FindReviews(ctx context.Context, opts FindReviewOptions) (ReviewList, error)

FindReviews returns reviews passing FindReviewOptions

func GetReviewersFromOriginalAuthorsByIssueID

func GetReviewersFromOriginalAuthorsByIssueID(ctx context.Context, issueID int64) (ReviewList, error)

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

func GetReviewsByIssueID

func GetReviewsByIssueID(ctx context.Context, issueID int64) (ReviewList, error)

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

func (ReviewList) LoadIssues

func (reviews ReviewList) LoadIssues(ctx context.Context) error

func (ReviewList) LoadReviewers

func (reviews ReviewList) LoadReviewers(ctx context.Context) error

LoadReviewers loads reviewers

func (ReviewList) LoadReviewersTeams

func (reviews ReviewList) LoadReviewersTeams(ctx context.Context) error

LoadReviewersTeams loads reviewers teams

type ReviewType

type ReviewType int

ReviewType defines the sort of feedback a review gives

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

ReviewTypeUnknown unknown review type

func (ReviewType) Icon

func (rt ReviewType) Icon() string

Icon returns the corresponding icon for the review type

type RoleDescriptor

type RoleDescriptor struct {
	IsPoster   bool
	RoleInRepo RoleInRepo
}

RoleDescriptor defines comment "role" tags

type RoleInRepo

type RoleInRepo string

RoleInRepo presents the user's participation in the repo

const (
	RoleRepoOwner                RoleInRepo = "owner"
	RoleRepoMember               RoleInRepo = "member"
	RoleRepoCollaborator         RoleInRepo = "collaborator"
	RoleRepoFirstTimeContributor RoleInRepo = "first_time_contributor"
	RoleRepoContributor          RoleInRepo = "contributor"
)

Enumerate all the role tags.

func (RoleInRepo) LocaleHelper

func (r RoleInRepo) LocaleHelper(lang translation.Locale) string

LocaleHelper returns the locale tooltip of the role

func (RoleInRepo) LocaleString

func (r RoleInRepo) LocaleString(lang translation.Locale) string

LocaleString returns the locale string name of the role

type Stopwatch

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

Stopwatch represents a stopwatch for time tracking.

func GetUserStopwatches

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

GetUserStopwatches return list of all stopwatches of a user

func (Stopwatch) Duration

func (s Stopwatch) Duration() string

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

func (Stopwatch) Seconds

func (s Stopwatch) Seconds() int64

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

type TrackedTime

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

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

func AddTime

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

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

func GetTrackedTimeByID

func GetTrackedTimeByID(ctx context.Context, id int64) (*TrackedTime, error)

GetTrackedTimeByID returns raw TrackedTime without loading attributes by id

func (*TrackedTime) AfterLoad

func (t *TrackedTime) AfterLoad()

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

func (*TrackedTime) LoadAttributes

func (t *TrackedTime) LoadAttributes(ctx context.Context) (err error)

LoadAttributes load Issue, User

type TrackedTimeList

type TrackedTimeList []*TrackedTime

TrackedTimeList is a List of TrackedTime's

func GetTrackedTimes

func GetTrackedTimes(ctx context.Context, options *FindTrackedTimesOptions) (trackedTimes TrackedTimeList, err error)

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

func (TrackedTimeList) LoadAttributes

func (tl TrackedTimeList) LoadAttributes(ctx context.Context) error

LoadAttributes load Issue, User

type UserStopwatch

type UserStopwatch struct {
	UserID      int64
	StopWatches []*Stopwatch
}

UserIDCount is a simple coalition of UserID and Count

func GetUIDsAndStopwatch

func GetUIDsAndStopwatch(ctx context.Context) ([]*UserStopwatch, error)

GetUIDsAndNotificationCounts between the two provided times

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL