Commit Graph
100 Commits
Author SHA1 Message Date
Lunny XiaoandGitHub e94f37f95e Refactor webhook events (#33337)
Extract from #33320

This PR uses a map instead of a struct to store webhook event
information. It removes many duplicated functions and makes the logic
clearer.
2025-01-23 18:53:06 +00:00
6410c34b7f Refactor ref type (#33242)
Major changes:

1. do not sync ".keep" file during tests
2. fix incorrect route handler and empty repo handling (backported as #33253 with tests)
3. do not use `RepoRef`: most of the calls are abuses.
4. Use `git.RefType` instead of a new type definition `RepoRefType` on `context`.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-14 15:35:34 +08:00
be4e961240 Fix mirror bug (#33224)
Fix #33200

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-12 18:46:37 +08:00
Lunny XiaoandGitHub fd7d393c67 Fix unpin hint on the pinned pull requests (#33207) 2025-01-12 00:05:33 +00:00
Lunny XiaoandGitHub d3083d2198 Some small refactors (#33144) 2025-01-10 06:00:06 +00:00
Lunny XiaoandGitHub 39d51e7c82 Automerge supports deleting branch automatically after merging (#32343)
Resolve #32341 
~Depends on #27151~

- [x] It will display a checkbox of deleting the head branch on the pull
request view page when starting an auto-merge task.
- [x] Add permission check before deleting the branch
- [x] Add delete branch comment for those closing pull requests because
of head branch or base branch was deleted.
- [x] Merge `RetargetChildrenOnMerge` and `AddDeletePRBranchComment`
into `service.DeleteBranch`.
2025-01-10 03:51:03 +08:00
Lunny XiaoandGitHub ba5e3a5161 Fix fuzz test (#33156) 2025-01-09 15:15:47 +08:00
Lunny XiaoandGitHub 67aeb1f896 Add missed transaction on setmerged (#33079)
Follow #33045. There are two updates on `Set Merged`, which should be in
one transaction.
This also introduced some refactors for changeissuestatus to make it
more clear.
2025-01-08 03:16:56 +00:00
98637fe76e Filter reviews of one pull request in memory instead of database to reduce slow response because of lacking database index (#33106)
This PR fixes a performance problem when reviewing a pull request in a
big instance which have many records in the `review` table.
Traditionally, we should add more indexes in that table. But since
dismissed reviews of 1 pull request will not be too many as expected in
a common repository. Filtering reviews in the memory should be more
quick .

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-01-07 10:50:09 +08:00
20c7fba601 Use project's redirect url instead of composing url (#33058)
Fix #32992

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-12-31 19:19:53 +08:00
Lunny XiaoandGitHub a54cc05d2a Fix issue comment number (#30556) 2024-12-30 14:35:46 -08:00
Lunny XiaoandGitHub fe32ffe181 Merge updatecommentattachment functions (#33044)
Extract from #32178
2024-12-30 18:21:57 +00:00
Lunny XiaoandGitHub d45456b1b5 Move SetMerged to service layer (#33045)
No code change.
Extract from #32178
2024-12-30 07:04:03 +00:00
Lunny XiaoandGitHub 8eecca3478 Remove aws go sdk package dependency (#33029)
This PR removed the dependency of `github.com/aws/aws-sdk-go/aws`

Patially fix for #33023
2024-12-30 06:30:28 +00:00
Lunny XiaoandGitHub f4ccbd38dc Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from latest commit cache (#32987)
The latest commit cache is currently used only for listing tree files.
However, a cold start may take longer than directly invoking the Git
command. This PR addresses the issue of slow response times when
accessing raw files, improving performance in such scenarios.

```log
gitea.log:105521:2024/12/23 08:22:18 ...eb/routing/logger.go:68:func1() [W] router: slow      GET /xxxx/xxxxxx/raw/commit/xxxxxxxxxxxxxxxxxxxxxxxxxxx/.editorconfig for 172.18.0.5:53252, elapsed 3526.8ms @ repo/download.go:117(repo.SingleDownload)
```
2024-12-30 03:30:01 +00:00
Lunny XiaoandGitHub 344c89ea34 Fix bug automerge cannot be chosed when there is only 1 merge style (#33040)
This is a quick bug fix. Even if there is only 1 merge style, the
dropdown menu will still be displayed to allow users to choose
auto-merge.

Fix #32448
2024-12-30 03:04:22 +00:00
Lunny XiaoandGitHub e69da2cd07 Fix bug on activities (#33008)
A repository with no issue will display a random number on activities
page. This is caused by wrong usage of `And` and `Or`.

![9cdbbf81d50aa5d9bd16604e0dab5eb0](https://github.com/user-attachments/assets/828cebdc-bd35-4716-a58c-c1b43ddf8bf0)
2024-12-28 04:04:07 +00:00
5feb1a6bff Use CloseIssue and ReopenIssue instead of ChangeStatus (#32467)
The behaviors of closing issues and reopening issues are very different.
So splitting it into two different functions makes it easier to
maintain.

- [x] Split ChangeIssueStatus into CloseIssue and ReopenIssue both at
the service layer and model layer
- [x] Rename `isClosed` to `CloseOrReopen` to make it more readable.
- [x] Add transactions for ReopenIssue and CloseIssue

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
2024-12-25 07:38:30 +00:00
Lunny XiaoandGitHub f44712f22b demilestone should not include milestone (#32923)
Fix #32887
2024-12-25 05:52:46 +00:00
b8b690feb9 Refactor getpatch/getdiff functions and remove unnecessary fallback (#32817)
Extract from #32786 

`git diff a..b` is equal to `git diff a b` which is different from `git
diff a...b`. For pull request, we should always 

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-12-24 14:29:34 +08:00
Lunny XiaoandGitHub 751fe8b714 Move some errors to their own sub packages (#32880) 2024-12-20 18:05:29 +00:00
Lunny XiaoandGitHub dc8f59baa5 Add more load functions to make sure the reference object loaded (#32901)
Fix #32897
2024-12-19 14:10:08 +08:00
Lunny XiaoandGitHub f9f62b4c4c Move delete deploy keys into service layer (#32201) 2024-12-18 04:10:38 +00:00
Lunny XiaoandGitHub e4c4629465 Move RepoTransfer from models to models/repo sub package (#32506)
`RepoTransfer` now is at models, but if we want to move it into `repo`
model, it will depend on `Team`. So this PR also makes repo model depend
on org model to make it possible. Just refactor, no code change.

- [x] Move `DeleteOrganization` from `models/organization` to service
layer
- [x] Move `AccessibleTeamReposEnv` to `models/repo`
- [x] Move `RepoTransfer` from `models` to `models/repo`
- [x] Merge `getUserTeamIDs` and `GetUserTeamIDs`, Merge `GetUserTeams`
and `getUserTeams`.
- [x] Remove `Team`'s `Repos []*repo_model.Repository` to avoid dependency recycle.
2024-12-18 11:44:16 +08:00
42090844ed Fix bug on action list deleted branch (#32848)
Fix
https://github.com/go-gitea/gitea/issues/32761#issuecomment-2540946064

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-12-16 05:38:39 +08:00
Lunny XiaoandGitHub 9264811217 Remove translation to issue add time because the format is fixed should not be translated (#32850)
The input content should always be `1h 2m 3s` and will be the same on
different UI languages. So the translation is wrong.
2024-12-15 07:44:13 +00:00
Lunny XiaoandGitHub 887928e0a6 Add missing two sync feed for refs/pull (#32815)
Fowllow #32659
2024-12-13 04:22:39 +00:00
Lunny XiaoandGitHub 6370d2fb93 Detect whether action view branch was deleted (#32764)
Fix #32761 

![图片](https://github.com/user-attachments/assets/a5a7eef8-0fea-4242-b199-1b0b73d9bbdb)
2024-12-12 19:28:23 +00:00
Lunny XiaoandGitHub 39a01016cd Upgrade dependency crypto library (#32750) 2024-12-11 13:07:48 -05:00
Lunny XiaoandGitHub fbe6d9dc6b Use batch database operations instead of one by one to optimze api pulls (#32680)
Resolve #31492

The response time for the Pull Requests API has improved significantly,
dropping from over `2000ms` to about `350ms` on my local machine. It's
about `6` times faster.

A key area for further optimization lies in batch-fetching data for
`apiPullRequest.ChangedFiles, apiPullRequest.Additions, and
apiPullRequest.Deletions`.

Tests `TestAPIViewPulls` does exist and new tests added.

- This PR also fixes some bugs in `GetDiff` functions.
- This PR also fixes data inconsistent in test data. For a pull request,
the head branch's reference should be equal to the reference in
`pull/xxx/head`.
2024-12-11 05:15:06 +08:00
Lunny XiaoandGitHub 9d08d3fbf5 Fix compare page bug view as anonymous (#32754)
Fix a bug introduced from
https://github.com/go-gitea/gitea/pull/32403/files#diff-dc86301f15109eee38296d469630672193e0587ad1485fdd8f503bf4c789cf7eR692
2024-12-08 14:38:21 +08:00
Lunny XiaoandGitHub cd7bf77b2f Split issue/pull view router function as multiple smaller functions (#32749)
This PR splits issue/pull view function into multiple smaller functions.
It also removed duplicated branches load.
2024-12-08 04:39:35 +00:00
Lunny XiaoandGitHub 5a75160c92 Update changelog to add missed changelog (#32734) 2024-12-06 17:31:43 +00:00
Lunny XiaoandGitHub b32f0cdfa0 Make wiki pages visit fast (#32732) 2024-12-06 07:39:50 +00:00
Lunny XiaoandGitHub c5422fae9a Fix fork page branch selection (#32711)
Fix #32709
2024-12-05 00:57:32 +00:00
Lunny XiaoandGitHub 5ab7aa700f Use new mail package instead of an unmintained one (#32682)
Resolve #18664
2024-12-05 06:33:43 +08:00
Lunny XiaoandGitHub e45ffc530f Remove outdated code about fixture generation (#32708) 2024-12-04 07:59:28 +00:00
Lunny XiaoandGitHub 17053e953f Fix delete branch perm checking (#32654) 2024-12-04 11:59:48 +08:00
Lunny XiaoandGitHub 829c34129c Quick fix for license file name (#32696) 2024-12-03 07:59:07 -08:00
Lunny XiaoandGitHub 79d593a9be Split mail sender sub package from mailer service package (#32618)
Move all mail sender related codes into a sub package of
services/mailer. Just move, no code change.
Then we just have dependencies on go-mail package in the new sub
package. We can use other package to replace it because it's
unmaintainable. ref #18664
2024-11-30 01:15:41 +00:00
Lunny XiaoandGitHub 1ed5f379b9 Move GetFeeds to service layer (#32526)
Move GetFeeds from models to service layer, no code change.
2024-11-29 17:53:49 +00:00
Lunny XiaoandGitHub 00f8090de4 Don't create action when syncing mirror pull refs (#32659)
Fix #27961
2024-11-28 07:43:38 +00:00
Lunny XiaoandGitHub f62f68cbdd Move team related functions to service layer (#32537)
There are still some functions under `models` after last big refactor
about `models`. This change will move all team related functions to
service layer with no code change.
2024-11-27 21:12:26 +00:00
Lunny XiaoandGitHub f49d82309b Introduce OrgList and add LoadTeams, optimaze Load teams for orgs (#32543) 2024-11-26 21:55:06 +00:00
Lunny XiaoandGitHub 703be6bf30 Add github compatible tarball download API endpoints (#32572)
Fix #29654 
Fix #32481
2024-11-25 19:35:49 +00:00
Lunny XiaoandGitHub c363bd06e9 Strict pagination check (#32548) 2024-11-25 09:56:50 +08:00
Lunny XiaoandGitHub fe49cb0243 Fix get reviewers' bug (#32415)
This PR rewrites `GetReviewer` function and move it to service layer.

Reviewers should not be watchers, so that this PR removed all watchers
from reviewers. When the repository is under an organization, the pull
request unit read permission will be checked to resolve the bug of
#32394

Fix #32394
2024-11-22 10:44:48 -05:00
Lunny XiaoandGitHub a175f9805c Add line-through for deleted branch on pull request view page (#32500)
Base branch deleted

![图片](https://github.com/user-attachments/assets/bc45aa33-d514-47c8-885a-de9732f2f3d5)

branch deleted comment

![图片](https://github.com/user-attachments/assets/83729bbb-2ee8-4bd3-b6f1-780d2daad3d4)

Head branch deleted

![图片](https://github.com/user-attachments/assets/90120b22-34a9-4387-aae9-5c882e8d421a)
2024-11-21 17:04:18 +00:00
Lunny XiaoandGitHub 9bf821ae6c Fix GetInactiveUsers (#32540)
Fix #31480
2024-11-21 04:55:32 +00:00
33850a83fe Fix submodule parsing (#32571)
Fix #32568, parse `.gitmodules` correctly

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-11-20 19:26:12 +00:00
Lunny XiaoandGitHub 0d5abd9b3e Remove unnecessary code (#32560)
PushMirrors only be used in the repository setting page. So it should
not be loaded on every repository page.
2024-11-19 16:21:13 +00:00
Lunny XiaoandGitHub 896314c7a2 Fix some places which doesn't repsect org full name setting (#32243)
Partially fix #31345
2024-11-18 06:24:49 +00:00
696fbe6036 Refactor push mirror find and add check for updating push mirror (#32539)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-11-18 05:59:04 +00:00
4f879a00df Refactor find forks and fix possible bugs that weak permissions check (#32528)
- Move models/GetForks to services/FindForks
- Add doer as a parameter of FindForks to check permissions
- Slight performance optimization for get forks API with batch loading
of repository units
- Add tests for forking repository to organizations

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-11-18 03:06:25 +00:00
Lunny XiaoandGitHub f122aaf9ff Use better name for userinfo structure (#32544) 2024-11-18 10:41:59 +08:00
Lunny XiaoandGitHub c3dedcffa7 Fix basic auth with webauthn (#32531) 2024-11-16 17:52:16 +00:00
Lunny XiaoandGitHub e1b269e956 Remove transaction for archive download (#32186)
Since there is a status column in the database, the transaction is
unnecessary when downloading an archive. The transaction is blocking
database operations, especially with SQLite.

Replace #27563
2024-11-15 12:04:20 +08:00
Lunny XiaoandGitHub 4121f952d1 Fix oauth2 error handle not return immediately (#32514) 2024-11-15 02:13:01 +00:00
Lunny XiaoandGitHub 98d9a71ffe Trim title before insert/update to database to match the size requirements of database (#32498)
Fix #32489
2024-11-14 07:19:14 +00:00
b4abb6deff Reimplement GetUserOrgsList to make it simple and clear (#32486)
Reimplement GetUserOrgsList and also move some functions and test to
org_list file.

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
2024-11-14 05:31:47 +00:00
840ad7eefe Disable Oauth check if oauth disabled (#32368)
Fix #32367

---------

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-11-12 21:33:35 +00:00
a1892cf7e3 Move some functions from issue.go to standalone files (#32468)
Just functions move, no code change.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-11-11 04:28:54 +00:00
Lunny XiaoandGitHub 331e878e81 Add new event commit status creation and webhook implementation (#27151)
This PR introduces a new event which is similar as Github's. When a new
commit status submitted, the event will be trigged. That means, now we
can receive all feedback from CI/CD system in webhooks or other notify
systems.

ref:
https://docs.github.com/en/webhooks/webhook-events-and-payloads#status

Fix #20749
2024-11-07 06:41:49 +00:00
Lunny XiaoandGitHub 276500c314 Move AddCollabrator and CreateRepositoryByExample to service layer (#32419)
- [x] Move `CreateRepositoryByExample` to service layer
- [x] Move `AddCollabrator` to service layer
- [x] Add a new parameter for `AddCollabrator` so that changing mode
immediately after that will become unnecessary.
2024-11-07 11:28:11 +08:00
Lunny XiaoandGitHub 913be9e8ac Add new index for action to resolve the performance problem (#32333)
Fix #32224
2024-11-06 22:04:48 +00:00
24b83ff63e Fix milestone deadline and date related problems (#32339)
Use zero instead of 9999-12-31 for deadline
Fix #32291

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2024-11-05 07:46:40 +00:00
Lunny XiaoandGitHub 1887c75c35 Only query team tables if repository is under org when getting assignees (#32414)
It's unnecessary to query the team table if the repository is not under
organization when getting assignees.
2024-11-05 07:13:52 +00:00
Lunny XiaoandGitHub 13a203828c Fix created_unix for mirroring (#32342)
Fix #32233
2024-11-02 06:11:38 +00:00
feca8802b8 Fix clean tmp dir (#32360)
Try to fix #31792 

Credit to @jeroenlaylo
Copied from
https://github.com/go-gitea/gitea/issues/31792#issuecomment-2311920520

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-10-29 18:27:03 +02:00
Lunny XiaoandGitHub 2abdbe88b5 Fix disable 2fa bug (#32320) 2024-10-23 06:41:00 +00:00
Lunny XiaoandGitHub d46d34a655 Upgrade rollup to 4.24.0 (#32312) 2024-10-23 05:00:32 +00:00
Lunny XiaoandGitHub 500774277c Upgrade vue to 3.5.12 (#32311) 2024-10-23 04:55:17 +00:00
Lunny XiaoandGitHub a264c46fb0 Add warn log when deleting inactive users (#32318)
Add log for the problem #31480
2024-10-23 09:28:28 +08:00
Lunny XiaoandGitHub 9df5ddaf44 Only rename a user when they should receive a different name (#32247)
Fix #31996
2024-10-13 03:13:55 +00:00
Lunny XiaoandGitHub aebb741c08 Use per package global lock for container uploads instead of memory lock (#31860)
This PR uses a per-package lock instead of a global lock for container
uploads. So that different packages can be uploaded simultaneously.
2024-10-11 07:37:49 +00:00
c2217670dd Move admin routers from /admin to /-/admin (#32189)
Resolve #32181

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-10-10 04:56:49 +00:00
Lunny XiaoandGitHub d6d3c96e65 Fix bug when a token is given public only (#32204) 2024-10-08 12:51:09 +03:00
Lunny XiaoandGitHub fa35ace9fb Fix bug when there are multiple triggers with workflow dispatch (#32200) 2024-10-07 03:50:38 +00:00
a989404e23 Fix javascript error when an anonymous user visiting migration page (#32144)
This PR fixes javascript errors when an anonymous user visits the
migration page.
It also makes task view checking more restrictive.

The router moved from `/user/task/{id}/status` to
`/username/reponame/-/migrate/status` because it's a migrate status.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-10-02 04:37:16 +00:00
Lunny XiaoandGitHub 3a4a1bffbe Make oauth2 code clear. Move oauth2 provider code to their own packages/files (#32148)
Fix #30266
Replace #31533
2024-10-02 08:03:19 +08:00
Lunny XiaoandGitHub 3f9e360142 Don't join repository when loading action table data (#32127) 2024-09-26 04:50:30 +00:00
Lunny XiaoandGitHub 5a8568459d Fix bug when deleting a migrated branch (#32075)
After migrating a repository with pull request, the branch is missed and
after the pull request merged, the branch cannot be deleted.
2024-09-24 07:42:08 +00:00
Lunny XiaoandGitHub 4947bec836 Include collaboration repositories on dashboard source/forks/mirrors list (#31946)
Fix #13489

In the original implementation, only `All` will display your owned and
collaborated repositories. For other filters like `Source`, `Mirrors`
and etc. will only display your owned repositories.

This PR removed the limitations. Now except `collbrations`, other
filters will always display your owned and collaborated repositories.
2024-09-24 07:12:06 +00:00
Lunny XiaoandGitHub e2f365b55c Display head branch more comfortable on pull request view (#32000)
This PR do some minor improvements for head branch display on pull
request view UI.

- [x] Remove the link if the head branch has been deleted with a
tooltip, so that users will not result in a 404 page
- [x] Display a label if this pull request is an agit based one.

![图片](https://github.com/user-attachments/assets/872f26b6-f1cf-4427-9e41-e3a5b176dfa4)
2024-09-24 04:14:57 +00:00
Lunny XiaoandGitHub 2c6fa6c1e0 Fix template bug of pull request view (#32072)
Caused by #31924
2024-09-24 03:02:42 +00:00
Lunny XiaoandGitHub 6eb5950835 Allow set branch protection in an empty repository (#32095) 2024-09-24 02:06:28 +00:00
Lunny XiaoandGitHub 3f2d8f8730 Fix panic when cloning with wrong ssh format. (#32076) 2024-09-24 01:30:05 +00:00
Lunny XiaoandGitHub 9e0db1b646 Fix rename branch permission bug (#32066)
The previous implementation requires admin permission to rename branches
which should be write permission.

Fix #31993
2024-09-22 18:08:27 +00:00
Lunny XiaoandGitHub a802508f88 Fix wrong last modify time (#32102) 2024-09-21 21:56:25 +00:00
Lunny XiaoandGitHub 5de41737a5 Fix upload maven pacakge parallelly (#31851)
Use globallock for maven package uploads.

Thanks @tlusser for the test code.

Depends on ~#31813~
2024-09-21 19:26:45 +00:00
Lunny XiaoandGitHub 8e2dd5d3dd Use camo.Always instead of camo.Allways (#32097)
Fix #31575 

https://gitea.com/gitea/docs/pulls/73
2024-09-21 12:50:54 +03:00
Lunny XiaoandGitHub 8cdf4e29c4 Fix CI (#32062) 2024-09-17 19:35:59 +00:00
Lunny XiaoandGitHub 3febcaa53b Use a common message template instead of a special one (#31878) 2024-09-14 17:17:49 +00:00
Lunny XiaoandGitHub d8f3498875 Upgrade cache to v0.2.1 (#32003)
Fix #31757
2024-09-07 17:12:37 +00:00
2da2000413 Use global lock instead of NewExclusivePool to allow distributed lock between multiple Gitea instances (#31813)
Replace #26486 
Fix #19620

---------

Co-authored-by: Jason Song <i@wolfogre.com>
2024-09-06 10:12:41 +00:00
Lunny XiaoandGitHub a5818470fe Use forum.gitea.com instead of old URL (#31989) 2024-09-06 07:20:30 +00:00
Lunny XiaoandGitHub 5c05dddbed Fix nuget/conan/container packages upload bugs (#31967) 2024-09-05 07:05:42 +00:00
Lunny XiaoandGitHub a366af4b7a Remove html tags from create tag and branch translation (#31973)
Follow #31950 and Fix the display bug of #31966 .

This will only fix the English version. I will update all these
translation files in crowdin after this merged so that all the languages
can be fixed.

And all these files should be backported together.

This PR remove the bold effect around the name when creating a new tag
or branch.
2024-09-04 12:53:55 +08:00
7eef261c3e Replace v-html with v-text in search inputbox (#31966)
Credit for @techknowlogick

Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com>
2024-09-04 02:52:00 +00:00
85b1f3080c Improve get feed with pagination (#31821)
Fix #31752

@somera

---------

Co-authored-by: delvh <dev.lh@web.de>
2024-09-02 19:05:09 +00:00