summaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Move repository model into models/repo (#17933)Lunny Xiao2021-12-1091-1924/+2012
| | | | | | | | | | | | | | | * 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
* Fix a panic in NotifyCreateIssueComment (caused by string truncation) (#17928)wxiaoguang2021-12-091-1/+0
| | | | | | | | | | | * Fix a panic in NotifyCreateIssueComment (caused by string truncation) * more unit tests * refactor * fix some edge cases * use SplitStringAtByteN for comment content
* Support sorting for project board issuses (#17152)Anbraten2021-12-085-24/+49
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor install page (db type) (#17919)wxiaoguang2021-12-071-2/+1
| | | | | | | | | | | | * Refactor install page (db type) * set correct default DB HOST for different DB TYPE * remove legacy TiDB from documents * unify the usage of DB TYPE, in code we only use "mysql". "MySQL" is only shown to users for friendly name. * Gitea can use TiDB via MySQL protocol Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move repo archiver to models/repo (#17913)Lunny Xiao2021-12-064-119/+115
| | | | | | | | | | | * Move repo archiver to models/repo * Move archiver service into services/repository/ * Fix imports * Fix test * Fix test
* Use fmt.Sprintf correctly (#17886)delvh2021-12-021-1/+1
|
* Check if column exist before rename if exist, just return with no error (#17870)Lunny Xiao2021-12-021-0/+24
| | | | | | | | | * Check if column exist before rename if exist, just return with no error * Also check if errors column exist * Add comment for migration * Fix sqlite test
* Refactor various strings (#17784)mscherer2021-12-022-3/+5
| | | | | | | | Fixes #16478 Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* fix 500 error while use a reserved name in org rename (#17878)a10121127962021-12-021-6/+0
| | | | | fix #17876 Signed-off-by: a1012112796 <1012112796@qq.com>
* Improve install code to avoid low-level mistakes. (#17779)wxiaoguang2021-12-016-59/+109
| | | | | | | | | | | | | | * Improve install code to avoid low-level mistakes. If a user tries to do a re-install in a Gitea database, they gets a warning and double check. When Gitea runs, it never create empty app.ini automatically. Also some small (related) refactoring: * Refactor db.InitEngine related logic make it more clean (especially for the install code) * Move some i18n strings out from setting.go to make the setting.go can be easily maintained. * Show errors in CLI code if an incorrect app.ini is used. * APP_DATA_PATH is created when installing, and checked when starting (no empty directory is created any more).
* Move more model into models/user (#17826)Lunny Xiao2021-11-2812-562/+509
| | | | | | | | * Move more model into models/user * Remove unnecessary comment Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move accessmode into models/perm (#17828)Lunny Xiao2021-11-2820-169/+198
|
* Fix database inconsistent when admin change user email (#17549)Lunny Xiao2021-11-252-9/+38
|
* Allow forks to org if you can create repos (#17783)qwerty2872021-11-251-1/+1
|
* Move user related model into models/user (#17781)Lunny Xiao2021-11-2493-2467/+2642
| | | | | | | | | | | | | * Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
* Add `PULL_LIMIT` and `PUSH_LIMIT` to cron.update_mirror task (#17568)zeripath2021-11-222-0/+2
|
* Harden authorized keys a bit more (#17772)mscherer2021-11-221-1/+1
| | | | | | | | | | | | sshd(8) list restrict as a future-proof way to restrict feature enabled in ssh. It is supported since OpenSSH 7.2, out since 2016-02-29. OpenSSH will ignore unknown options (see sshauthopt_parse in auth-options.c), so it should be safe to add the option and no-user-rc. Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* More pleasantly handle broken or missing git repositories (#17747)zeripath2021-11-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | * More pleasantly handle broken or missing git repositories In #17742 it was noted that there a completely invalid git repository underlying a repo on gitea.com. This happened due to a problem during a migration however, it is not beyond the realms of possibility that a corruption could occur to another user. This PR adds a check to RepoAssignment that will detect if a repository loading has failed due to an absent git repository. It will then show a page suggesting the user contacts the administrator or deletes the repository. Fix #17742 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update options/locale/locale_en-US.ini Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Remove unnecessary attributes of User struct (#17745)Lunny Xiao2021-11-2210-366/+90
| | | | | | | | | | | | | | | * Remove unnecessary functions of User struct * Move more database methods out of user struct * Move more database methods out of user struct * Fix template failure * Fix bug * Remove finished FIXME * remove unnecessary code
* Support pagination of organizations on user settings pages (#16083)Lunny Xiao2021-11-222-21/+61
| | | | | | * Add pagination for user setting orgs * Use FindOrgs instead of GetOrgsByUserID * Remove unnecessary functions and fix test * remove unnecessary code
* Improvements to content history (#17746)Jimmy Praet2021-11-223-14/+38
| | | | | | | | | | | * Improvements to content history * initialize content history when making an edit to an old item created before the introduction of content history * show edit history for code comments on pull request files tab * Fix a flaw in keepLimitedContentHistory Fix a flaw in keepLimitedContentHistory, the first and the last should never be deleted * Remove obsolete eager initialization of content history
* Add user settings key/value DB table (#16834)techknowlogick2021-11-226-1/+196
|
* Remove NewSession method from db.Engine interface (#17577)Lunny Xiao2021-11-2144-570/+550
| | | | | | | | | | | | | * Remove NewSession method from db.Engine interface * Fix bug * Some improvements * Fix bug * Fix test * Use XXXBean instead of XXXExample
* Fix close issue but time watcher still running (#17643)Lunny Xiao2021-11-211-67/+120
| | | | | | | | | | | | | * Fix close issue but time watcher still running * refactor stopwatch codes * Fix test * Fix test * Fix typo * Fix test
* Use `hostmatcher` to replace `matchlist`, improve security (#17605)wxiaoguang2021-11-201-4/+0
| | | | | Use hostmacher to replace matchlist. And we introduce a better DialContext to do a full host/IP check, otherwise the attackers can still bypass the allow/block list by a 302 redirection.
* Move attachment into models/repo/ (#17650)Lunny Xiao2021-11-1925-368/+420
| | | | | | | * Move attachment into models/repo/ * Fix test * Fix bug
* Use a standalone struct name for Organization (#17632)Lunny Xiao2021-11-1910-166/+245
| | | | | | | | | | | | | | | | | | | | | * Use a standalone struct name for Organization * recover unnecessary change * make the code readable * Fix template failure * Fix template failure * Move HasMemberWithUserID to org * Fix test * Remove unnecessary user type check * Fix test Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Added comment for changing issue ref (#17672)Gusted2021-11-192-1/+21
| | | | | * Added comment for changing issue ref - Add a comment when someone changes the ref(erence?) of a issue.
* Fix bug when project board get open issue number (#17703)Lunny Xiao2021-11-191-1/+3
| | | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move user/org deletion to services (#17673)KN4CK3R2021-11-1910-286/+54
|
* Fix possible panic (#17694)Gusted2021-11-181-5/+4
| | | | | - The code will get the first and second character `link[{0,1]]`. However in a rare case the `link` could have 1 character and thus the `link[1]` will create a panic.
* Prevent NPE due to missing repo in regression in #17551 (#17697)zeripath2021-11-181-2/+14
|
* Move user functions into user.go (#17659)Lunny Xiao2021-11-186-45/+69
| | | | | * Move user functions into user.go * Fix test
* Remove unnecessary variable assignments (#17695)Gusted2021-11-183-5/+4
| | | | | | | | | | * Remove unnecessary variable assignments As title * enable ineffassign Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* A better go code formatter, and now `make fmt` can run in Windows (#17684)wxiaoguang2021-11-1741-12/+44
| | | | * go build / format tools * re-format imports
* Move user follow and openid into models/user/ (#17613)Lunny Xiao2021-11-1710-122/+127
| | | | | | | | | | | | | | | | | | | | | | | * Move UserRedirect into models/user/ * Fix lint & test * Fix lint * Fix lint * remove nolint comment * Fix lint * Move user follow and openid into models/user * Ignore the lint * Ignore the lint * Fix test * ignore stutters lint on UserOpenID
* Multiple Escaping Improvements (#17551)zeripath2021-11-1610-35/+43
| | | | | | | | | | | | | | There are multiple places where Gitea does not properly escape URLs that it is building and there are multiple places where it builds urls when there is already a simpler function available to use this. This is an extensive PR attempting to fix these issues. 1. The first commit in this PR looks through all href, src and links in the Gitea codebase and has attempted to catch all the places where there is potentially incomplete escaping. 2. Whilst doing this we will prefer to use functions that create URLs over recreating them by hand. 3. All uses of strings should be directly escaped - even if they are not currently expected to contain escaping characters. The main benefit to doing this will be that we can consider relaxing the constraints on user names and reponames in future. 4. The next commit looks at escaping in the wiki and re-considers the urls that are used there. Using the improved escaping here wiki files containing '/'. (This implementation will currently still place all of the wiki files the root directory of the repo but this would not be difficult to change.) 5. The title generation in feeds is now properly escaped. 6. EscapePound is no longer needed - urls should be PathEscaped / QueryEscaped as necessary but then re-escaped with Escape when creating html with locales Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move migrations into services and base into modules/migration (#17663)Lunny Xiao2021-11-161-1/+1
| | | | | | | * Move migrtions into services and base into modules/migration * Fix imports * Fix lint
* Decouple unit test, remove intermediate `unittestbridge` package (#17662)wxiaoguang2021-11-1650-1044/+1057
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix offBy1 errors (#17606)Gusted2021-11-141-1/+8
| | | | | | | | | | | | | | | | | | | | | * Fix offBy1 errors - Partially resolves #17596 - Resolve errors from go-critic `offBy1: Index() can return -1; maybe you wanted to do Index()+1`. * Match golang spec * Remove comments * Update migrations.go * Apply suggestions from code review Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Decouple unit test code from business code (#17623)wxiaoguang2021-11-1270-648/+791
|
* unbind the CheckConsistency for some structs so that they can be moved to ↵Lunny Xiao2021-11-121-20/+33
| | | | | | | | | sub packages easier (#17612) * unbind the CheckConsistency for some structs so that they can be moved to sub packages easier * Fix functions name * Fix typo
* Move EmailAddress & UserRedirect into models/user/ (#17607)Lunny Xiao2021-11-1116-592/+652
| | | | | | | | | | | | | | | | | | | | | * Move EmailAddress into models/user/ * Fix test * rename user_mail to user_email * Fix test * Move UserRedirect into models/user/ * Fix lint & test * Fix lint * Fix lint * remove nolint comment * Fix lint
* Refactor commentTags functionality (#17558)Gusted2021-11-112-9/+35
| | | | | | | | | | | | | | | | | | | | | | | | * feat: Allow multiple tags on comments - Allow for multiples tags(Currently Poster + {Owner, Writer}). - Utilize the Poster tag within the commentTag function and remove the checking from templates. - Use bitwise on CommentTags to enable specific tags. - Don't show poster tag(view_content.tmpl) on the initial issue comment. * Change parameters naming * Change function name * refactor variable wording * Merge 'master' branch into 'tags-comments' branch * Change naming * `tag` -> `role` Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move oauth2 error to oauth2 service package (#17603)Lunny Xiao2021-11-111-24/+0
|
* Fix 500 when a comment was deleted which has a notification (#17550)Lunny Xiao2021-11-101-2/+8
| | | | | | | | | | * Fix 500 when a comment was deleted which has a notification * Tolerate missing Comment in other places too Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move webhook into models/webhook/ (#17579)Lunny Xiao2021-11-1011-338/+376
|
* Added GetUserByIDCtx. (#17602)KN4CK3R2021-11-093-5/+10
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move unit into models/unit/ (#17576)Lunny Xiao2021-11-0923-191/+215
| | | | | * Move unit into models/unit/ * Rename unit.UnitType as unit.Type
* Update `User` model comments about permissions (#17583)wxiaoguang2021-11-091-5/+12
|