* 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 <[email protected]>
Co-authored-by: KN4CK3R <[email protected]>
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 <[email protected]>
* 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 <[email protected]>
* fix unit tests
Signed-off-by: Andrew Thornton <[email protected]>
* another place that needs to set the initial context
Signed-off-by: Andrew Thornton <[email protected]>
* avoid race
Signed-off-by: Andrew Thornton <[email protected]>
* change attachment error
Signed-off-by: Andrew Thornton <[email protected]>
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 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
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 <[email protected]>
* 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 <[email protected]>
* switch to use sql
Signed-off-by: Andrew Thornton <[email protected]>
* remove AS
Signed-off-by: Andrew Thornton <[email protected]>
* subquery alias
Signed-off-by: Andrew Thornton <[email protected]>
* Give me some AS?
Signed-off-by: Andrew Thornton <[email protected]>
* double AS
Signed-off-by: Andrew Thornton <[email protected]>
* try try again
Signed-off-by: Andrew Thornton <[email protected]>
* once more around the merry go round
Signed-off-by: Andrew Thornton <[email protected]>
* fix api problem
Signed-off-by: Andrew Thornton <[email protected]>
* 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 <[email protected]>
* fix migration
Signed-off-by: Andrew Thornton <[email protected]>
* prep for merge
Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
* 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 <[email protected]>
* let us try information_schema instead
Signed-off-by: Andrew Thornton <[email protected]>
* try again
Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
Co-authored-by: 6543 <[email protected]>
* Prevent adding nil label to .AddedLabels or .RemovedLabels
There are possibly a few old databases out there with malmigrated data that can
cause panics with empty labels being migrated.
This PR adds a few tests to prevent nil labels being added.
Fix#14466
Signed-off-by: Andrew Thornton <[email protected]>
* Add doctor command to remove the broken label comments
Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: 6543 <[email protected]>
* Refactor Logger
Refactor Logger to make a logger interface and make it possible to
wrap loggers for specific purposes.
* Refactor Doctor
Move the gitea doctor functions into its own module.
Use a logger for its messages instead of returning a results string[]
Signed-off-by: Andrew Thornton <[email protected]>
* Update modules/doctor/misc.go
Co-authored-by: 6543 <[email protected]>
* Update modules/doctor/misc.go
Co-authored-by: 6543 <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-authored-by: techknowlogick <[email protected]>