summaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash following ldap authentication update (#16447) (#16449)zeripath2021-07-151-2/+2
| | | | | | | | | | | Backport #16447 Unfortunately #16268 contained a terrible error, whereby there was a double indirection taken when unmarshalling the source data. This fatally breaks authentication configuration reading. Fix #16342 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Retry rename on lock induced failures (#16435) (#16439)zeripath2021-07-154-10/+10
| | | | | | | | | | | | | | | | | Backport #16435 Due to external locking on Windows it is possible for an os.Rename to fail if the files or directories are being used elsewhere. This PR simply suggests retrying the rename again similar to how we handle the os.Remove problems. Fix #16427 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Validate issue index before querying DB (#16406) (#16410)Norwin2021-07-121-0/+3
|
* Fix list_options GetStartEnd (#16303) (#16305)65432021-06-301-1/+1
| | | | | end is start + pageSize and not start + page Co-authored-by: sebastian-sauer <sauer.sebastian@gmail.com>
* Handle misencoding of login_source cfg in mssql (#16268) (#16275)zeripath2021-06-272-20/+21
| | | | | | | | | | | | | | Backport #16268 Unfortunately due a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) updating loginsources on MSSQL causes them to become corrupted. (#16252) Whilst waiting for the referenced PR to be merged and to handle the corrupted loginsources correctly we need to add a wrapper to the `FromDB()` methods to look for and ignore the misplaced BOMs that have been added. Fix #16252 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update milestone counters on new issue (#16183) (#16224)KN4CK3R2021-06-224-56/+39
| | | | Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
* Encrypt migration credentials at rest (#15895) (#16187)zeripath2021-06-171-1/+41
| | | | | | | | | | Backport #15895 Storing these credentials is a liability. * Encrypt credentials with SECRET_KEY before persisting to task queue table (they need to be persisted due to the nature of the task queue) - security in depth: helps when attacker has access to DB only, but not app.ini * Delete all credentials (even encrypted) from the task table, once the migration is done, for safety - security in depth: minimizes leaked data if attacker gains access to snapshot of both DB and app.ini
* Only check access tokens if they are likely to be tokens (#16164) (#16171)zeripath2021-06-161-1/+7
| | | | | | | | | | | Backprt #16164 Gitea will currently check every if every password is an access token even though most passwords are not and cannot be access tokens. By creation access tokens are 40 byte hexadecimal strings therefore only these should be checked. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix bug on getIssueIDsByRepoID (#16119) (#16124)Lunny Xiao2021-06-102-1/+9
| | | | | * Fix bug on getIssueIDsByRepoID * Add test
* Fix case change in ownernames (#16045) (#16050)zeripath2021-06-031-0/+20
| | | | | | | | Backport #16045 If you change the case of a username the change needs to be propagated to their repositories. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Restore PAM user autocreation functionality (#15825) (#15867)zeripath2021-05-191-1/+14
| | | | | | | | | | | | | | | | | | | | Backport #15825 * Restore PAM user autocreation functionality PAM autoregistration of users currently fails due to email invalidity. This PR adds a new setting to PAM to allow an email domain to be set or just sets the email to the noreply address and if that fails falls back to uuid@localhost Fix #15702 Signed-off-by: Andrew Thornton <art27@cantab.net> * As per KN4CKER Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Tagger can be empty, as can Commit and Author - tolerate this (#15835) (#15839)zeripath2021-05-121-7/+25
| | | | | | | | | | | | | | | | Backport #15835 Unfortunately some old repositories can have tags with empty Tagger, Commit or Author. Go-Git variants will always have empty values for these whereas the native git variant leaves them at nil. The simplest solution is just to always have these set to empty Signatures. v156 migration also makes the incorrect assumption that these cannot be empty. Therefore add some handling to this and add logging and adjust broken logging elsewhere in this migration. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Display conflict-free merge messages for pull requests (#15773) (#15796)zeripath2021-05-092-2/+44
| | | | | | | | | | | | | | | Backport #15773 Repositories using external issue tracker tend to use numeric issues in commits. To prevent conflicts during issue reference parsing or inside commit hooks, this change respects these configuration and uses the ! character to refer to pull requests in merge commit messages. For repositories using squash merges, this was already handled. Signed-off-by: JustusBunsi <61625851+justusbunsi@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Steven <61625851+justusbunsi@users.noreply.github.com>
* Fix setting version table in dump (#15753) (#15759)zeripath2021-05-072-2/+2
| | | | | | | | | | | | | | | | Backport #15753 * Fix setting version table in dump As noted on Discord there is a problem with gitea dump where the version table is not being dumped correctly. This is due to a missing pointer in the TableInfo. This PR fixes this. Signed-off-by: Andrew Thornton <art27@cantab.net> * Update models_test.go
* fix some ui bug about draft release (#15137) (#15745)a10121127962021-05-061-0/+12
| | | | | | | | | | | | | | | | | | | * fix some ui bug about draft release - should not show draft release in tag list because it will't create real tag - still show draft release without tag and commit message for draft release instead of 404 error - remove tag load for attachement links because it's useless Signed-off-by: a1012112796 <1012112796@qq.com> * add test code * fix test That's because has added a new release in relaese test database. * fix dropdown link for draft release
* Implement delete release attachments and update release attachments' name ↵Kyle D2021-05-033-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | (#14130) (#15666) * Implement delete release attachment * Add attachments on release edit page * Fix bug * Finish del release attachments * Fix frontend lint * Fix tests * Support edit release attachments * Added tests * Remove the unnecessary parameter isCreate from UpdateReleaseOrCreatReleaseFromTag * Rename UpdateReleaseOrCreatReleaseFromTag to UpdateRelease * Fix middle align Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix DB session cleanup (#15697) (#15700)zeripath2021-05-021-1/+1
| | | | | | | Backport #15697 The DB session clean up needs to check expiry not created_unix. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Delete references if repository gets deleted (#15681) (#15684)65432021-05-011-17/+15
| | | | | | | | * Remove DeletedBranch and LFSLocks. * Sort beans. Co-authored-by: KN4CK3R <KN4CK3R@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net>
* Fix orphaned objects deletion bug (#15657) (#15683)65432021-04-302-3/+39
| | | | | | | | | | * Fix orphaned objects deletion bug * extend test Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Delete protected branch if repository gets removed (#15658) (#15676)KN4CK3R2021-04-301-0/+1
| | | | | | | * Added missing error parameters. * Delete protected branch if repository gets removed. * Added doctor fix.
* not update updated uinx for `git gc` (#15637) (#15641)zeripath2021-04-281-1/+1
| | | | | | | | | Backport #15637 fix #15634 Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
* Resolve panic on failed interface conversion in migration v156 (#15604) (#15610)techknowlogick2021-04-251-1/+1
| | | | | | | go panics otherwise with `panic: interface conversion: error is git.ErrNotExist, not *git.ErrNotExist`, thanks to Codeberg/Andi for reporting this. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Send size to /avatars if requested (#15459) (#15528)zeripath2021-04-172-3/+11
| | | | | | | | | | | Backport #15459 If an avatar is requested in a particular size ensure that /avatars also gets the size request Fix #15453 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Prevent migration 156 failure if tag commit missing (#15519) (#15527)zeripath2021-04-171-0/+11
| | | | | | | | | | Backport #15519 It is possible that tag commits could be deleted or missing from repos. This causes migration 156 to fail and breaks upgrade. This PR simply logs the failure. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Performance improvement for list pull requests (#15447) (#15500)65432021-04-161-0/+8
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Ensure review dismissal only dismisses the correct review (#15477) (#15489)zeripath2021-04-152-8/+58
| | | | | | | | | Backport #15477 Fix #15472 Signed-off-by: Andrew Thornton art27@cantab.net Co-authored-by: 6543 <6543@obermui.de>
* Query the DB for the hash before inserting in to email_hash (#15457) (#15491)zeripath2021-04-151-0/+5
| | | | | | | | | | | | | Backport #15457 Some postgres users have logging which logs even failed transactions. So just query the db before trying to insert. Fix #15451 Signed-off-by: Andrew Thornton art27@cantab.net Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* v172 migration adds created_unix field instead of expiry (#15458) (#15463)techknowlogick2021-04-141-3/+3
| | | | | | | | | | The Session table must have an Expiry field not a created_unix field - somehow this migration adds the incorrect named field leading to #15445 reports. Fix #15445 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Fix delete nonexist oauth application 500 and prevent deadlock (#15384) (#15396)Lunny Xiao2021-04-112-1/+4
| | | | | | | | | | | | | | | * Fix delete nonexist oauth application 500 * Fix test * Close the session * Fix more missed sess.Close * Remove unnecessary blank line Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Always set the merge base used to merge the commit (#15352) (#15385)zeripath2021-04-101-1/+2
| | | | | | | | | Backport #15352 The issue is that the TestPatch will reset the PR MergeBase - and it is possible for TestPatch to update the MergeBase whilst a merge is ongoing. The ensuing merge will then complete but it doesn't re-set the MergeBase it used to merge the PR. Fixes the intermittent error in git test. Signed-off-by: Andrew Thornton art27@cantab.net
* Fix `admin user list` (#15358) (#15359)65432021-04-091-2/+2
| | | | | * Fix `admin user list` (#15358) * fix routers/api/v1/repo/issue.go
* Fix xorm log stack level (#15285) (#15316)65432021-04-071-8/+10
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add size to Save function (#15264) (#15270)zeripath2021-04-041-1/+1
| | | | | | | | | | | This PR proposes an alternative solution to #15255 - just add the size to the save function. Yes it is less apparently clean but it may be more correct. Close #15255 Fix #15253 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix timezone bug when clicking heatmap (#15141) (#15231)mayswind2021-04-011-1/+1
|
* Improve /api/v1/repos/issues/search by just getting repo ids (#15179) (#15192)zeripath2021-04-011-18/+68
| | | | | | | | | | | | | | | Backport #15179 /api/v1/repos/issues/search is a highly inefficient search which is unfortunately the basis for our dependency searching algorithm. In particular it currently loads all of the repositories and their owners and their primary coding language all of which is immediately thrown away. This PR makes one simple change - just get the IDs. Related #14560 Related #12827 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix Migration 176 yet again (#15132)v1.14.0-rc2zeripath2021-03-233-9/+10
| | | | | | | | | | | | Backport #15131 Whilst creating a test for v176 in the migrations_test PR it has become clear that this was still wrong. This is now fixed. Genuinely. Also fix repo transfer Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix consistency check (#15120) (#15128)zeripath2021-03-231-1/+1
| | | | | | In my last fix I missed adding the label_ prefix to the consistency check count. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix the v176 migration (#15110) (#15111)zeripath2021-03-223-3/+3
| | | | | | | | Backport #15110 There is a serious issue with the v176 migration where there is a mistaken missing label_id selection. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Delete Labels & IssueLabels on Repo Delete too (#15039)65432021-03-196-8/+98
| | | | | | | | | | | | | | | | | | | | | | | * Doctor: find IssueLabels without existing label * on Repo Delete: delete labels & issue_labels too * performance nits * Add Migration: Delete orphaned IssueLabels * Migration v174: use Sync2 * USE sess !!! * better func name * code format & comment * RAW SQL * Update models/migrations/v176.go * next try?
* Prevent addition of labels from outside the repository or organisation in ↵zeripath2021-03-193-0/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | issues (#14912) * Never add labels not from this repository or organisation and remove org labels on transfer Prevent the addition of labels from outside of the repository or organisation and remove organisation labels on transfer. Related #14908 Signed-off-by: Andrew Thornton <art27@cantab.net> * switch to use sql Signed-off-by: Andrew Thornton <art27@cantab.net> * remove AS Signed-off-by: Andrew Thornton <art27@cantab.net> * subquery alias Signed-off-by: Andrew Thornton <art27@cantab.net> * Give me some AS? Signed-off-by: Andrew Thornton <art27@cantab.net> * double AS Signed-off-by: Andrew Thornton <art27@cantab.net> * try try again Signed-off-by: Andrew Thornton <art27@cantab.net> * once more around the merry go round Signed-off-by: Andrew Thornton <art27@cantab.net> * fix api problem Signed-off-by: Andrew Thornton <art27@cantab.net> * Add outside label consistency check into doctor This PR adds another consistency check into doctor in order to detect labels that have been added from outside of repositories and organisations Fix #14908 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix migration Signed-off-by: Andrew Thornton <art27@cantab.net> * prep for merge Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
* Fix postgres ID sequences broken by recreate-table (#15015)zeripath2021-03-183-1/+178
| | | | | | | | | | | | | | | | | | | | | * Fix postgres ID sequences broken by recreate-table Unfortunately there is a subtle problem with recreatetable on postgres which leads to the sequences not being renamed and not being left at 0. Fix #14725 Signed-off-by: Andrew Thornton <art27@cantab.net> * let us try information_schema instead Signed-off-by: Andrew Thornton <art27@cantab.net> * try again Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
* sort release attachments by name (#15008)Norwin2021-03-171-1/+1
| | | | | Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
* Ensure validation occurs on clone addresses too (#14994)zeripath2021-03-152-28/+28
| | | | | | | | | | | | | | | | | | | | | * Ensure validation occurs on clone addresses too Fix #14984 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix lint Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix api tests Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* chore(models): rewrite code format. (#14754)Bo-Yi Wu2021-03-14103-460/+474
| | | | | | | | | | | | | | | * chore: rewrite format. * chore: update format Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * chore: update format Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> * chore: Adjacent parameters with the same type should be grouped together * chore: update format.
* API: fix set milestone on PR creation (#14981)Norwin2021-03-133-1/+18
| | | | | | | | | | | | | | * API: fix set milestone on PR creation pr creation via API failed with 404, because we searched for milestoneID 0, due to uninitialized var usage D: * add tests * fix expected status codes * fix tests Co-authored-by: 6543 <6543@obermui.de>
* Never add labels not from this repository or organisation and remove org ↵zeripath2021-03-123-5/+61
| | | | | | | | | | | | | | | | | | labels on transfer (#14928) * Never add labels not from this repository or organisation and remove org labels on transfer Prevent the addition of labels from outside of the repository or organisation and remove organisation labels on transfer. Related #14908 * switch to use sql * subquery alias * once more around the merry go round * fix api problem
* Add "captcha" to list of reserved usernames (#14929)fnetX (aka fralix)2021-03-081-0/+1
| | | Signed-off-by: Otto Richter <git@fralix.ovh>
* Fix overdue marking of closed issues and milestones (#14923)zeripath2021-03-082-2/+7
| | | | | | | | Closed milestones and issues should only be marked overdue if they were closed after their deadline. Fix: #14536 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix issue search with db indexer because of mysql 5.7 sqlmode (#14907)Lunny Xiao2021-03-061-1/+10
| | | | | * Fix sqlmode bug * distinct is necessary
* When transfering repository and database transaction failed, rollback the ↵Lunny Xiao2021-03-051-1/+37
| | | | | | | | renames (#14864) Fix #14821 Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>