aboutsummaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Allow package cleanup from admin page (#25307)KN4CK3R2023-08-082-5/+23
| | | | | | | | | | | | | | | Until now expired package data gets deleted daily by a cronjob. The admin page shows the size of all packages and the size of unreferenced data. The users (#25035, #20631) expect the deletion of this data if they run the cronjob from the admin page but the job only deletes data older than 24h. This PR adds a new button which deletes all expired data. ![grafik](https://github.com/go-gitea/gitea/assets/1666336/b3e35d73-9496-4fa7-a20c-e5d30b1f6850) --------- Co-authored-by: silverwind <me@silverwind.io>
* Bypass MariaDB performance bug of the "IN" sub-query, fix incorrect ↵wxiaoguang2023-08-071-1/+1
| | | | | | IssueIndex (#26279) Close #26277 Fix #26285
* Display human-readable text instead of cryptic filemodes (#26352)delvh2023-08-061-0/+17
| | | | | | | | | | | | | | | | Now, you don't need to be a git expert anymore to know what these numbers mean. ## Before ![grafik](https://github.com/go-gitea/gitea/assets/51889757/9a964bf6-10fd-40a6-aeb2-ac8f437f8c32) ## After ![grafik](https://github.com/go-gitea/gitea/assets/51889757/84573cb9-55b6-4dde-9866-95f71b657554) or when the mode actually changed: ![grafik](https://github.com/go-gitea/gitea/assets/51889757/0f327538-ebdc-40e7-8c99-f9e21b67f638)
* Prevent newline errors with Debian packages (#26332)KN4CK3R2023-08-051-1/+1
| | | Fixes #26313
* Fix the bug when getting files changed for `pull_request_target` event (#26320)Zettat1232023-08-051-2/+2
| | | | | | | | | | | Follow #25229 Copy from https://github.com/go-gitea/gitea/pull/26290#issuecomment-1663135186 The bug is that we cannot get changed files for the `pull_request_target` event. This event runs in the context of the base branch, so we won't get any changes if we call `GetFilesChangedSinceCommit` with `PullRequest.Base.Ref`.
* Delete `issue_service.CreateComment` (#26298)caicandong2023-08-044-30/+8
| | | | | | | I noticed that `issue_service.CreateComment` adds transaction operations on `issues_model.CreateComment`, we can merge the two functions and we can avoid calling each other's methods in the `services` layer. Co-authored-by: Giteabot <teabot@gitea.io>
* Add `Retry` button when creating a mirror-repo fails (#26228)Kerwin Bryant2023-08-041-0/+24
| | | | | | | | | | | | | | | fixed #26156 * Added a retry button in the frontend (only displayed when the status is abnormal) * After clicking Retry, the backend adds the task back to the task queue ![7UJDNM671RI})EA8~~XPL39](https://github.com/go-gitea/gitea/assets/3371163/e088fd63-5dcc-4bc6-8849-7db3086511b7) ![T83F1WL9)VGHR@MB956$VT9](https://github.com/go-gitea/gitea/assets/3371163/744425bb-dde1-4315-be2e-5c99ac3a44d4) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* add unit test for user renaming (#26261)Earl Warren2023-08-031-0/+64
| | | | | | | | | | | | | - The user renaming function has zero test coverage. - This patch brings that up to speed to test for various scenarios and ensure that in a normal workflow the correct things has changed to their respective new value. Most scenarios are to ensure certain things DO NOT happen. (cherry picked from commit 5b9d34ed115c9ef24012b8027959ea0afdcb4e2d) Refs: https://codeberg.org/forgejo/forgejo/pulls/1156 Co-authored-by: Gusted <postmaster@gusted.xyz>
* add some Wiki unit tests (#26260)Earl Warren2023-08-031-0/+12
| | | | | | | | | | - Just to get 100% coverage on services/wiki/wiki_path.go, nothing special. This is just an formality. (cherry picked from commit 6b3528920fbf18c41d6aeb95498af48443282370) Refs: https://codeberg.org/forgejo/forgejo/pulls/1156 Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix pull request check list is limited (#26179)caicandong2023-07-313-3/+3
| | | | | | | | | | | | In the original implementation, we can only get the first 30 records of the commit status (the default paging size), if the commit status is more than 30, it will lead to the bug #25990. I made the following two changes. - On the page, use the ` db.ListOptions{ListAll: true}` parameter instead of `db.ListOptions{}` - The `GetLatestCommitStatus` function makes a determination as to whether or not a pager is being used. fixed #25990
* Fix API leaking Usermail if not logged in (#25097)JakobDev2023-07-311-1/+1
| | | | | | | | | The API should only return the real Mail of a User, if the caller is logged in. The check do to this don't work. This PR fixes this. This not really a security issue, but can lead to Spam. --------- Co-authored-by: silverwind <me@silverwind.io>
* Add commits dropdown in PR files view and allow commit by commit review (#25528)sebastian-sauer2023-07-281-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds a new dropdown to select a commit or a commit range (shift-click like github) of a Pull Request. After selection of a commit only the changes of this commit will be shown. When selecting a range of commits the diff of this range is shown. This allows to review a PR commit by commit or by viewing only commit ranges. The "Show changes since your last review" mechanism github uses is implemented, too. When reviewing a single commit or a commit range the "Viewed" functionality is disabled. ## Screenshots ### The commit dropdown ![image](https://github.com/go-gitea/gitea/assets/51889757/0db3ae62-1272-436c-be64-4730c5d611e3) ### Selecting a commit range ![image](https://github.com/go-gitea/gitea/assets/51889757/ad81eedb-8437-42b0-8073-2d940c25fe8f) ### Show changes of a single commit only ![image](https://github.com/go-gitea/gitea/assets/51889757/6b1a113b-73ef-4ecc-adf6-bc2340bb8f97) ### Show changes of a commit range ![image](https://github.com/go-gitea/gitea/assets/51889757/6401b358-cd66-4c09-8baa-6cf6177f23a7) Fixes https://github.com/go-gitea/gitea/issues/20989 Fixes https://github.com/go-gitea/gitea/issues/19263 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Warn instead of reporting an error when a webhook cannot be found (#26039)puni98692023-07-281-1/+6
| | | | | | | | | Attemp fix: #25744 Fixing the log level when we delete any repo then we get error hook not found by id. That should be warn level to reduce the noise in the logs. --------- Co-authored-by: delvh <dev.lh@web.de>
* Show branches and tags that contain a commit (#25180)delvh2023-07-271-0/+55
| | | | | | | | | | | | | | | | | | | | | | | Now, you can see for a commit which existing branches and tags contain it. You first have to click on the `load branches and tags` button, they are not preloaded by default. All branches and tags are ordered descending by creation date. You can even see without much hassle if the given commit is already part of the default branch. Closes #25152 ## Screenshots ### Initial ![image](https://github.com/go-gitea/gitea/assets/51889757/84db2c0b-aaef-4f69-ab92-0b812793d2ad) ### Loaded ![image](https://github.com/go-gitea/gitea/assets/51889757/a9b84e66-8e44-4c55-b017-c37f4a45f41b) --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* refactor improve NoBetterThan (#26126)caicandong2023-07-261-1/+1
| | | | | | | | | | | | | - The `NoBetterThan` function can only handle comparisons between "pending," "success," "error," and "failure." For any other comparison, we directly return false. This prevents logic errors like the one in #26121. - The callers of the `NoBetterThan` function should also avoid making incomparable calls. --------- Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
* Fix bugs in LFS meta garbage collection (#26122)Zettat1232023-07-262-2/+67
| | | | | | | | This PR - Fix #26093. Replace `time.Time` with `timeutil.TimeStamp` - Fix #26135. Add missing `xorm:"extends"` to `CountLFSMetaObject` for LFS meta object query - Add a unit test for LFS meta object garbage collection
* Allow Organisations to have a E-Mail (#25082)JakobDev2023-07-252-0/+2
| | | | | | | | | | | | | | | | | | | | Resolves #25057 This adds a E-Mail field to Organisations. The E-Mail is just shown on the Profile when it is visited by a logged in User. The E-mail is not used for something else. **Screenshots:** ![grafik](https://github.com/go-gitea/gitea/assets/15185051/a8d622b3-7278-4c08-984b-9c5ebfdb5471) ![grafik](https://github.com/go-gitea/gitea/assets/15185051/6dcb1dd7-d04b-49eb-bc96-6582cfe9757b) --------- Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: Denys Konovalov <privat@denyskon.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Implement auto-cancellation of concurrent jobs if the event is push (#25716)Bo-Yi Wu2023-07-251-4/+19
| | | | | | | | | | | | | | | | | | - cancel running jobs if the event is push - Add a new function `CancelRunningJobs` to cancel all running jobs of a run - Update `FindRunOptions` struct to include `Ref` field and update its condition in `toConds` function - Implement auto cancellation of running jobs in the same workflow in `notify` function related task: https://github.com/go-gitea/gitea/pull/22751/ --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: delvh <dev.lh@web.de>
* Replace gogs/cron with go-co-op/gocron (#25977)Chongyi Zheng2023-07-243-14/+103
| | | | | | | | Replace `github.com/gogs/cron` with `github.com/go-co-op/gocron` as the former package is not maintained for many years. --------- Co-authored-by: delvh <dev.lh@web.de>
* Add context parameter to some database functions (#26055)Lunny Xiao2023-07-2213-78/+70
| | | | | To avoid deadlock problem, almost database related functions should be have ctx as the first parameter. This PR do a refactor for some of these functions.
* Fix version in rpm repodata/primary.xml.gz (#26009)Peter Verraedt2023-07-211-3/+3
| | | | | | | | The version listed in rpm repodata should only contain the rpm version (1.0.0) and not the combination of version and release (1.0.0-2). We correct this behaviour in primary.xml.gz, filelists.xml.gz and others.xml.gz. Signed-off-by: Peter Verraedt <peter@verraedt.be>
* Remove commit status running and warning to align GitHub (#25839)caicandong2023-07-212-6/+10
| | | | | | | | | | | | | | | | | | | | | | Fix #25776. Close #25826. In the discussion of #25776, @wolfogre's suggestion was to remove the commit status of `running` and `warning` to keep it consistent with github. references: - https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#about-commit-statuses ## :warning: BREAKING :warning: So the commit status of Gitea will be consistent with GitHub, only `pending`, `success`, `error` and `failure`, while `warning` and `running` are not supported anymore. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Support copy protected branch from template repository (#25889)Lunny Xiao2023-07-212-8/+38
| | | Fix #14303
* Add file status for API "Get a single commit from a repository" (#16205) ↵jeremiepozzigithub2023-07-201-1/+2
| | | | | | | | | | (#25831) #16205 To obtain a closer behavior to the api from github, the status (added, modified, removed) of a file should be available in addition to the filename. See github doc : https://docs.github.com/fr/rest/commits/commits?apiVersion=2022-11-28#get-a-commit
* Fix bug when pushing to a pull request which enabled dismiss approval ↵Lunny Xiao2023-07-203-8/+62
| | | | | | | | | | | | | | | automatically (#25882) Fix #25858 The option `dissmiss stale approvals` was listed on protected branch but never implemented. This PR fixes that. <img width="1006" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/60bfa968-4db7-4c24-b8be-2e5978f91bb9"> <img width="1021" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/8dabc14d-2dfe-40c2-94ed-24fcbf6e0e8f">
* Bump github.com/golang-jwt/jwt to v5 (#25975)harryzcy2023-07-194-4/+7
| | | | | | | | | | | | | | | | Bumping `github.com/golang-jwt/jwt` from v4 to v5. `github.com/golang-jwt/jwt` v5 is bringing some breaking changes: - standard `Valid()` method on claims is removed. It's replaced by `ClaimsValidator` interface implementing `Validator()` method instead, which is called after standard validation. Gitea doesn't seem to be using this logic. - `jwt.Token` has a field `Valid`, so it's checked in `ParseToken` function in `services/auth/source/oauth2/token.go` --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor "Content" for file uploading (#25851)wxiaoguang2023-07-181-11/+12
| | | | | | | | | | | | | | | Before: the concept "Content string" is used everywhere. It has some problems: 1. Sometimes it means "base64 encoded content", sometimes it means "raw binary content" 2. It doesn't work with large files, eg: uploading a 1G LFS file would make Gitea process OOM This PR does the refactoring: use "ContentReader" / "ContentBase64" instead of "Content" This PR is not breaking because the key in API JSON is still "content": `` ContentBase64 string `json:"content"` ``
* Fix SSPI auth panic (#25955)wxiaoguang2023-07-181-2/+2
| | | | | Try to fix #25952 Co-authored-by: Giteabot <teabot@gitea.io>
* fix incorrect repo url when changed the case of ownername (#25733)hiifong2023-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When only the case of the username changes and the new username is consistent with the lowercase username of the old user name, update the owner name of the repo, and keep the original logic consistent with other conditions. example: your username is `gitea`, lowercase username is `gitea`,repo url is `.../gitea/{repo}`, you changed username to `Gitea` or `GiTea` or other, but the lowercase username is still `gitea`, the repo url is still `.../gitea/{repo}`. this pr fixed it,keep username and repo url consistent. Before: ![image](https://github.com/go-gitea/gitea/assets/89133723/84177296-f0ff-4176-84f1-1f9ec3f5b86f) ![image](https://github.com/go-gitea/gitea/assets/89133723/8f8f4a12-ecdd-4dec-af89-85c009b0ccfe) After: ![image](https://github.com/go-gitea/gitea/assets/89133723/0564edb6-9467-405a-8cd4-d6f70e6f614b) ![image](https://github.com/go-gitea/gitea/assets/89133723/554ecd6e-e5a1-43bc-a46d-99e988c2ff58)
* Do not "guess" the file encoding/BOM when using API to upload files (#25828)wxiaoguang2023-07-121-102/+3
| | | | | | | | Related issue: #18368 It doesn't seem right to "guess" the file encoding/BOM when using API to upload files. The API should save the uploaded content as-is.
* Fix the error message when the token is incorrect (#25701)caicandong2023-07-112-24/+41
| | | | | | | | | | | | | | | we refactored `userIDFromToken` for the token parsing part into a new function `parseToken`. `parseToken` returns the string `token` from request, and a boolean `ok` representing whether the token exists or not. So we can distinguish between token non-existence and token inconsistency in the `verfity` function, thus solving the problem of no proper error message when the token is inconsistent. close #24439 related #22119 --------- Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Giteabot <teabot@gitea.io>
* For API attachments, use API URL (#25639)Lunny Xiao2023-07-108-22/+69
| | | | | | | Fix #25257 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Avoid amending the Rebase and Fast-forward merge if there is no message ↵wxiaoguang2023-07-101-0/+5
| | | | | | | | | | | | template (#25779) Related #22669. Close #25177 After the fix: ![image](https://github.com/go-gitea/gitea/assets/2114189/0e900927-ea72-4f8f-bde6-5ed927cb02f4) Co-authored-by: Giteabot <teabot@gitea.io>
* Update tool dependencies, lock govulncheck and actionlint (#25655)silverwind2023-07-091-8/+7
| | | | | | | | | | - Update all tool dependencies - Lock `govulncheck` and `actionlint` to their latest tags --------- Co-authored-by: 6543 <m.huber@kithara.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix `ref` for workflows triggered by `pull_request_target` (#25743)Zettat1232023-07-071-4/+2
| | | | | | | | | | Follow #25229 At present, when the trigger event is `pull_request_target`, the `ref` and `sha` of `ActionRun` are set according to the base branch of the pull request. This makes it impossible for us to find the head branch of the `ActionRun` directly. In this PR, the `ref` and `sha` will always be set to the head branch and they will be changed to the base branch when generating the task context.
* Less naked returns (#25713)65432023-07-077-49/+43
| | | | | just a step towards #25655 and some related refactoring
* Simplify the LFS GC logger usage (#25717)wxiaoguang2023-07-061-21/+17
| | | | | | | | | Remove unnecessary `if opts.Logger != nil` checks. * For "CLI doctor" mode, output to the console's "logger.Info". * For "Web Task" mode, output to the default "logger.Debug", to avoid flooding the server's log in a busy production instance. Co-authored-by: Giteabot <teabot@gitea.io>
* Sync branches when mirroring (#25722)Lunny Xiao2023-07-061-0/+5
| | | | | | | Caused by #22743 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Replace `interface{}` with `any` (#25686)silverwind2023-07-0421-56/+56
| | | | | Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`. Basically the same [as golang did](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
* Log the real reason when authentication fails (but don't show the user) (#25414)Lunny Xiao2023-07-031-2/+37
|
* Add direct serving of package content (#25543)KN4CK3R2023-07-031-40/+34
| | | | | | | Fixes #24723 Direct serving of content aka HTTP redirect is not mentioned in any of the package registry specs but lots of official registries do that so it should be supported by the usual clients.
* Support displaying diff stats in PR tab bar (#25387)hiifong2023-07-031-0/+36
| | | | | | | Fix #25326 --------- Co-authored-by: silverwind <me@silverwind.io>
* Fix branch commit message too long problem (#25588)Lunny Xiao2023-06-301-1/+1
| | | | | | When branch's commit CommitMessage is too long, the column maybe too short.(TEXT 16K for mysql). This PR will fix it to only store the summary because these message will only show on branch list or possible future search?
* Sync branches into databases (#22743)Lunny Xiao2023-06-2912-34/+269
| | | | | | | | | | | | | | | | | | | | | | | | | | Related #14180 Related #25233 Related #22639 Close #19786 Related #12763 This PR will change all the branches retrieve method from reading git data to read database to reduce git read operations. - [x] Sync git branches information into database when push git data - [x] Create a new table `Branch`, merge some columns of `DeletedBranch` into `Branch` table and drop the table `DeletedBranch`. - [x] Read `Branch` table when visit `code` -> `branch` page - [x] Read `Branch` table when list branch names in `code` page dropdown - [x] Read `Branch` table when list git ref compare page - [x] Provide a button in admin page to manually sync all branches. - [x] Sync branches if repository is not empty but database branches are empty when visiting pages with branches list - [x] Use `commit_time desc` as the default FindBranch order by to keep consistent as before and deleted branches will be always at the end. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Fix content holes in Actions task logs file (#25560)Jason Song2023-06-281-4/+12
| | | | | | | | | | | | | | | | | | | Fix #25451. Bugfixes: - When stopping the zombie or endless tasks, set `LogInStorage` to true after transferring the file to storage. It was missing, it could write to a nonexistent file in DBFS because `LogInStorage` was false. - Always update `ActionTask.Updated` when there's a new state reported by the runner, even if there's no change. This is to avoid the task being judged as a zombie task. Enhancement: - Support `Stat()` for DBFS file. - `WriteLogs` refuses to write if it could result in content holes. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add Adopt repository event and handler (#25497)Lunny Xiao2023-06-261-11/+13
| | | | | | | Fix #14304 --------- Co-authored-by: delvh <dev.lh@web.de>
* Support `pull_request_target` event (#25229)Zettat1232023-06-261-8/+44
| | | | | | | | | | | Fix #25088 This PR adds the support for [`pull_request_target`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) workflow trigger. `pull_request_target` is similar to `pull_request`, but the workflow triggered by the `pull_request_target` event runs in the context of the base branch of the pull request rather than the head branch. Since the workflow from the base is considered trusted, it can access the secrets and doesn't need approvals to run.
* Store and use seconds for timeline time comments (#25392)65432023-06-231-0/+12
| | | | | | | | | | | this will allow us to fully localize it later PS: we can not migrate back as the old value was a one-way conversion prepare for #25213 --- *Sponsored by Kithara Software GmbH*
* Fix `Permission` in API returned repository struct (#25388)Jason Song2023-06-229-111/+126
| | | | | | | | | | | | | | | | | | | | | | | The old code generates `structs.Repository.Permissions` with only `access.Permission.AccessMode`, however, it should check the units too, or the value could be incorrect. For example, `structs.Repository.Permissions.Push` could be false even the doer has write access to code unit. Should fix https://github.com/renovatebot/renovate/issues/14059#issuecomment-1047961128 (Not reported by it, I just found it when I was looking into this bug) --- Review tips: The major changes are - `modules/structs/repo.go` https://github.com/go-gitea/gitea/pull/25388/files#diff-870406f6857117f8b03611c43fca0ab9ed6d6e76a2d0069a7c1f17e8fa9092f7 - `services/convert/repository.go` https://github.com/go-gitea/gitea/pull/25388/files#diff-7736f6d2ae894c9edb7729a80ab89aa183b888a26a811a0c1fdebd18726a7101 And other changes are passive.
* Change default email domain for LDAP users (#25425)Zettat1232023-06-222-2/+2
| | | | | Fixes #21169 Change `localhost` to `localhost.local`