aboutsummaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Set is_empty in fixtures (#18869)KN4CK3R2022-02-262-2/+32
|
* Don't update email for organisation (#18905)Gusted2022-02-261-1/+1
| | | | | | | - Fix regression caused by: f1b1472632e36c3bb5df73f184a6efeef47f5d01 - Don't try to insert a email for Organisation(as they don't have one). - Resolves #18891 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Set is_private in fixtures. (#18868)KN4CK3R2022-02-251-0/+2
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix migration v210 (#18892)Lunny Xiao2022-02-251-4/+10
|
* migrations: add test for importing pull requests in gitea uploader (#18752)singuliere2022-02-251-0/+5
| | | | | | | | | | | | | | | | | | | * logs: add the buffer logger to inspect logs during testing Signed-off-by: Loïc Dachary <loic@dachary.org> * migrations: add test for importing pull requests in gitea uploader Signed-off-by: Loïc Dachary <loic@dachary.org> * for each git.OpenRepositoryCtx, call Close * Content is expected to return the content of the log * test for errors before defer Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix update user (#18878)Lunny Xiao2022-02-241-3/+4
|
* Fix ldap user sync missed email in email_address table (#18786)Lunny Xiao2022-02-241-5/+25
| | | | | * Fix ldap user sync missed email in email_address table * Fix test
* Update assignees check to include any writing team and change org sidebar ↵zeripath2022-02-231-11/+40
| | | | | | | | | | | | (#18680) Following the merging of #17811 teams can now have differing write and readonly permissions, however the assignee list will not include teams which have mixed perms. Further the org sidebar is no longer helpful as it can't describe these mixed permissions situations. Fix #18572 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Lock gofumpt to v0.3.0 and run it (#18866)silverwind2022-02-233-2/+4
| | | | | We can't depend on `latest` version of gofumpt because the output will not be stable across versions. Lock it down to the latest version released yesterday and run it again.
* Fix bug for get user by email (#18833)Lunny Xiao2022-02-211-12/+2
| | | Co-authored-by: zeripath <art27@cantab.net>
* Show fullname on issue edits and gpg/ssh signing info (#18827)Wim2022-02-202-3/+5
| | | | | Show missing full names when configured to do so Co-authored-by: zeripath <art27@cantab.net>
* Fix ldap loginname (#18789)Johan Van de Wauw2022-02-181-0/+14
| | | | | | | | | | | | | | | | | | | | * Use email_address table to check user's email when login with email adress * Update services/auth/signin.go * Fix test * Fix test * Fix logging in with ldap username != loginname * Fix if user does not exist yet * Make more clear this is loginName * Fix formatting Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Move deletebeans into models/db (#18781)Lunny Xiao2022-02-174-16/+15
|
* Attempt to fix the webauthn migration again - part 3 (#18770)zeripath2022-02-1610-251/+190
| | | | | | | | v208.go is seriously broken as it misses an ID() check. We need to no-op and remigrate all of the u2f keys. See #18756 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix display time of milestones (#18753)René Schaar2022-02-163-38/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | * Fix display time of milestones * Move the SecToTime function From the models/issue_stopwatch.go file to the modules/util package * Rename the sec_to_time file * Updated formatting * Include copyright notice in sec_to_time.go * Apply PR review suggestions - Update copyright notice dates to 2022 - Change `1 day 3h 5min 7s` to `1d 3h 5m 7s` * Rename hrs var and combine conditions * Update unit tests to match new time pattern Changed `1min` to `1m` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Ignore the migrate if u2f_registration is not exist (#18760)Lunny Xiao2022-02-141-0/+8
|
* Increase the size of the webauthn_credential credential_id field (#18739)zeripath2022-02-138-2/+274
| | | | | | | | | | | Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255) This problem is not apparent on SQLite because strings get mapped to TEXT there. Fix #18727 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Let `MinUnitAccessMode` return correct perm (#18675)Gusted2022-02-081-1/+6
| | | | | | | | | - Don't let `TypeExternalTracker` or `TypeExternalWiki` influence the minimal permission, as they won't be higher than read. So even if all the other ones are write, these 2 will ensure that's not higher than read. - Partially resolves #18572 (Point 1,2,5?) Co-authored-by: zeripath <art27@cantab.net>
* Added auto-save whitespace behavior if it changed manually (#15566)Viktor Suprun2022-02-081-1/+3
|
* Add separate SSH_USER config option (#17584)Clar Fon2022-02-073-5/+4
| | | Co-authored-by: zeripath <art27@cantab.net>
* Be more lenient with label colors (#17752)Clar Fon2022-02-072-3/+24
| | | Accept 12-bit color specifications.
* remove redundant call to UpdateRepoStats during migration (#18591)singuliere2022-02-072-36/+4
| | | | | | | | | | | | | | | | | | | | | | | There is no need to call UpdateRepoStats in the InsertIssues and InsertPullRequests function. They are only called during migration by the CreateIssues and CreateReviews methods of the gitea uploader. The UpdateRepoStats function will be called by the Finish method of the gitea uploader after all reviews and issues are inserted. Calling it before is therefore redundant and the associated SQL requests are not cheap. The statistics tests done after inserting an issue or a pull request are also removed. They predate the implementation of UpdateRepoStats, back when the calculation of the statistics was an integral part of the migration function. The UpdateRepoStats is now tested independantly and these tests are no longer necessary. Signed-off-by: singuliere <singuliere@autistici.org> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* No longer show the db-downgrade SQL in production (#18653)wxiaoguang2022-02-071-3/+6
| | | * make messages more friendly
* Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)65432022-02-062-6/+6
|
* Pass correct context (#18638)Gusted2022-02-061-1/+1
| | | | - Pass the correct context into `db.GetEngine()`. - Introduced in: https://github.com/go-gitea/gitea/pull/18604
* preserve users if restoring a repository on the same Gitea instance (#18604)singuliere2022-02-061-0/+13
| | | | | | | | | | | | | | | | | | | | | When calling DumpRepository and RestoreRepository on the same Gitea instance, the users are preserved: all labels, issues etc. belong to the external user who is, in this particular case, the local user. Dead code verifying g.gitServiceType.Name() == "" (i.e. plain git) is removed. The function is never called because the plain git downloader does not migrate anything that is associated to a user, by definition. Errors returned by GetUserIDByExternalUserID are no longer ignored. The userMap is used when the external user is not kown, which is the most common case. It was only used when the external user exists which happens less often and, as a result, every occurence of an unknown external user required a SQL query. Signed-off-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Use `CryptoRandomBytes` instead of `CryptoRandomString` (#18439)Gusted2022-02-041-4/+18
| | | | | | - Switch to use `CryptoRandomBytes` instead of `CryptoRandomString`, OAuth's secrets are copied pasted and don't need to avoid dubious characters etc. - `CryptoRandomBytes` gives ![2^256 = 1.15 * 10^77](https://render.githubusercontent.com/render/math?math=2^256%20=%201.15%20\cdot%2010^77) `CryptoRandomString` gives ![62^44 = 7.33 * 10^78](https://render.githubusercontent.com/render/math?math=62^44%20=%207.33%20\cdot%2010^78) possible states. - Add a prefix, such that code scanners can easily grep these in source code. - 32 Bytes + prefix
* Collaborator trust model should trust collaborators (#18539)zeripath2022-02-022-6/+6
| | | | | | | | | | * Collaborator trust model should trust collaborators There was an unintended regression in #17917 which leads to only repository admin commits being trusted. This PR restores the old logic. Fix #18501 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add `GetUserTeams` (#18499)Gusted2022-02-012-10/+55
| | | | | | | | | | | | | | | | | | | | * COrrect use `UserID` in `SearchTeams` - Use `UserID` in the `SearchTeams` function, currently it was useless to pass such information. Now it does a INNER statement to `team_user` which obtains UserID -> TeamID data. - Make OrgID optional. - Resolves #18484 * Seperate searching specific user * Add condition back * Use correct struct type Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* add test coverage for original author conversion during migrations (#18506)singuliere2022-02-017-0/+97
| | | | | | | | | | | | | | | | | | * add test coverage for original author conversion during migrations And create a function to factorize a code snippet that is repeated five times and would otherwise be more difficult to test and maintain consistently. Signed-off-by: Loïc Dachary <loic@dachary.org> * fix variable scope and int64 formatting * add missing calls to remapExternalUser and fix misplaced %d Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix non-ASCII search on database (#18437)Gusted2022-02-011-1/+7
| | | Use `ToASCIIUpper` for SQLite database on issues search, this because `UPPER(x)` on SQLite only transforms ASCII letters. Resolves #18429
* Fix for AvatarURL database type (#18487)Viktor Kuzmin2022-02-011-1/+1
|
* Allow to filter repositories by language in explore, user and organization ↵Lauris BH2022-01-281-0/+9
| | | | repositories lists (#18430)
* Automatically pause queue if index service is unavailable (#15066)Lauris BH2022-01-273-8/+10
| | | | | | * Handle keyword search error when issue indexer service is not available * Implement automatic disabling and resume of code indexer queue
* Only view milestones from current repo (#18414)zeripath2022-01-261-16/+0
| | | | | | The endpoint /{username}/{reponame}/milestone/{id} is not currently restricted to the repo. This PR restricts the milestones to those within the repo. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Use base32 for 2FA scratch token (#18384)wxiaoguang2022-01-265-6/+10
| | | | * Use base32 for 2FA scratch token * rename Secure* to Crypto*, add comments
* API: Return primary language and repository language stats API URL (#18396)Lauris BH2022-01-252-2/+26
|
* Add packagist webhook (#18224)Dr. Tobias Quathamer2022-01-231-0/+1
| | | | Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add config options to hide issue events (#17414)qwerty2872022-01-214-19/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add config option to hide issue events Adds a config option `HIDE_ISSUE_EVENTS` to hide most issue events (changed labels, milestones, projects...) on the issue detail page. If this is true, only the following events (comment types) are shown: * plain comments * closed/reopned/merged * reviews * Make configurable using a list * Add docs * Add missing newline * Fix merge issues * Allow changes per user settings * Fix lint * Rm old docs * Apply suggestions from code review * Use bitsets * Rm comment * fmt * Fix lint * Use variable/constant to provide key * fmt * fix lint * refactor * Add a prefix for user setting key * Add license comment * Add license comment * Update services/forms/user_form_hidden_comments.go Co-authored-by: Gusted <williamzijl7@hotmail.com> * check len == 0 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: 6543 <6543@obermui.de>
* format with gofumpt (#18184)65432022-01-2027-62/+45
| | | | | | | | | | | * 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-1914-48/+57
| | | | | | | | | 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 PR comments UI (#18323)wxiaoguang2022-01-191-1/+1
| | | | | Closes: * Review comment cannot be edited #17768 * Changing PR Comment Resolved State Disables Further Changes #18315
* Prevent ambiguous column error in organizations page (#18314)zeripath2022-01-181-5/+5
| | | | | | | | Explicitly set the table for the org_id column queries on the organizations pages. Fix #18229 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix CheckRepoStats and reuse it during migration (#18264)Aravinth Manivannan2022-01-179-168/+215
| | | | | | | | | | | | | | | | | | | The CheckRepoStats function missed the following counters: - label num_closed_issues & num_closed_pulls - milestone num_closed_issues & num_closed_pulls The update SQL statements for updating the repository num_closed_issues & num_closed_pulls fields were repeated in three functions (repo.CheckRepoStats, migrate.insertIssues and models.Issue.updateClosedNum) and were moved to a single helper. The UpdateRepoStats is implemented and called in the Finish migration method so that it happens immediately instead of wating for the CheckRepoStats to run. Signed-off-by: Loïc Dachary loic@dachary.org --- [source](https://lab.forgefriends.org/forgefriends/forgefriends/-/merge_requests/34)
* Webauthn nits (#18284)zeripath2022-01-154-9/+62
| | | | | | | This contains some additional fixes and small nits related to #17957 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support webauthn (#17957)Lunny Xiao2022-01-149-262/+393
| | | | | | | Migrate from U2F to Webauthn Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Improve the comment for 2FA filter in admin panel (#18017)Gusted2022-01-131-1/+3
| | | | | Replace TODO with explanation Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* fix regression from #16075 (#18260)Norwin2022-01-141-3/+2
| | | | | | we don't want reviews to count towards comments, as this needs changes in other components as well (eg repo stats cron job, etc). Co-authored-by: 6543 <6543@obermui.de>
* migrations: a deadline at January 1st, 1970 is valid (#18237)Aravinth Manivannan2022-01-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * migrations: a deadline at January 1st, 1970 is valid Do not change the deadline value if it is set to January 1st, 1970. Setting the deadline to year 9999 when it is zero (which is equal to January 1st, 1970) modifies a deadline set to January 1st, 1970 which is a valid date. In addition, setting a date in year 9999 will be converted to a null date in some cases. Signed-off-by: Loïc Dachary <loic@dachary.org> * tests: set milestone.deadline_unix in fixtures The value of deadline_unix must be set to 253370764800 (i.e. 9999-01-01) in fixtures, otherwise it will be inserted as null which leads to unexpected errors. For instance, DumpRepository will store a null deadline_unix as 0 (i.e. 1970-01-01) and RestoreRepository will change it to 9999-01-01. Signed-off-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix update user bug (#18250)Lunny Xiao2022-01-121-1/+1
|