aboutsummaryrefslogtreecommitdiffstats
path: root/modules/doctor
Commit message (Collapse)AuthorAgeFilesLines
* Move some files into models' sub packages (#20262)Lunny Xiao2022-08-252-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Fix git.Init for doctor sub-command (#20782)wxiaoguang2022-08-141-1/+6
|
* Refactor legacy git init (#20376)wxiaoguang2022-08-092-7/+0
| | | | | | | | * merge `CheckLFSVersion` into `InitFull` (renamed from `InitWithSyncOnce`) * remove the `Once` during git init, no data-race now * for doctor sub-commands, `InitFull` should only be called in initialization stage Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix various typos (#20338)luzpaz2022-07-121-2/+2
| | | | | | | * Fix various typos Found via `codespell -q 3 -S ./options/locale,./options/license,./public/vendor -L actived,allways,attachements,ba,befores,commiter,pullrequest,pullrequests,readby,splitted,te,unknwon` Co-authored-by: zeripath <art27@cantab.net>
* Add username check to doctor (#20140)Gusted2022-06-271-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | * Add username check to doctor - Add a new breaking change detector to Gitea's doctor, which checks if all users still have a valid username according to Gitea. Given from time-to-time we need to make changes, either due to new routes or due to security, it's for a instance's admin to check if all users still have a valid username. * Fix extra argument * Apply suggestions from code review Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be> * Apply suggestions from code review Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: delvh <dev.lh@web.de>
* Add doctor command to write commit-graphs (#20007)zeripath2022-06-252-0/+79
| | | | | | | | This PR adds a doctor command to write the commit-graphs for the repositories: `gitea doctor --run check-commit-graphs --fix` Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add more linters to improve code readability (#19989)Wim2022-06-201-1/+1
| | | | | | | | | | 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)
* Backtick table name in generic orphan check (#20019)Gusted2022-06-191-2/+2
|
* Add dbconsistency checks for Stopwatches (#20010)zeripath2022-06-181-0/+6
| | | | | | | | | | It appears possible that stopwatches can become orphaned or have been orphaned in the past. This PR adds Orphan checks for Stopwatches. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move issues related files into models/issues (#19931)Lunny Xiao2022-06-132-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Add breaking email restrictions checker in doctor (#19903)Gusted2022-06-071-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add breaking change check in doctor - This patch introduces a new kind of doctor type, breaking. This file is made to register checks that helps with detecting when a breaking change might impact a Gitea instance. - For now the only check here(and the reason of creating this) is to check if all users in the database has a valid email address, which might not be the case after https://github.com/go-gitea/gitea/pull/17688. This _simply_ uses the validation function to detect and report these cases. - Helps admins with detecting #19897. - I have no clue which priority should be and IsDefault is true, because when breaking change happen and we have a doctor check for it, we can say "run `gitea doctor` to help you with this and maybe you find other errors :wink:". * Makes no sense tbh * Fix copyright * Update modules/doctor/breaking.go Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix inconsistency in doctor output (#19836)Gusted2022-05-312-4/+10
| | | | | | | | | | | | | * Fix inconsistency in doctor output - Use `logger.Info` instead of `logger.Warn` when no errors were found. * Update modules/doctor/fix16961.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move almost all functions' parameter db.Engine to context.Context (#19748)Lunny Xiao2022-05-201-1/+1
| | | | * Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
* [doctor] pq: syntax error at or near "." quote user table name (#19765)silentcodeg2022-05-201-2/+2
|
* [doctor] do not update User Stars numbers unless --fix (#19750)silentcodeg2022-05-191-3/+8
|
* [doctor] explain what enable-push-options does (#19740)silentcodeg2022-05-181-1/+1
|
* Add doctor orphan check for orphaned pull requests without an existing base ↵silentcodeg2022-05-181-0/+3
| | | | repo (#19731)
* Delete user related oauth stuff on user deletion too (#19677)65432022-05-111-0/+9
| | | | | * delete user related oauth stuff on user deletion too * extend doctor check-db-consistency
* [doctor] Add check/fix for bogus action rows (#19656)singuliere2022-05-101-0/+9
| | | | Signed-off-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Loïc Dachary <loic@dachary.org>
* [doctor] authorized-keys: fix displayed check name (#19464)Pilou2022-04-241-2/+2
| | | The registered check name is authorized-keys, not authorized_keys.
* Remove `git.Command.Run` and `git.Command.RunInDir*` (#19280)wxiaoguang2022-04-012-6/+6
| | | | | | Follows #19266, #8553, Close #18553, now there are only three `Run..(&RunOpts{})` functions. * before: `stdout, err := RunInDir(path)` * now: `stdout, _, err := RunStdString(&git.RunOpts{Dir:path})`
* Make git.OpenRepository accept Context (#19260)65432022-03-301-1/+1
| | | | | * OpenRepositoryCtx -> OpenRepository * OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
* Use `ctx` instead of `db.DefaultContext` in some ↵wxiaoguang2022-03-224-12/+12
| | | | | | | | | | | | packages(routers/services/modules) (#19163) * Remove `db.DefaultContext` usage in routers, use `ctx` directly * Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services` * Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages * fix incorrect context usage
* Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)65432022-02-062-6/+6
|
* format with gofumpt (#18184)65432022-01-203-3/+1
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Propagate context and ensure git commands run in request context (#17868)zeripath2022-01-1911-28/+38
| | | | | | | | | This PR continues the work in #17125 by progressively ensuring that git commands run within the request context. This now means that the if there is a git repo already open in the context it will be used instead of reopening it. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix various typos (#18219)luzpaz2022-01-101-1/+1
| | | | | Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Quote references to the user table in consistency checks (#18072)zeripath2021-12-221-2/+2
| | | | | | | | Although #17487 ensured that the table was quoted in the join it missed that the query part of the check also needed to be quoted. Fix #17485 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move keys to models/asymkey (#17917)Lunny Xiao2021-12-101-4/+4
| | | | | | | | | | | | | | | | | | | * Move keys to models/keys * Rename models/keys -> models/asymkey * change the missed package name * Fix package alias * Fix test * Fix docs * Fix test * Fix test * merge
* Move repository model into models/repo (#17933)Lunny Xiao2021-12-105-48/+51
| | | | | | | | | | | | | | | * 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
* Improve install code to avoid low-level mistakes. (#17779)wxiaoguang2021-12-012-2/+2
| | | | | | | | | | | | | | * 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 user related model into models/user (#17781)Lunny Xiao2021-11-241-1/+2
| | | | | | | | | | | | | * Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
* Move attachment into models/repo/ (#17650)Lunny Xiao2021-11-192-4/+5
| | | | | | | * Move attachment into models/repo/ * Fix test * Fix bug
* 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
* Move unit into models/unit/ (#17576)Lunny Xiao2021-11-091-7/+8
| | | | | * Move unit into models/unit/ * Rename unit.UnitType as unit.Type
* Fix bug on admin subcommand (#17533)Lunny Xiao2021-11-071-4/+5
| | | | | | | * Fix bug on admin subcommand * Add signals for all initDB Co-authored-by: Lauris BH <lauris@nix.lv>
* Rename db Engines related functions (#17481)Lunny Xiao2021-10-303-4/+4
| | | | | * Rename db Engines related functions Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Nicely handle missing user in collaborations (#17049)zeripath2021-09-271-253/+138
| | | | | | | | | | | | | | | | * Nicely handle missing user in collaborations It is possible to have a collaboration in a repository which refers to a no-longer existing user. This causes the repository transfer to fail with an unusual error. This PR makes `repo.getCollaborators()` nicely handle the missing user by ghosting the collaboration but also adds consistency check. It also adds an Access consistency check. Fix #17044 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Create doctor command to fix repo_units broken by dumps from 1.14.3-1.14.6 ↵zeripath2021-09-272-0/+589
| | | | | | | | | | | | | | | | (#17136) There was a serious issue with the `gitea dump` command in 1.14.3-1.14.6 which led to corruption of the `config` field of the `repo_unit` table. This PR adds a doctor command to attempt to fix the broken repo_units. Users affected by #16961 should run: ``` gitea doctor --fix --run fix-broken-repo-units ``` Fix #16961 Signed-off-by: Andrew Thornton <art27@cantab.net>
* DBContext is just a Context (#17100)zeripath2021-09-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-221-2/+1
| | | | | | | | | The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move db related basic functions to models/db (#17075)Lunny Xiao2021-09-195-12/+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>
* Add doctor dbconsistency check for release and attachment (#16978)Lunny Xiao2021-09-141-0/+36
|
* Fix storage Iterate bug and Add storage doctor to delete garbage attachments ↵Lunny Xiao2021-09-061-0/+76
| | | | | | | (#16971) * Fix storage Iterate bug and Add storage doctor to delete garbage attachments * Close object when used
* Restore creation of git-daemon-export-ok files (#16508)zeripath2021-07-221-0/+73
| | | | | | | | | | | | | | Somewhere along the line the creation of git-daemon-export-ok files disappeared but the updating of these files when repo visibility changes remained. The problem is that the current state will create files even when the org or user is private. This PR restores creation correctly. Fix #15521 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Rework repository archive (#14723)Lunny Xiao2021-06-231-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use storage to store archive files * Fix backend lint * Add archiver table on database * Finish archive download * Fix test * Add database migrations * Add status for archiver * Fix lint * Add queue * Add doctor to check and delete old archives * Improve archive queue * Fix tests * improve archive storage * Delete repo archives * Add missing fixture * fix fixture * Fix fixture * Fix test * Fix archiver cleaning * Fix bug * Add docs for repository archive storage * remove repo-archive configuration * Fix test * Fix test * Fix lint Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add err to log (#15813)John Olheiser2021-05-101-1/+1
| | | | Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Delete references if repository gets deleted (#15681)KN4CK3R2021-04-301-9/+46
| | | | | | | * Remove DeletedBranch and LFSLocks. * Sort beans. Co-authored-by: zeripath <art27@cantab.net>
* Delete protected branch if repository gets removed (#15658)KN4CK3R2021-04-301-8/+26
| | | | | | | * Added missing error parameters. * Delete protected branch if repository gets removed. * Added doctor fix.
* Delete Labels & IssueLabels on Repo Delete too (#15039)65432021-03-191-1/+18
| | | | | | | | | | | | | | | | | | | | | | | * 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?