aboutsummaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Refactor container package (#34877)HEADmainwxiaoguang13 hours1-0/+9
| | | Use standard db.WithTx and introduce db.WithTx2
* enforce explanation for necessary nolints and fix bugs (#34883)TheFox0x72 days9-39/+15
| | | | | | | Follows up https://github.com/go-gitea/gitea/pull/34851 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* enforce nolint scope (#34851)TheFox0x72 days286-288/+293
| | | | | | | | | | | | | | | enable nolintlint scope requirement add comments to new directives so it's more obvious why they are in place --- I can also toggle the mandatory comments on if that's something of interest. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Use standalone function to update repository cols (#34811)Lunny Xiao3 days1-12/+6
| | | | | | | | Extract `UpdateRepository` Follow up #34762 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix some log and UI problems (#34863)wxiaoguang4 days3-3/+3
| | | | | Remove the misleading error log, fix #34738 Make the "search" input auto-focused, fix #34807
* Fix archive API (#34853)wxiaoguang4 days1-0/+1
| | | Fix #34852
* fix(issue): Replace stopwatch toggle with explicit start/stop actions (#34818)Junsik Kong5 days2-138/+90
| | | | | | | | | | | | | | | | This PR fixes a state de-synchronization bug with the issue stopwatch, it resolves the issue by replacing the ambiguous `/toggle` endpoint with two explicit endpoints: `/start` and `/stop`. - The "Start timer" button now exclusively calls the `/start` endpoint. - The "Stop timer" button now exclusively calls the `/stop` endpoint. This ensures the user's intent is clearly communicated to the server, eliminating the state inconsistency and fixing the bug. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix team permissions (#34827)wxiaoguang5 days6-41/+85
| | | | * Fix #34793 * Fix #33456
* Fix job status aggregation logic (#34823)JIUN-TAI NIEN5 days2-5/+5
|
* Edit file workflow for creating a fork and proposing changes (#34240)Brecht Van Lommel7 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When viewing a file that the user can't edit because they can't write to the branch, the new, upload, patch, edit and delete functionality is no longer disabled. If no user fork of the repository exists, there is now a page to create one. It will automatically create a fork with a single branch matching the one being viewed, and a unique repository name will be automatically picked. When a fork exists, but it's archived, a mirror or the user can't write code to it, there will instead be a message explaining the situation. If the usable fork exists, a message will appear at the top of the edit page explaining that the changes will be applied to a branch in the fork. The base repository branch will be pushed to a new branch to the fork, and then the edits will be applied on top. The suggestion to fork happens when accessing /_edit/, so that for example online documentation can have an "edit this page" link to the base repository that does the right thing. Also includes changes to properly report errors when trying to commit to a new branch that is protected, and when trying to commit to an existing branch when choosing the new branch option. Resolves #9017, #20882 --------- Co-authored-by: Brecht Van Lommel <brecht@blender.org> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add post-installation redirect based on admin account status (#34493)Kerwin Bryant8 days1-0/+14
| | | | | | | | | | | | | | | | This PR adds a feature to direct users to appropriate pages after system installation: - If no admin credentials were provided during installation, redirect to the registration page with a prominent notice about creating the first administrative account - If admin credentials were already set, redirect directly to the login page ![4d396ad132d9b57fc4f45a62117177f1](https://github.com/user-attachments/assets/3a5d8700-9194-4d3b-a862-e64c8c347932) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor editor (#34780)wxiaoguang8 days1-2/+0
| | | A complete rewrite
* Add workflow_run api + webhook (#33964)ChristopherHX9 days6-20/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#list-jobs-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#get-a-job-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#get-a-workflow-run - `/actions/runs` for global + user + org (Gitea only) - `/actions/jobs` for global + user + org + repository (Gitea only) - workflow_run webhook + action trigger - limitations - workflow id is assigned to a string, this may result into problems in strongly typed clients Fixes - workflow_job webhook url to no longer contain the `runs/<run>` part to align with api - workflow instance does now use it's name inside the file instead of filename if set Refactoring - Moved a lot of logic from workflows/workflow_job into a shared module used by both webhook and api TODO - [x] Verify Keda Compatibility - [x] Edit Webhook API bug is resolved Closes https://github.com/go-gitea/gitea/issues/23670 Closes https://github.com/go-gitea/gitea/issues/23796 Closes https://github.com/go-gitea/gitea/issues/24898 Replaces https://github.com/go-gitea/gitea/pull/28047 and is much more complete --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Upgrade `gopls` to v0.19.0, add `make fix` (#34772)silverwind11 days1-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upgrade to [v0.19.0](https://github.com/golang/tools/releases/tag/gopls%2Fv0.19.0) and fix issues. Runs with new `warning` serverity setting. This likely does less checks than before. Additionally, add `make fix` which runs modernize. This is also verified on CI. For the record, here are the issues discoverd when running with `info` severity, in case we want to fix these: ``` tests/integration/repo_test.go:95:5-14: could use tagged switch on i tests/integration/api_packages_generic_test.go:149:4-64: could use tagged switch on setting.Packages.Storage.Type services/webhook/msteams_test.go:33:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:59:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:85:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:111:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:138:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:161:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:187:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:213:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:239:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:266:4-33: could use tagged switch on fact.Name services/webhook/msteams_test.go:407:4-33: could use tagged switch on fact.Name tests/integration/api_packages_conan_test.go:350:6-33: could use tagged switch on pf.Name models/issues/tracked_time_test.go:98:3-18: could use tagged switch on user.ID tests/integration/api_token_test.go:505:5-43: could use tagged switch on minRequiredLevel services/gitdiff/gitdiff.go:220:33-46: method "getLineLegacy" is unused ``` --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix some package registry problems (#34759)wxiaoguang11 days1-2/+2
| | | | 1. Fix #33787 2. Fix container image display
* when using rules to delete packages, remove unclean bugs (#34632)anthony-zh11 days2-21/+17
| | | | | | | | | | | | | By default, the code extracts 200 package versions. If too many packages are generated every day or if rule cleaning is enabled later, which means there are more than 200 versions corresponding to the library package, it may not be cleaned up completely, resulting in residue Fix #31961 --------- Co-authored-by: yeyuanjie <yecao100@126.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Run `gopls modernize` on codebase (#34751)silverwind12 days33-196/+75
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Fix ghost user in feeds when pushing in an actions, it should be ↵Lunny Xiao12 days1-1/+1
| | | | gitea-actions (#34703)
* Improve nuget/rubygems package registries (#34741)wxiaoguang12 days3-16/+5
| | | | | | | | 1. Add some missing (optional) fields for nuget v2, and sort the fields to make it easier to maintain 2. Add missing "platform" for rubygems: `VERSION-PLATFORM` and `VERSION_PLATFORM` Co-authored-by: Giteabot <teabot@gitea.io>
* Replace update repository function in some places (#34566)Lunny Xiao12 days4-20/+7
| | | | | | | | | | | | `UpdateAllCols` is dangerous, the columns should be updated when necessary. This PR replaces some `updateRepository` invokes to reduce possible problems and wrongly updated time. Some parts have been fixed in #34388, but some are hidden in the function `updateRepository`. Alternatively, using `UpdateRepositoryColsNoAutoTime` to update the changed columns. Some `UpdateRepoSize` invokes are duplicated, so they will be removed when extracting from `updateRepository`.
* Allow renaming/moving binary/LFS files in the UI (#34350)bytedream13 days1-0/+12
| | | | | | | | | | | | | | | | | | | Adds the ability to rename/move binary files like binary blobs or images and files that are too large in the web ui. This was purposed in #24722, along with the ability edit images via an upload of a new image, which I didn't implement here (could be done in a separate PR). Binary file content: ![binary](https://github.com/user-attachments/assets/61d9ff71-25d3-4832-9288-452cdefc7283) File too large: ![toolarge](https://github.com/user-attachments/assets/3b42dbd0-e76a-4c3c-92d2-52ebffedea64) GitHub does the same (I've copied the text from there): ![gh](https://github.com/user-attachments/assets/e1499813-fb71-4544-9d58-086046a5f13e)
* Refactor container and UI (#34736)wxiaoguang13 days4-3/+26
|
* Fix commit message rendering and some UI problems (#34680)wxiaoguang2025-06-102-13/+18
| | | | | | * Fix #34679 * Fix #34676 * Fix #34674 * Fix #34526
* Update x/crypto package and make builtin SSH use default parameters (#34667)wxiaoguang2025-06-091-1/+1
|
* Fix footnote jump behavior on the issue page. (#34621)charles2025-06-092-3/+9
| | | | | | | | | | Close #34511 Close #34590 Add comment ID to the footnote item's id attribute to ensure uniqueness. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Keeping consistent between UI and API about combined commit status state and ↵Lunny Xiao2025-06-093-72/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix some bugs (#34562) Extract from #34531 ## Move Commit status state to a standalone package Move the state from `structs` to `commitstatus` package. It also introduce `CommitStatusStates` so that the combine function could be used from UI and API logic. ## Combined commit status Changed This PR will follow Github's combined commit status. Before this PR, every commit status could be a combined one. According to https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#get-the-combined-status-for-a-specific-reference > Additionally, a combined state is returned. The state is one of: > failure if any of the contexts report as error or failure > pending if there are no statuses or a context is pending > success if the latest status for all contexts is success This PR will follow that rule and remove the `NoBetterThan` logic. This also fixes the inconsistent between UI and API. In the API convert package, it has implemented this which is different from the UI. It also fixed the missing `URL` and `CommitURL` in the API. ## `CalcCommitStatus` return nil if there is no commit statuses The behavior of `CalcCommitStatus` is changed. If the parameter commit statuses is empty, it will return nil. The reference places should check the returned value themselves.
* Refactor FindOrgOptions to use enum instead of bool, fix membership ↵wxiaoguang2025-06-093-22/+43
| | | | visibility (#34629)
* Fix GetUsersByEmails (#34643)wxiaoguang2025-06-073-17/+43
|
* Fix issue label delete incorrect labels webhook payload (#34575)badhezi2025-06-031-0/+1
| | | | | | | | Fixes https://github.com/go-gitea/gitea/issues/34560 explanation of the bug in the issue setting `issue.isLabelsLoaded = false` before calling `deleteIssueLabel` guarantee we will load the new state of the labels into the issue object before sending it in the webhook.
* Refactor some tests (#34580)wxiaoguang2025-06-033-14/+4
| | | | 1. use `test.MockVariableValue` as much as possible 2. avoid `time.Sleep` as much as possible
* Do not mutate incoming options to SearchRepositoryByName (#34553)Philip Peterson2025-06-023-61/+63
| | | | | | | | | | | | | | Similar to #34544, this PR changes the `opts` argument in `SearchRepositoryByName()` to be passed by value instead of by pointer, as its mutations do not escape the function scope and are not used elsewhere. This simplifies reasoning about the function and avoids unnecessary pointer usage. This insight emerged during an initial attempt to refactor `RenderUserSearch()`, which currently intermixes multiple concerns. --------- Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
* Fix/improve avatar sync from LDAP (#34573)Râu Cao2025-06-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes 3 issues I encountered when debugging problems with our LDAP sync: 1. The comparison of the hashed image data in `IsUploadAvatarChanged` is wrong. It seems to be from before avatar hashing was changed and unified in #22289. This results in the function always returning `true` for any avatars, even if they weren't changed. 2. Even if there's no avatar to upload (i.e. no avatar available for the LDAP entry), the upload function would still be called for every single user, only to then fail, because the data isn't valid. This is unnecessary. 3. Another small issue is that the comparison function (and thus hashing of data) is called for every user, even if there is no avatar attribute configured at all for the LDAP source. Thus, I switched the condition nesting, so that no cycles are wasted when avatar sync isn't configured in the first place. I also added a trace log for when there is actually a new avatar being uploaded for an existing user, which is now only shown when that is actually the case. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix some trivial problems (#34579)wxiaoguang2025-06-021-1/+1
|
* Fix doctor deleting orphaned issues attachments (#34142)Lunny Xiao2025-05-301-135/+8
| | | | Fix the bug when deleting orphaned issues attachments. The attachments maybe stored on other storages service rather than disk.
* Fix actions skipped commit status indicator (#34507)badhezi2025-05-282-2/+12
| | | | | Addresses https://github.com/go-gitea/gitea/issues/34500 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Do not mutate incoming options to RenderUserSearch and SearchUsers (#34544)Philip Peterson2025-05-272-20/+20
| | | | | | | | | | | This PR changes the `opts` argument in `SearchUsers()` to be passed by value instead of by pointer, as its mutations do not escape the function scope and are not used elsewhere. This simplifies reasoning about the function and avoids unnecessary pointer usage. This insight emerged during an initial attempt to refactor `RenderUserSearch()`, which currently intermixes multiple concerns. Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
* Split GetLatestCommitStatus as two functions (#34535)Lunny Xiao2025-05-264-14/+52
| | | | | | | | Extract from #34531. This will reduce unnecessary count operation in databases. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add sort option recentclose for issues and pulls (#34525)Markus Amshove2025-05-263-1/+46
| | | | | | closes #34171 Adds a new sort option `recentclose` for issues and pull requests which will return items in a descending order of when they were closed
* Performance optimization for tags synchronization (#34355)Lunny Xiao2025-05-221-54/+7
| | | | | | | | | The tags synchronization is very slow for a non-mirror repository with many tags especially forking. This PR make all repositories' tags synchronization use the same function and remove the low performance synchronization function. The commit count of tag now will not be stored into database when syncing. Since the commits count will always be read from cache or git data, the `NumCommits` in the release table will be updated for the first read from git data.
* Fix ephemeral runner deletion (#34447)ChristopherHX2025-05-204-0/+54
| | | | | | | | | * repository deletion, delete ephemeral runners with active tasks as well skips regular cleanup * user deletion, delete ephemeral runners with active tasks as well skips regular cleanup * delete ephemeral runners once status changes to done * You no longer see used ephemeral runners after the task is done * if you see one the cron job takes care of it
* Use run-name and evaluate workflow variables (#34301)badhezi2025-05-201-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses https://github.com/go-gitea/gitea/issues/34247 depends on https://gitea.com/gitea/act/pulls/137 I couldn't find any previous implementation for `run-name` support on workflows so I created one. Key points: All dispatched workflows, scheduled workflows and detected workflows (from different hooks) will use and evaluate `run-name` if exists, with the corresponding gitea context and variables. This will be used as the Action run title and replace the default commit message being used today. Had to change act package jobparser (see link above) and create two helpers https://github.com/go-gitea/gitea/blob/3a1320c70df82ae88e286612c1646cffb8e2c343/models/actions/utils.go#L86 and https://github.com/go-gitea/gitea/blob/3a1320c70df82ae88e286612c1646cffb8e2c343/services/actions/context.go#L169 to pass the correct types to [GenerateGiteaContext](https://github.com/go-gitea/gitea/pull/34301/files#diff-9c9c27cb61a33e55ad33dc2c2e6a3521957a3e5cc50ddf652fdcd1def87b044dR86) and [WithGitContext](https://gitea.com/gitea/act/src/commit/65c232c4a5a40e59e257ab5d956b32585f0405d7/pkg/jobparser/jobparser.go#L84) respectively. <img width="1336" alt="Screenshot 2025-04-28 at 17 13 01" src="https://github.com/user-attachments/assets/73cb03d0-23a0-4858-a466-bbf0748cea98" />
* Add migrations tests (#34456)Lunny Xiao2025-05-154-2/+99
| | | | | Fix #34455 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add endpoint deleting workflow run (#34337)NorthRealm2025-05-137-16/+140
| | | | | | | | | | | Add endpoint deleting workflow run Resolves #26219 /claim #26219 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix remove org user failure on mssql (#34449)ChristopherHX2025-05-143-48/+6
| | | | | | | | | | | * mssql does not support fetching 0 repositories * remove paging by NumRepos that might be 0 * extend admin api test to purge user 2 Fixes #34448 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Only git operations should update `last changed` of a repository (#34388)Lunny Xiao2025-05-113-4/+5
| | | Try to fix #32046
* Fix GetUsersByEmails (#34423)wxiaoguang2025-05-102-8/+20
| | | Fix #34418, fix #34353
* Fix a bug when uploading file via lfs ssh command (#34408)Lunny Xiao2025-05-092-9/+33
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor commit message rendering and fix bugs (#34412)wxiaoguang2025-05-091-1/+1
| | | | | | Fix #34398, fix #33308 Remove all `repo.ComposeCommentMetas` from templates, only use `repo` to render commit message.
* feat: add label 'state' to metric 'gitea_users' (#34326)Tobias Balle-Petersen2025-05-072-2/+21
| | | | | | | | | | | | | | | | | | This PR adds the label _state_ to the metric _gitea_users_. With the change, _gitea_users_ would be reported like this: ``` ... # HELP gitea_users Number of Users # TYPE gitea_users gauge gitea_users{state="active"} 20 gitea_users{state="inactive"} 10 ... ``` The metrics above would be from a Gitea instance with 30 user accounts. 20 of the accounts are active and 10 of the accounts are not active. Resolve #34325
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)wxiaoguang2025-04-286-20/+97
| | | | | | | | | | | | | | | | | | | | | Fix #880 Design: 1. A global setting `security.TWO_FACTOR_AUTH`. * To support org-level config, we need to introduce a better "owner setting" system first (in the future) 2. A user without 2FA can login and may explore, but can NOT read or write to any repositories via API/web. 3. Keep things as simple as possible. * This option only aggressively suggest users to enable their 2FA at the moment, it does NOT guarantee that users must have 2FA before all other operations, it should be good enough for real world use cases. * Some details and tests could be improved in the future since this change only adds a check and seems won't affect too much. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>