summaryrefslogtreecommitdiffstats
path: root/services/issue
Commit message (Collapse)AuthorAgeFilesLines
* Move some files into models' sub packages (#20262)Lunny Xiao2022-08-253-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | * Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
* Refactor AssertExistsAndLoadBean to use generics (#20797)Lunny Xiao2022-08-163-22/+22
| | | | | | | * Refactor AssertExistsAndLoadBean to use generics * Fix tests Co-authored-by: zeripath <art27@cantab.net>
* Check if project has the same repository id with issue when assign project ↵Lunny Xiao2022-06-301-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | to issue (#20133) * Check if project has the same repository id with issue when assign project to issue * Check if issue's repository id match project's repository id * Add more permission checking * Remove invalid argument * Fix errors * Add generic check * Remove duplicated check * Return error + add check for new issues * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: 6543 <6543@obermui.de>
* Add more linters to improve code readability (#19989)Wim2022-06-202-4/+4
| | | | | | | | | | Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
* fix delete pull head ref for DeleteIssue (#20032)a10121127962022-06-191-1/+1
| | | | | | | | | | | | | * fix delete pull head ref for DeleteIssue fix #19655 Signed-off-by: a1012112796 <1012112796@qq.com> * add different help message for delete pull request Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: 6543 <6543@obermui.de>
* Move issues related files into models/issues (#19931)Lunny Xiao2022-06-1312-129/+264
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
* Move almost all functions' parameter db.Engine to context.Context (#19748)Lunny Xiao2022-05-204-12/+16
| | | | * Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
* Move access and repo permission to models/perm/access (#19350)Lunny Xiao2022-05-114-8/+12
| | | | | * Move access and repo permission to models/perm/access * Remove unnecessary code
* Use for a repo action one database transaction (#19576)65432022-05-031-3/+11
| | | | | ... more context (part of #9307)
* more context for models (#19511)65432022-04-283-10/+23
| | | | | make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
* Use a struct as test options (#19393)Lunny Xiao2022-04-141-1/+3
| | | | | | | * Use a struct as test options * Fix name * Fix test
* Move milestone to models/issues/ (#19278)Lunny Xiao2022-04-083-3/+92
| | | | | | | | | | | * Move milestone to models/issues/ * Fix lint * Fix test * Fix lint * Fix lint
* Move some issue methods as functions (#19255)Lunny Xiao2022-03-295-8/+8
| | | | | * Move some issue methods as functions * Fix bug
* Move organization related structs into sub package (#18518)Lunny Xiao2022-03-291-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move organization related structs into sub package * Fix test * Fix lint * Move more functions into sub packages * Fix bug * Fix test * Update models/organization/team_repo.go Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Fix fmt * Follow suggestion from @Gusted * Fix test * Fix test * Fix bug * Use ctx but db.DefaultContext on routers * Fix bug * Fix bug * fix bug * Update models/organization/team_user.go * Fix bug Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Allow users to self-request a PR review (#19030)Norwin2022-03-081-8/+0
| | | | | | | | | | | The review request feature was added in https://github.com/go-gitea/gitea/pull/10756, where the doer got explicitly excluded from available reviewers. I don't see a functionality or security related reason to forbid this case. As shown by GitHubs implementation, it may be useful to self-request a review, to be reminded oneselves about reviewing, while communicating to team mates that a review is missing. Co-authored-by: delvh <dev.lh@web.de>
* [API] Allow removing issues (#18879)Otto Richter (fnetX)2022-03-011-0/+29
| | | | | | | | Add new feature to delete issues and pulls via API Co-authored-by: fnetx <git@fralix.ovh> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: 6543 <6543@obermui.de>
* format with gofumpt (#18184)65432022-01-202-4/+4
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Restore propagation of ErrDependenciesLeft (#18325)zeripath2022-01-191-4/+4
| | | | | | | | | | | Unfortunately #17643 prevented all propagation of ErrDependenciesLeft meaning that dependency errors that prevent closing of issues get swallowed. This PR restores propagation of the error but instead swallows the error in the places where it needs to be swallowed. Fix #18223 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Simplify parameter types (#18006)Gusted2021-12-201-1/+1
| | | Remove repeated type declarations in function definitions.
* Move repository model into models/repo (#17933)Lunny Xiao2021-12-103-12/+15
| | | | | | | | | | | | | | | * Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
* Move accessmode into models/perm (#17828)Lunny Xiao2021-11-281-3/+4
|
* Move user related model into models/user (#17781)Lunny Xiao2021-11-2410-34/+44
| | | | | | | | | | | | | * Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
* Fix close issue but time watcher still running (#17643)Lunny Xiao2021-11-213-4/+508
| | | | | | | | | | | | | * Fix close issue but time watcher still running * refactor stopwatch codes * Fix test * Fix test * Fix typo * Fix test
* A better go code formatter, and now `make fmt` can run in Windows (#17684)wxiaoguang2021-11-172-0/+2
| | | | * go build / format tools * re-format imports
* Decouple unit test, remove intermediate `unittestbridge` package (#17662)wxiaoguang2021-11-161-9/+8
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Decouple unit test code from business code (#17623)wxiaoguang2021-11-123-6/+7
|
* Move unit into models/unit/ (#17576)Lunny Xiao2021-11-091-3/+4
| | | | | * Move unit into models/unit/ * Rename unit.UnitType as unit.Type
* DBContext is just a Context (#17100)zeripath2021-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * DBContext is just a Context This PR removes some of the specialness from the DBContext and makes it context This allows us to simplify the GetEngine code to wrap around any context in future and means that we can change our loadRepo(e Engine) functions to simply take contexts. Signed-off-by: Andrew Thornton <art27@cantab.net> * fix unit tests Signed-off-by: Andrew Thornton <art27@cantab.net> * another place that needs to set the initial context Signed-off-by: Andrew Thornton <art27@cantab.net> * avoid race Signed-off-by: Andrew Thornton <art27@cantab.net> * change attachment error Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move db related basic functions to models/db (#17075)Lunny Xiao2021-09-194-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | | * Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
* Fix various documentation, user-facing, and source comment typos (#16367)luzpaz2021-07-081-1/+1
| | | | | * Fix various doc, user-facing, and source comment typos Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby`
* Fixed assert statements. (#16089)KN4CK3R2021-06-071-1/+1
|
* label and milestone webhooks on issue/pull creation (#14363)Jimmy Praet2021-01-171-0/+6
|
* Send notifications for mentions in pulls, issues, (code-)comments (#14218)Jimmy Praet2021-01-021-1/+6
| | | | | Fixes #14187: mention handling extracted from email notification code Fixes #14013: add notification for mentions in pull request code comments Fixes #13450: Not receiving any emails with setting "Only Email on Mention"
* Add review request api (#11355)a10121127962020-10-201-6/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add review request api * add : POST /repos/{owner}/{repo}/pulls/{index}/requested_reviewers * Remove : DELET /repos/{owner}/{repo}/pulls/{index}/requested_reviewers * fix some request review bug * block delet request review by models/DeleteReview() Signed-off-by: a1012112796 <1012112796@qq.com> * make fmt * fix bug * fix test code * fix typo * Apply suggestion from code review @jonasfranz * fix swagger ref * fix typo Co-authored-by: Lauris BH <lauris@nix.lv> * fix comment * Change response message * chang response so some simplfy * Add ErrIllLegalReviewRequest fix some nits * make fmt * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * * Add team support * fix test * fix an known bug * fix nit * fix test * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * update get api and add test Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: zeripath <art27@cantab.net>
* Add team support for review request (#12039)赵智超2020-10-121-1/+38
| | | | | | | | | | | Add team support for review request Block #11355 Signed-off-by: a1012112796 <1012112796@qq.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Change/remove a branch of an open issue (#9080)Vedran2020-09-081-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add field with isIssueWriter to front end * Make branch field editable * Switch frontend to form and POST from javascript * Add /issue/id/ref endpoint to routes * Use UpdateIssueTitle model to change ref in backend * Removed crossreference check and adding comments on branch change * Use ref returned from POST to update the field * Prevent calling loadRepo from models/ * Branch/tag refreshed without page reload * Remove filter for empty branch name * Add clear option to tag list as well * Delete button translation and coloring * Fix for not showing selected branch name in new issue * Check that branch is not being changed on a PR * Change logic * Notification when changing issue ref * Fix for renamed permission parameter * Fix for failing build * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Gitea <gitea@fake.local> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix ref links in issue overviews for tags (#8742)Sijmen Schoon2020-05-142-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Properly generate ref URLs Tags used to not generate correct URLs (src/branch/tags/1.0.0 instead of src/tags/1.0.0). Also cleans up some code around it with the created helper functions. * Fix formatting and create migration * Add copyright head to utils_test * Use a raw query for the ref migration * Remove semicolon * Quote column and table names in migration SQL * Change || to CONCAT, since MSSQL does not support || * Make migration engine aware * Add missing import * Move ref EndName and URL to the issue service * Fix tests * Add test for commit refs * Update issue.go * Use the right command for building JavaScript bundles * Prepare for merge * Check for refs/* before prepending in migration * Update services/issue/issue_test.go * Update modules/git/utils_test.go Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <matti@mdranta.net>
* Fix spelling mistake with Rewiew (#11262)zeripath2020-04-301-3/+3
| | | Signed-off-by: Andrew Thornton <art27@cantab.net>
* add request review from specific reviewers feature in pull request (#10756)赵智超2020-04-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * add request review feature in pull request add a way to notify specific reviewers to review like github , by add or delet a special type review . The acton is is similar to Assign , so many code reuse the function and items of Assignee, but the meaning and result is different. The Permission style is is similar to github, that only writer can add a review request from Reviewers, but the poster can recall and remove a review request after a reviwer has revied even if he don't have Write Premission. only manager , the poster and reviewer of a request review can remove it. The reviewers can be requested to review contain all readers for private repo , for public, contain all writers and watchers. The offical Review Request will block merge if Reject can block it. an other change: add ui otify for Assignees. Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv> Signed-off-by: a1012112796 <1012112796@qq.com> * new change * add placeholder string * do some changes follow #10238 to add review requests num on lists also change icon for review requests to eye Co-authored-by: Lauris BH <lauris@nix.lv>
* Add Organization Wide Labels (#10814)mrsdizzie2020-04-011-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add organization wide labels Implement organization wide labels similar to organization wide webhooks. This lets you create individual labels for organizations that can be used for all repos under that organization (so being able to reuse the same label across multiple repos). This makes it possible for small organizations with many repos to use labels effectively. Fixes #7406 * Add migration * remove comments * fix tests * Update options/locale/locale_en-US.ini Removed unused translation string * show org labels in issue search label filter * Use more clear var name * rename migration after merge from master * comment typo * update migration again after rebase with master * check for orgID <=0 per guillep2k review * fmt * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * remove unused code * Make sure RepoID is 0 when searching orgID per code review * more changes/code review requests * More descriptive translation var per code review * func description/delete comment when issue label deleted instead of hiding it * remove comment * only use issues in that repo when calculating number of open issues for org label on repo label page * Add integration test for IssuesSearch API with labels * remove unused function * Update models/issue_label.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Use subquery in GetLabelIDsInReposByNames * Fix tests to use correct orgID * fix more tests * IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well * update comment for clarity * Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition * Don't sort repos by date in IssuesSearch API After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures: SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45 Returns different results for MySQL than other engines. However, the similar query: SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30 Returns the same results. This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function. * linter is back! * code review * remove now unused option * Fix newline at end of files * more unused code * update to master * check for matching ids before query * Update models/issue_label.go Co-Authored-By: 6543 <6543@obermui.de> * Update models/issue_label.go * update comments * Update routers/org/setting.go Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
* Trigger webhooks on issue label-change via API too (#10421)65432020-02-231-0/+15
| | | | | | | | | | | | | | * trigger webhooks with api too * fix comment * notify report old too * CI restart * restart CI again * remove duplicated code
* Refactor comment (#9330)Lunny Xiao2019-12-151-2/+2
| | | | | | | | * Refactor comment * fix test * improve code
* Move actions to notification (#8785)Lunny Xiao2019-11-031-15/+0
|
* Move issue milestone assign to issue service and move webhook to ↵Lunny Xiao2019-11-021-0/+21
| | | | notification (#8780)
* Move labels webhooks to notification (#8749)Lunny Xiao2019-11-021-52/+3
| | | | | | * Move webhooks to notification * fix notification
* Move webhook to a standalone package under modules (#8747)Lunny Xiao2019-11-011-3/+4
| | | | | | | | * Move webhook to a standalone package under modules * fix test * fix comments
* Move issue change content from models to service (#8711)Lunny Xiao2019-10-301-0/+23
| | | | | | * Move issue change content from models to service * fix lint
* Move issue notifications (#8713)Lunny Xiao2019-10-291-24/+8
|
* Move issue change status from models to service (#8691)Lunny Xiao2019-10-281-0/+21
|
* Move more issue assignee code from models to issue service (#8690)Lunny Xiao2019-10-283-42/+93
| | | | | | * Move more issue assignee code from models to issue service * fix test