summaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Fix bugs in rerunning jobs (#29955) (#29983)Giteabot2024-03-222-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #29955 by @Zettat123 Fix #28761 Fix #27884 Fix #28093 ## Changes ### Rerun all jobs When rerun all jobs, status of the jobs with `needs` will be set to `blocked` instead of `waiting`. Therefore, these jobs will not run until the required jobs are completed. ### Rerun a single job When a single job is rerun, its dependents should also be rerun, just like GitHub does (https://github.com/go-gitea/gitea/issues/28761#issuecomment-2008620820). In this case, only the specified job will be set to `waiting`, its dependents will be set to `blocked` to wait the job. ### Show warning if every job has `needs` If every job in a workflow has `needs`, all jobs will be blocked and no job can be run. So I add a warning message. <img src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b" width="480px" /> --------- Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Performance improvements for pull request list page (#29900) (#29972)Lunny Xiao2024-03-222-4/+5
| | | | | | | | | This PR will avoid load pullrequest.Issue twice in pull request list page. It will reduce x times database queries for those WIP pull requests. Partially fix #29585 Backport #29900
* Fix the bug that user may logout if GetUserByID return unknow error (#29964)Lunny Xiao2024-03-211-17/+9
| | | | | | | | | | | | backport #29962 This PR fixed a bug when the user switching pages too fast, he will logout automatically. The reason is that when the error is context cancelled, the previous code think user hasn't login then the session will be deleted. Now it will return the errors but not think it's not login. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix loadOneBranch panic (#29938) (#29939)wxiaoguang2024-03-201-4/+6
| | | | | | | Backport #29938 Try to fix #29936 Far from ideal, but still better than panic.
* Add cache for dashbaord commit status (#29932)Lunny Xiao2024-03-202-44/+138
| | | backport #29444
* Notify reviewers added via CODEOWNERS (#29842) (#29902)Lunny Xiao2024-03-204-22/+77
| | | | | backport #29842 Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be>
* Fix invalid link of the commit status when ref is tag (#29752) (#29908)yp053272024-03-201-3/+13
| | | | | | | Backport #29752 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix codeowner detected diff base branch to mergebase (#29783) (#29807)Lunny Xiao2024-03-178-8/+129
| | | | | | | | | | | | | | | Fix #29763 Backport #29783 This PR fixes 2 problems with CodeOwner in the pull request. - Don't use the pull request base branch but merge-base as a diff base to detect the code owner. - CodeOwner detection in fork repositories will be disabled because almost all the fork repositories will not change CODEOWNERS files but it should not be used on fork repositories' pull requests. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make runs-on support variable expression (#29468) (#29782)sillyguodong2024-03-141-1/+12
| | | | | | | | | backport #29468 Close issue: https://gitea.com/gitea/act_runner/issues/445 Follow: https://gitea.com/gitea/act/pulls/91 Move `getSecretsOfTask` and `getVariablesOfTask` under models because of circular dependency issues.
* Fix possible NPE in ToPullReviewList (#29759) (#29775)Giteabot2024-03-132-1/+53
| | | | | | Backport #29759 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix commit_status problem when testing (#29672) (#29675)Giteabot2024-03-081-1/+1
| | | | | | | | | Backport #29672 by @charles7668 Close #29661 fix #29656 Co-authored-by: charles <30816317+charles7668@users.noreply.github.com>
* Add empty repo check in DetectAndHandleSchedules (#29606) (#29659)yp053272024-03-081-0/+4
| | | Backport #29606
* Fixing the issue when status check per rule matches multiple actions ↵Giteabot2024-03-082-7/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#29631) (#29655) Backport #29631 by @charles7668 Close #29628 rule ``` Test / Build* Test / Build * Test / Build 2* Test / Build 1* ``` ![image](https://github.com/go-gitea/gitea/assets/30816317/19bef0a9-fa97-43c5-887b-dece76064aa8) rule2 ``` Test / Build* Test / Build 1* ``` ![image](https://github.com/go-gitea/gitea/assets/30816317/19bef0a9-fa97-43c5-887b-dece76064aa8) rule3 ``` Test / Build* Test / Build 1* NotExist* ``` ![image](https://github.com/go-gitea/gitea/assets/30816317/f6a5e832-2e1b-4049-915b-45bec5ef070c) Co-authored-by: charles <30816317+charles7668@users.noreply.github.com> Co-authored-by: Zettat123 <zettat123@gmail.com>
* Use strict protocol check when redirect (#29642) (#29644)Giteabot2024-03-071-0/+39
| | | | | Backport #29642 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add missing database transaction for new issue (#29490) (#29607)Lunny Xiao2024-03-051-7/+16
| | | | | | When creating an issue, inserting issue, assign users and set project should be in the same transaction. Backport #29490
* Fix workflow trigger event IssueChangeXXX bug (#29559) (#29565)Giteabot2024-03-041-2/+14
| | | | | | | | | | Backport #29559 by @yp05327 Bugs from #29308 Follow #29467 partly fix #29558 Co-authored-by: yp05327 <576951401@qq.com>
* Fix incorrect relative/absolute URL usages (#29531) (#29547)Giteabot2024-03-021-1/+1
| | | | | | | | Backport #29531 by wxiaoguang Add two "HTMLURL" methods for PackageDescriptor. And rename "FullWebLink" to "VersionWebLink" Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix workflow trigger event bugs (#29467) (#29475)Giteabot2024-02-281-1/+7
| | | | | | | | | | Backport #29467 by @Zettat123 1. Fix incorrect `HookEventType` for issue-related events in `IssueChangeAssignee` 2. Add `case "types"` in the `switch` block in `matchPullRequestEvent` to avoid warning logs Co-authored-by: Zettat123 <zettat123@gmail.com>
* The job should always run when `if` is `always()` (#29464) (#29469)Giteabot2024-02-282-1/+76
| | | | | | | | | | | | | | | Backport #29464 by @Zettat123 Fix #27906 According to GitHub's [documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds), a job should always run when its `if` is `always()` > If you would like a job to run even if a job it is dependent on did not succeed, use the `always()` conditional expression in `jobs.<job_id>.if`. Co-authored-by: Zettat123 <zettat123@gmail.com>
* Ignore empty repo for CreateRepository in action notifier (#29416) (#29424)Giteabot2024-02-261-0/+3
| | | | | | | Backport #29416 by @yp05327 Fix #29415 Co-authored-by: yp05327 <576951401@qq.com>
* Fix tarball/zipball download bug (#29342) (#29352)Giteabot2024-02-232-1/+6
| | | | | | | | | | | Backport #29342 by @Zettat123 Fix #29249 ~~Use the `/repos/{owner}/{repo}/archive/{archive}` API to download.~~ Apply #26430 to archive download URLs. Co-authored-by: Zettat123 <zettat123@gmail.com>
* Use general token signing secret (#29205) (#29325)wxiaoguang2024-02-222-9/+3
| | | | | Backport #29205 (including #29172) Use a clearly defined "signing secret" for token signing.
* Fix SSPI user creation (#28948) (#29323)Lunny Xiao2024-02-221-7/+3
| | | | | | | | | Fixes #28945 Backport #28948 Setting the avatar is wrong and creating a random password is equal to leave it empty. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Improve the `issue_comment` workflow trigger event (#29277) (#29322)Giteabot2024-02-222-27/+80
| | | | | | | | | | | | | | | | | | | | | Backport #29277 by @Zettat123 Fix #29175 Replace #29207 This PR makes some improvements to the `issue_comment` workflow trigger event. 1. Fix the bug that pull requests cannot trigger `issue_comment` workflows 2. Previously the `issue_comment` event only supported the `created` activity type. This PR adds support for the missing `edited` and `deleted` activity types. 3. Some events (including `issue_comment`, `issues`, etc. ) only trigger workflows that belong to the workflow file on the default branch. This PR introduces the `IsDefaultBranchWorkflow` function to check for these events. Co-authored-by: Zettat123 <zettat123@gmail.com>
* Implement some action notifier functions (#29173) (#29308)yp053272024-02-221-9/+67
| | | | | | | | | | | | | Backport #29173 Fix #29166 Add support for the following activity types of `pull_request` - assigned - unassigned - review_requested - review_request_removed - milestoned - demilestoned
* Fix missing link on outgoing new release notifications (#29079) (#29300)wxiaoguang2024-02-211-0/+1
| | | | | | | Backport #29079 Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz> Co-authored-by: Wiktor Kwapisiewicz <wiktor@metacode.biz> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix debian InRelease Acquire-By-Hash newline (#29204) (#29299)wxiaoguang2024-02-211-1/+1
| | | | | Backport #29204 Co-authored-by: Robin Schoonover <robin@cornhooves.org>
* Fix missed edit issues event for actions (#29237) (#29251)Lunny Xiao2024-02-201-0/+41
| | | | Fix #29213 Backport #29237
* Disallow merge when required checked are missing (#29143) (#29268)Markus Amshove2024-02-191-0/+4
| | | | | | backport #29143 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix bug when the linked account was disactived and list the linked accounts ↵Lunny Xiao2024-02-192-5/+4
| | | | | | | | | (#29263) The bug has been fixed on v1.22 but not backport to v1.21. This original PR have many refactors so I don't think it's necessary to backport all of them. Fix #28667
* Do not use lower tag names to find releases/tags (#29261) (#29262)Jason Song2024-02-191-6/+6
| | | | | | | | | | | | | | | | Backport #29261. Fix #26090, see https://github.com/go-gitea/gitea/issues/26090#issuecomment-1952013206 Since `TagName` stores the original tag name and `LowerTagName` stores the lower tag name, it doesn't make sense to use lowercase tags as `TagNames` in `FindReleasesOptions`. https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/services/repository/push.go#L396-L397 While the only other usage looks correct: https://github.com/go-gitea/gitea/blob/5e72526da4e915791f03af056890e16821bde052/routers/web/repo/repo.go#L416
* Only delete scheduled workflows when needed (#29091) (#29235)Zettat1232024-02-181-3/+6
| | | | | | | | Backport #29091 Fix #29040 `handleSchedules` should be called only if `DetectWorkflows` should detect schedule workflows
* Refactor issue template parsing and fix API endpoint (#29069) (#29140)wxiaoguang2024-02-141-14/+16
| | | | | | | | | | | | | | | | | | Backport #29069 The old code `GetTemplatesFromDefaultBranch(...) ([]*api.IssueTemplate, map[string]error)` doesn't really follow Golang's habits, then the second returned value might be misused. For example, the API function `GetIssueTemplates` incorrectly checked the second returned value and always responds 500 error. This PR refactors GetTemplatesFromDefaultBranch to ParseTemplatesFromDefaultBranch and clarifies its behavior, and fixes the API endpoint bug, and adds some tests. And by the way, add proper prefix `X-` for the header generated in `checkDeprecatedAuthMethods`, because non-standard HTTP headers should have `X-` prefix, and it is also consistent with the new code in `GetIssueTemplates`
* Avoid sending update/delete release notice when it is draft (#29008) (#29025)Giteabot2024-02-021-8/+7
| | | | | | | Backport #29008 by @yp05327 Fix #27157 Co-authored-by: yp05327 <576951401@qq.com>
* Fix an actions schedule bug (#28942) (#28999)Giteabot2024-01-315-17/+67
| | | | | | | | | | | | | | | Backport #28942 by @Zettat123 In #28691, schedule plans will be deleted when a repo's actions unit is disabled. But when the unit is enabled, the schedule plans won't be created again. This PR fixes the bug. The schedule plans will be created again when the actions unit is re-enabled --------- Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Implement `MigrateRepository` for the actions notifier (#28920) (#28923)Giteabot2024-01-251-0/+12
| | | | | | | | | | | Backport #28920 by @Zettat123 Fixes #28699 This PR implements the `MigrateRepository` method for `actionsNotifier` to detect the schedules from the workflow files in the migrated repository. Co-authored-by: Zettat123 <zettat123@gmail.com>
* Only migrate the first 255 chars of a Github issue title (#28902) (#28912)Giteabot2024-01-241-1/+2
| | | | | | | Backport #28902 by @JakobDev Fixes #28846 Co-authored-by: JakobDev <jakobdev@gmx.de>
* Fix `DeleteCollaboration` transaction behaviour (#28886) (#28889)Giteabot2024-01-221-2/+5
| | | | | | | | | | | | | Backport #28886 by @KN4CK3R The method can't be called with an outer transaction because if the user is not a collaborator the outer transaction will be rolled back even if the inner transaction uses the no-error path. `has == 0` leads to `return nil` which cancels the transaction. A standalone call of this method does nothing but if used with an outer transaction, that will be canceled. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix schedule not trigger bug because matching full ref name with short ref ↵Giteabot2024-01-221-12/+16
| | | | | | | | | | | name (#28874) (#28888) Backport #28874 by @lunny Fix #28533 Caused by #28691 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix reverting a merge commit failing (#28794) (#28825)Mihir Joshi2024-01-217-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport https://github.com/go-gitea/gitea/pull/28794 Fixes #22236 --- Error occurring currently while trying to revert commit using read-tree -m approach: > 2022/12/26 16:04:43 ...rvices/pull/patch.go:240:AttemptThreeWayMerge() [E] [63a9c61a] Unable to run read-tree -m! Error: exit status 128 - fatal: this operation must be run in a work tree > - fatal: this operation must be run in a work tree We need to clone a non-bare repository for `git read-tree -m` to work. https://github.com/go-gitea/gitea/commit/bb371aee6ecf5e570cdf7b5f7f0d6f47a607a325 adds support to create a non-bare cloned temporary upload repository. After cloning a non-bare temporary upload repository, we [set default index](https://github.com/go-gitea/gitea/blob/main/services/repository/files/cherry_pick.go#L37) (`git read-tree HEAD`). This operation ends up resetting the git index file (see investigation details below), due to which, we need to call `git update-index --refresh` afterward. Here's the diff of the index file before and after we execute SetDefaultIndex: https://www.diffchecker.com/hyOP3eJy/ Notice the **ctime**, **mtime** are set to 0 after SetDefaultIndex. You can reproduce the same behavior using these steps: ```bash $ git clone https://try.gitea.io/me-heer/test.git -s -b main $ cd test $ git read-tree HEAD $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 error: Entry '1' not uptodate. Cannot merge. ``` After which, we can fix like this: ```bash $ git update-index --refresh $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 ```
* Rework markup link rendering (#26745) (#28803)KN4CK3R2024-01-162-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #26745 Fixes #26548 This PR refactors the rendering of markup links. The old code uses `strings.Replace` to change some urls while the new code uses more context to decide which link should be generated. The added tests should ensure the same output for the old and new behaviour (besides the bug). We may need to refactor the rendering a bit more to make it clear how the different helper methods render the input string. There are lots of options (resolve links / images / mentions / git hashes / emojis / ...) but you don't really know what helper uses which options. For example, we currently support images in the user description which should not be allowed I think: <details> <summary>Profile</summary> https://try.gitea.io/KN4CK3R ![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5) </details>
* Forbid removing the last admin user (#28337) (#28793)Giteabot2024-01-161-1/+6
| | | | | | Backport #28337 by @yp05327 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix schedule tasks bugs (#28691) (#28780)Lunny Xiao2024-01-145-22/+131
| | | | | | | | | | | | | | Fix #28157 Backport #28691 This PR fix the possible bugs about actions schedule. - Move `UpdateRepositoryUnit` and `SetRepoDefaultBranch` from models to service layer - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when actions unit has been disabled or global disabled. - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when default branch changed.
* Fix `convert.ToTeams` on empty input (#28426) (#28767)Giteabot2024-01-122-26/+26
| | | | | | | | | Backport #28426 by @KN4CK3R Fixes #28420 Don't return `nil` if the input was empty. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Concatenate error in `checkIfPRContentChanged` (#28731) (#28737)Giteabot2024-01-091-0/+4
| | | | | | | | | | | | Backport #28731 by @earl-warren - If there's a error with the Git command in `checkIfPRContentChanged` the stderr wasn't concatendated to the error, which results in still not knowing why an error happend. - Adds concatenation for stderr to the returned error. - Ref: https://codeberg.org/forgejo/forgejo/issues/2077 Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix alpine package files are not rebuilt (#28638) (#28665)Giteabot2023-12-311-0/+5
| | | | | | | | | Backport #28638 by @lng2020 I noticed the `BuildAllRepositoryFiles` function under the Alpine folder is unused and I thought it was a bug. But I'm not sure about this. Was it on purpose? Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* fix empty ref for cron workflow runs (#28640) (#28647)Giteabot2023-12-291-2/+3
| | | | | | | | | | Backport #28640 by @denyskon Fix #27678 Please see https://github.com/go-gitea/gitea/issues/27678#issuecomment-1871445853 for details. Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
* Remove unnecessary syncbranchToDB with tests (#28624) (#28629)Lunny Xiao2023-12-291-20/+9
| | | | | | | | | | Replace #28625 Backport #28624 by lunny #28361 introduced `syncBranchToDB` in `CreateNewBranchFromCommit`. This PR will revert the change because it's unnecessary. Every push will already be checked by `syncBranchToDB`. This PR also created a test to ensure it's right.
* Use known issue IID to generate new PR index number when migrating from ↵Giteabot2023-12-272-11/+45
| | | | | | | | | GitLab (#28616) (#28618) Backport #28616 by wxiaoguang Fix #13884 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add option to disable ambiguous unicode characters detection (#28454) (#28499)wxiaoguang2023-12-182-6/+6
| | | | | | | | Backport #28454 (the only conflict is caused by some comments) * Close #24483 * Close #28123 * Close #23682 * Close #23149