aboutsummaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Fix "force private" logic (#31012)wxiaoguang2024-05-203-3/+3
| | | | | When creating a repo, the "FORCE_PRIVATE" config option should be respected, `readonly` doesn't work for checkbox, so it should use `disabled` attribute.
* Fix bug on avatar (#31008)Lunny Xiao2024-05-191-10/+20
| | | Co-authored-by: silverwind <me@silverwind.io>
* Check if the release is converted from the tag when updating the release ↵Zettat1232024-05-151-2/+8
| | | | | | (#30984) Call `notify_service.NewRelease` when a release is created from an existing tag.
* Check if reverse proxy is correctly configured (#30890)wxiaoguang2024-05-102-2/+3
| | | | | | | | | Follow #27011 Follow #30885 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
* Fix incorrect default branch when adopt a repository (#30912)yp053272024-05-091-21/+16
| | | | | | | Fix #30521 we should sync branches first, then detect default branch, or `git_model.FindBranchNames` will always return empty list, and the detection will be wrong.
* Fix misspelling of mergable (#30896)yp053272024-05-082-6/+6
| | | | https://github.com/go-gitea/gitea/pull/25812#issuecomment-2099833692 Follow #30573
* Update issue indexer after merging a PR (#30715)Zettat1232024-05-081-0/+16
| | | Fix #30684
* Fix various problems around projects board view (#30696)Lunny Xiao2024-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | # The problem The previous implementation will start multiple POST requests from the frontend when moving a column and another bug is moving the default column will never be remembered in fact. # What's changed - [x] This PR will allow the default column to move to a non-first position - [x] And it also uses one request instead of multiple requests when moving the columns - [x] Use a star instead of a pin as the icon for setting the default column action - [x] Inserted new column will be append to the end - [x] Fix #30701 the newly added issue will be append to the end of the default column - [x] Fix when deleting a column, all issues in it will be displayed from UI but database records exist. - [x] Add a limitation for columns in a project to 20. So the sorting will not be overflow because it's int8. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor AppURL usage (#30885)wxiaoguang2024-05-072-2/+2
| | | | | | | | Fix #30883 Fix #29591 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Move database operations of merging a pull request to post receive hook and ↵Lunny Xiao2024-05-073-18/+25
| | | | | | | | | | | | | | | | | | | | add a transaction (#30805) Merging PR may fail because of various problems. The pull request may have a dirty state because there is no transaction when merging a pull request. ref https://github.com/go-gitea/gitea/pull/25741#issuecomment-2074126393 This PR moves all database update operations to post-receive handler for merging a pull request and having a database transaction. That means if database operations fail, then the git merging will fail, the git client will get a fail result. There are already many tests for pull request merging, so we don't need to add a new one. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make "sync branch" also sync object format and add tests (#30878)wxiaoguang2024-05-061-0/+4
|
* Make sure git version&feature are always prepared (#30877)wxiaoguang2024-05-064-4/+4
| | | Otherwise there would be more similar issues like #29287
* Ignore useless error message "broken pipe" (#30801)wxiaoguang2024-05-032-4/+3
| | | Fix #30792
* Fix incorrect message id for releaes email (#30825)wxiaoguang2024-05-023-8/+20
| | | | Make generateMessageIDForRelease outputs the same format as generateMessageIDForIssue (old `createReference`)
* Add API endpoints for getting action jobs status (#26673)Chester2024-05-011-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sample of response, it is similar to Github actions ref https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository ``` json { "workflow_runs": [ { "id": 3, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "6d8d29a9f7a01ded8f8aeb64341cb31ee1ab5f19", "run_number": 3, "event": "push", "display_title": "More job", "status": "success", "workflow_id": "demo2.yaml", "url": "/chester/test/actions/runs/3", "created_at": "2023-08-22T13:41:33-04:00", "updated_at": "2023-08-22T13:41:37-04:00", "run_started_at": "2023-08-22T13:41:33-04:00" }, { "id": 2, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "6d8d29a9f7a01ded8f8aeb64341cb31ee1ab5f19", "run_number": 2, "event": "push", "display_title": "More job", "status": "success", "workflow_id": "demo.yaml", "url": "/chester/test/actions/runs/2", "created_at": "2023-08-22T13:41:30-04:00", "updated_at": "2023-08-22T13:41:33-04:00", "run_started_at": "2023-08-22T13:41:30-04:00" }, { "id": 1, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "e5369ab054cae79899ba36e45ee82811a6e0acd5", "run_number": 1, "event": "push", "display_title": "Add job", "status": "failure", "workflow_id": "demo.yaml", "url": "/chester/test/actions/runs/1", "created_at": "2023-08-22T13:15:21-04:00", "updated_at": "2023-08-22T13:18:10-04:00", "run_started_at": "2023-08-22T13:15:21-04:00" } ], "total_count": 3 } ``` --------- Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
* Fix tautological conditions (#30735)silverwind2024-04-302-7/+9
| | | | | | | As discovered by https://github.com/go-gitea/gitea/pull/30729. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-2911-32/+31
| | | | | | | | | | Resolve all cases for `unused parameter` and `unnecessary type arguments` Related: #30729 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Bump `github.com/google/go-github` to v61 (#30738)Chongyi Zheng2024-04-282-2/+2
|
* Prevent allow/reject reviews on merged/closed PRs (#30686)Kemal Zebari2024-04-271-0/+8
| | | Resolves #30675.
* Remove unused parameter for some functions in `services/mirror` (#30724)Chongyi Zheng2024-04-272-5/+5
| | | Suggested by gopls `unusedparams`
* Update misspell to 0.5.1 and add `misspellings.csv` (#30573)silverwind2024-04-278-23/+23
| | | | | | Misspell 0.5.0 supports passing a csv file to extend the list of misspellings, so I added some common ones from the codebase. There is at least one typo in a API response so we need to decided whether to revert that and then likely remove the dict entry.
* feat(api): enhance Actions Secrets Management API for repository (#30656)Bo-Yi Wu2024-04-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | - Add endpoint to list repository action secrets in API routes - Implement `ListActionsSecrets` function to retrieve action secrets from the database - Update Swagger documentation to include the new `/repos/{owner}/{repo}/actions/secrets` endpoint - Add `actions` package import and define new routes for actions, secrets, variables, and runners in `api.go`. - Refactor action-related API functions into `Action` struct methods in `org/action.go` and `repo/action.go`. - Remove `actionAPI` struct and related functions, replacing them with `NewAction()` calls. - Rename `variables.go` to `action.go` in `org` directory. - Delete `runners.go` and `secrets.go` in both `org` and `repo` directories, consolidating their content into `action.go`. - Update copyright year and add new imports in `org/action.go`. - Implement `API` interface in `services/actions/interface.go` for action-related methods. - Remove individual action-related functions and replace them with methods on the `Action` struct in `repo/action.go`. --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Improve oauth2 client "preferred username field" logic and the error ↵wxiaoguang2024-04-252-6/+13
| | | | | | | | | | | | | handling (#30622) Follow #30454 And fix #24957 When using "preferred_username", if no such field, `extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an error. All other USERNAME options do not return such error. And fine tune some logic and error messages, make code more stable and more friendly to end users.
* If a repository return no commitstatus, then still cache it but not query it ↵Lunny Xiao2024-04-251-7/+15
| | | | | | | | | | | from database (#30700) The previous repository default branch commit status cache will only store if the commit status has value. So the repository which have no any commit status will always be fetched from database. This PR will store the empty state of commit status of a repository into cache because the cache will be updated once there is a commit status stored.
* Interpolate runs-on with variables when scheduling tasks (#30640)sillyguodong2024-04-231-1/+7
| | | | | | | | | | Follow #29468 1. Interpolate runs-on with variables when scheduling tasks. 2. The `GetVariablesOfRun` function will check if the `Repo` of the run is nil. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Initial support for colorblindness-friendly themes (#30625)wxiaoguang2024-04-243-16/+76
| | | | | | | Initial support for #25680 This PR only adds some simple styles from GitHub, it is big enough and it focuses on adding the necessary framework-level supports. More styles could be fine-tuned later.
* Add a db consistency check to remove runners that do not belong to a ↵Zettat1232024-04-231-0/+6
| | | | | repository (#30614) Follow #30406
* Enable more `revive` linter rules (#30608)silverwind2024-04-2218-41/+27
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Use correct hash for "git update-index" (#30626)wxiaoguang2024-04-221-5/+8
|
* Clarify permission "HasAccess" behavior (#30585)wxiaoguang2024-04-205-7/+6
| | | | | | | | | | | | | | | Follow #30495 "HasAccess" behavior wasn't clear, to make it clear: * Use a new name `HasAnyUnitAccess`, it will be easier to review related code and permission problems. * Separate everyone access mode to a separate field, then all calls to HasAccess are reverted to old behavior before #30495. * Add new tests. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Use action user as the trigger user of schedules (#30581)yp053272024-04-201-2/+7
| | | | | | | | | | | | | | | | | Follow https://github.com/go-gitea/gitea/pull/30357 When user push to default branch, the schedule trigger user will be the user. When disable then enable action units in settings, the schedule trigger user will be action user. When repo is a mirror, the schedule trigger user will be action user. ( before it will return error, fixed by #30357) As scheduled job is a cron, the trigger user should be action user from Gitea, not a real user. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Allow everyone to read or write a wiki by a repo unit setting (#30495)wxiaoguang2024-04-174-8/+10
| | | | | Replace #6312 Help #5833 Wiki solution for #639
* Fix branch_protection api shows users/teams who has no readAccess (#30291)Edward Zhang2024-04-171-21/+35
| | | | | | | | | | | | Add some logic in `convert.ToBranchProtection` to return only the names associated with readAccess instead of returning all names. This will ensure consistency in behavior between the frontend and backend. Fixes: #27694 --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wenzhuo.zhang <wenzhuo.zhang@geely.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor web routes (#30519)wxiaoguang2024-04-172-17/+12
| | | | | | | Re-organize the routes in web.go and use ctx constants instead of `context.UnitTypes()` --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Update API to return 'source_id' for users (#29718)Tobias Balle-Petersen2024-04-161-0/+1
| | | | | | | Using the API, a user's _source_id_ can be set in the _CreateUserOption_ model, but the field is not returned in the _User_ model. This PR updates the _User_ model to include the field _source_id_ (The ID of the Authentication Source).
* Fix code owners will not be mentioned when a pull request comes from a ↵Lunny Xiao2024-04-151-4/+4
| | | | | | forked repository (#30476) Fix #30277 Caused by #29783
* Rewrite and restyle reaction selector and enable no-sizzle eslint rule (#30453)silverwind2024-04-141-0/+1
| | | | | | | | | | | Enable `no-sizzle` lint rule, there was only one use in `initCompReactionSelector` and: - Remove all jQuery except the necessary fomantic dropdown init - Remove the recursion, instead bind event listeners to common parent container nodes --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* fix: Fix to delete cookie when AppSubURL is non-empty (#30375)Jonathan Tran2024-04-141-1/+2
| | | | | | | | Cookies may exist on "/subpath" and "/subpath/" for some legacy reasons (eg: changed CookiePath behavior in code). The legacy cookie should be removed correctly. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Kyle D <kdumontnu@gmail.com>
* Add `interface{}` to `any` replacement to `make fmt`, exclude `*.pb.go` (#30461)silverwind2024-04-131-1/+1
| | | | | | | Since https://github.com/go-gitea/gitea/pull/25686, a few `interface{}` have sneaked into the codebase. Add this replacement to `make fmt` to prevent this from happening again. Ideally a linter would do this, but I haven't found any suitable.
* Avoid losing token when updating mirror settings (#30429)Jason Song2024-04-131-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #30416. Before (it shows as "Unset" while there's a token): <img width="980" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/d7148e3e-62c9-4d2e-942d-3d795b79515a"> After: <img width="977" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/24aaa1db-5baa-4204-9081-470b15ea72b5"> The username shows as "oauth2" because of https://github.com/go-gitea/gitea/blob/f9fdac9809335729b2ac3227b2a5f71a62fc64ad/services/migrations/dump.go#L99 I have checked that all usage of `MirrorRemoteAddress` has been updated. <img width="1806" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/2f042501-2824-4511-9203-c84a6731a02d"> However, it needs to be checked again when backporting. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor cache and disable go-chi cache (#30417)wxiaoguang2024-04-137-48/+34
| | | use built-in cache package to wrap external go-chi cache package
* Fix mirror error when mirror repo is empty (#30432)yp053272024-04-131-17/+23
| | | | | Fix #30424 Co-authored-by: Giteabot <teabot@gitea.io>
* Fix commit status cache which missed target_url (#30426)Lunny Xiao2024-04-121-11/+41
| | | | | | | Fix #30421 --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Change the default maxPerPage for gitbucket (#30392)Kazushi (Jam) Marukawa2024-04-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the migration from gitbucket to gitea. The gitbucket uses it's own internal perPage value (= 25) for paging and ignore per_page arguments in the requested URL. This cause gitea to migrate only 25 issues and 25 PRs from gitbucket repository. This may not happens on old gitbucket. But recent gitbucket 4.40 or 4.38.4 has this problem. This patch change to use this internally hardcoded perPage of gitbucket as gitea's maxPerPage numer when migrating from gitbucket. There are several perPage values in gitbucket like 25 for Isseus/PRs and 10 for Releases. Some of those API doesn't support paging yet. It sounds difficult to implement, but using the minimum number among them worked out very well. So, I use 10 in this patch. Brief descriptions of problems and this patch are also available in https://github.com/go-gitea/gitea/issues/30316. In addition, I'm not sure what kind of test cases are possible to write here. It's a test for migration, so it requires testing gitbucket server and gitea server, I guess. Please let me know if it is possible to write such test cases here. Thanks!
* Add commit status summary table to reduce query from commit status table ↵Lunny Xiao2024-04-122-19/+49
| | | | | | | | | | | | (#30223) This PR adds a new table named commit status summary to reduce queries from the commit status table. After this change, commit status summary table will be used for the final result, commit status table will be for details. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Check the token's owner and repository when registering a runner (#30406)Zettat1232024-04-112-0/+2
| | | Fix #30378
* Avoid user does not exist error when detecting schedule actions when the ↵yp053272024-04-111-6/+3
| | | | | | | | | | | | | | | | commit author is an external user (#30357) ![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76) When repo is a mirror, and commit author is an external user, then `GetUserByEmail` will return error. reproduce/test: - mirror Gitea to your instance - disable action and enable it again, this will trigger `DetectAndHandleSchedules` ps: also follow #24706, it only fixed normal runs, not scheduled runs.
* Performance optimization for git push (#30104)Lunny Xiao2024-04-091-9/+17
| | | | | Agit returned result should be from `ProcReceive` hook but not `PostReceive` hook. Then for all non-agit pull requests, it will not check the pull requests for every pushing `refs/pull/%d/head`.
* Fix missed doer (#30231)Lunny Xiao2024-04-085-34/+34
| | | | | Fix #29879 Co-authored-by: Giteabot <teabot@gitea.io>
* Add optional doctor storage init (#30330)Michael Kriese2024-04-081-0/+11
| | | Add optional storage init to doctor