aboutsummaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* not update updated uinx for `git gc` (#15637)a10121127962021-04-281-1/+1
| | | | | fix #15634 Signed-off-by: a1012112796 <1012112796@qq.com>
* Resolve panic on failed interface conversion in migration v156 (#15604)techknowlogick2021-04-241-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>
* Refactor renders (#15175)Lunny Xiao2021-04-193-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
* Prevent migration 156 failure if tag commit missing (#15519)zeripath2021-04-161-0/+11
| | | | | | | | | | 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> Co-authored-by: 6543 <6543@obermui.de>
* Send size to /avatars if requested (#15459)zeripath2021-04-172-3/+11
| | | | | | | 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>
* Performance improvement for list pull requests (#15447)Lunny Xiao2021-04-151-0/+8
|
* Disable Stars config option (#14653)Kyle D2021-04-151-0/+6
| | | | | | | * Add config option to disable stars * Replace "stars" with watched in user profile * Add documentation
* Query the DB for the hash before inserting in to email_hash (#15457)zeripath2021-04-151-0/+5
| | | | | | | | | 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>
* Ensure review dismissal only dismisses the correct review (#15477)zeripath2021-04-152-8/+58
| | | | | Fix #15472 Signed-off-by: Andrew Thornton art27@cantab.net
* OAuth2 auto-register (#5123)Martin Michaelis2021-04-142-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactored handleOAuth2SignIn in routers/user/auth.go The function handleOAuth2SignIn was called twice but some code path could only be reached by one of the invocations. Moved the unnecessary code path out of handleOAuth2SignIn. * Refactored user creation There was common code to create a user and display the correct error message. And after the creation the only user should be an admin and if enabled a confirmation email should be sent. This common code is now abstracted into two functions and a helper function to call both. * Added auto-register for OAuth2 users If enabled new OAuth2 users will be registered with their OAuth2 details. The UserID, Name and Email fields from the gothUser are used. Therefore the OpenID Connect provider needs additional scopes to return the coresponding claims. * Added error for missing fields in OAuth2 response * Linking and auto linking on oauth2 registration * Set default username source to nickname * Add automatic oauth2 scopes for github and google * Add hint to change the openid connect scopes if fields are missing * Extend info about auto linking security risk Co-authored-by: Viktor Kuzmin <kvaster@gmail.com> Signed-off-by: Martin Michaelis <code@mgjm.de>
* docs: migration start new section (#15462)65432021-04-141-0/+3
|
* v172 migration adds created_unix field instead of expiry (#15458)zeripath2021-04-131-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>
* Fix delete nonexist oauth application 500 and prevent deadlock (#15384)Lunny Xiao2021-04-102-1/+4
| | | | | | | | | | | | | | | | | | * Fix delete nonexist oauth application 500 * Fix test * Close the session Signed-off-by: Andrew Thornton <art27@cantab.net> * Update integrations/api_oauth2_apps_test.go * Fix more missed sess.Close * Remove unnecessary blank line 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)zeripath2021-04-101-1/+2
| | | | | | | 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
* rsponse 404 when delete not exist email (#15383)a10121127962021-04-102-5/+16
| | | | | fix #15357 Signed-off-by: a1012112796 <1012112796@qq.com>
* Fix `admin user list` (#15358)65432021-04-091-2/+2
|
* Code Formats, Nits & Unused Func/Var deletions (#15286)65432021-04-097-44/+5
| | | | | | | | | | | | | | | * _ to unused func options * rm useless brakets * rm trifial non used models functions * rm dead code * rm dead global vars * fix routers/api/v1/repo/issue.go * dont overload import module
* Add LFS Migration and Mirror (#14726)KN4CK3R2021-04-085-47/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implemented LFS client. * Implemented scanning for pointer files. * Implemented downloading of lfs files. * Moved model-dependent code into services. * Removed models dependency. Added TryReadPointerFromBuffer. * Migrated code from service to module. * Centralised storage creation. * Removed dependency from models. * Moved ContentStore into modules. * Share structs between server and client. * Moved method to services. * Implemented lfs download on clone. * Implemented LFS sync on clone and mirror update. * Added form fields. * Updated templates. * Fixed condition. * Use alternate endpoint. * Added missing methods. * Fixed typo and make linter happy. * Detached pointer parser from gogit dependency. * Fixed TestGetLFSRange test. * Added context to support cancellation. * Use ReadFull to probably read more data. * Removed duplicated code from models. * Moved scan implementation into pointer_scanner_nogogit. * Changed method name. * Added comments. * Added more/specific log/error messages. * Embedded lfs.Pointer into models.LFSMetaObject. * Moved code from models to module. * Moved code from models to module. * Moved code from models to module. * Reduced pointer usage. * Embedded type. * Use promoted fields. * Fixed unexpected eof. * Added unit tests. * Implemented migration of local file paths. * Show an error on invalid LFS endpoints. * Hide settings if not used. * Added LFS info to mirror struct. * Fixed comment. * Check LFS endpoint. * Manage LFS settings from mirror page. * Fixed selector. * Adjusted selector. * Added more tests. * Added local filesystem migration test. * Fixed typo. * Reset settings. * Added special windows path handling. * Added unit test for HTTPClient. * Added unit test for BasicTransferAdapter. * Moved into util package. * Test if LFS endpoint is allowed. * Added support for git:// * Just use a static placeholder as the displayed url may be invalid. * Reverted to original code. * Added "Advanced Settings". * Updated wording. * Added discovery info link. * Implemented suggestion. * Fixed missing format parameter. * Added Pointer.IsValid(). * Always remove model on error. * Added suggestions. * Use channel instead of array. * Update routers/repo/migrate.go * fmt Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Add dashboard milestone search and repo milestone search by name (#14866)Roger Luo2021-04-081-1/+65
| | | | | Feature for issue #13845: - Add milestones search by name on dashboard milestones page. - Add milestones search by name on repo issue/milestones page.
* Fix xorm log stack level (#15285)Lunny Xiao2021-04-051-8/+10
|
* Add size to Save function (#15264)zeripath2021-04-031-1/+1
| | | | | Fix #15253 Signed-off-by: Andrew Thornton <art27@cantab.net>
* [refactor] mailer service (#15072)65432021-04-021-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Unexport SendUserMail * Instead of "[]*models.User" or "[]string" lists infent "[]*MailRecipient" for mailer * adopt * code format * TODOs for "i18n" * clean * no fallback for lang -> just use english * lint * exec testComposeIssueCommentMessage per lang and use only emails * rm MailRecipient * Dont reload from users from db if you alredy have in ram * nits * minimize diff Signed-off-by: 6543 <6543@obermui.de> * localize subjects * linter ... * Tr extend * start tmpl edit ... * Apply suggestions from code review * use translation.Locale * improve mailIssueCommentBatch Signed-off-by: Andrew Thornton <art27@cantab.net> * add i18n to datas Signed-off-by: Andrew Thornton <art27@cantab.net> * a comment Co-authored-by: Andrew Thornton <art27@cantab.net>
* Fix timezone bug when clicking heatmap (#15141)mayswind2021-04-011-1/+1
|
* Improve /api/v1/repos/issues/search by just getting repo ids (#15179)zeripath2021-03-291-18/+68
| | | | | | | | | | | | | | /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>
* Update repository size on cron gc task (#15177)zeripath2021-03-281-5/+2
| | | | | | | | | git gc cron could change the size of the repository therefore we should update the size of the repo stored in our database. Also significantly improve the efficiency of counting lfs associated with the repository
* Add DefaultMergeStyle option to repository (#14789)parnic2021-03-272-1/+11
| | | Fixes #12293
* Create Proper Migration Tests (#15116)zeripath2021-03-2416-12/+1007
| | | | | | | | | | | | | | * Create Proper Migration tests Unfortunately our testing regime has so far meant that migrations do not get proper testing. This PR begins the process of creating migration tests for this. * Add test for v176 * fix mssql drop db Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix Migration 176 yet again (#15131)zeripath2021-03-233-9/+10
| | | | | | | | | | | | | | * Fix Migration 176 yet again 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. Signed-off-by: Andrew Thornton <art27@cantab.net> * and fix repo transfer Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix consistency check (#15120)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)zeripath2021-03-223-3/+3
| | | | | | | | There is a serious issue with the v176 migration where there is a mistaken missing label_id selection. *introduced by #14912* Signed-off-by: Andrew Thornton <art27@cantab.net>
* Implement delete release attachments and update release attachments' name ↵Lunny Xiao2021-03-233-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | (#14130) * 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
* 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>
* Make manual merge autodetection optional and add manual merge as merge ↵a10121127962021-03-032-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | method (#12543) * Make auto check manual merge as a chooseable mod and add manual merge way on ui as title, Before this pr, we use same way with GH to check manually merge. It good, but in some special cases, misjudgments can occur. and it's hard to fix this bug. So I add option to allow repo manager block "auto check manual merge" function, Then it will have same style like gitlab(allow empty pr). and to compensate for not being able to detect THE PR merge automatically, I added a manual approach. Signed-off-by: a1012112796 <1012112796@qq.com> * make swager * api support * ping ci * fix TestPullCreate_EmptyChangesWithCommits * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * Apply review suggestions and add test * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * fix build * test error message * make fmt * Fix indentation issues identified by @silverwind Co-authored-by: silverwind <me@silverwind.io> * Fix tests and make manually merged disabled error on API the same Signed-off-by: Andrew Thornton <art27@cantab.net> * a small nit * fix wrong commit id error * fix bug * simple test * fix test Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Make searching issues by keyword case insensitive on DB (#14848)zeripath2021-03-021-3/+4
| | | | | | | | | | | | Most DBs apart from SQLite will use a default Collation that is not case insensitive. This means that SearchIssuesByKeyword becomes case sensitive for db indexing - in contrast to the bleve and elastic indexers. This PR simply uses UPPER(...) to do the LIKE - and although it may be more efficient to change collations this would be a non-trivial task. Fix #13663 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Migrate to use jsoniter instead of encoding/json (#14841)zeripath2021-03-018-9/+41
| | | | | | | | | | * Migrate to use jsoniter * fix tests * update gitea.com/go-chi/binding Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Repository transfer has to be confirmed, if user can not create repo for new ↵65432021-03-0112-145/+567
| | | | | | | owner (#14792) * make repo as "pending transfer" if on transfer start doer has no right to create repo in new destination * if new pending transfer ocured, create UI & Mail notifications
* All organization members should be assignable as reviewer (#14262)Jimmy Praet2021-02-281-8/+12
| | | | | | For public repos, all organization members should be assignable as reviewer Co-authored-by: zeripath <art27@cantab.net>
* Disable broken OAuth2 providers at startup (#14802)zeripath2021-02-251-1/+7
| | | | | | | | | | Instead of causing a log.Fatal, we should handle broken OAuth2 providers by disabling them. Fix #8930 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Heatmap days clickable (#13935)gordon--2021-02-201-6/+19
| | | | | | | | | | | | | | | | * Heatmap days clickable * Error handling * Unselect filter * better dayclick handler * made linter happy * clickable heatmap for profiles Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>