aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo
Commit message (Collapse)AuthorAgeFilesLines
...
* Move commits signature and verify functions to service layers (#33605)Lunny Xiao2025-02-164-7/+10
| | | | No logic change, just move functions.
* enable literal string for code search (#33590)Darren Hoo2025-02-162-59/+6
| | | | | | | | Close: #33588 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Artifacts download api for artifact actions v4 (#33510)ChristopherHX2025-02-161-15/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | * download endpoint has to use 302 redirect * fake blob download used if direct download not possible * downloading v3 artifacts not possible New repo apis based on GitHub Rest V3 - GET /runs/{run}/artifacts (Cannot use run index of url due to not being unique) - GET /artifacts - GET + DELETE /artifacts/{artifact_id} - GET /artifacts/{artifact_id}/zip - (GET /artifacts/{artifact_id}/zip/raw this is a workaround for a http 302 assertion in actions/toolkit) - api docs removed this is protected by a signed url like the internal artifacts api and no longer usable with any token or swagger - returns http 401 if the signature is invalid - or change the artifact id - or expired after 1 hour Closes #33353 Closes #32124 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Improve commits list performance to reduce unnecessary database queries (#33528)Lunny Xiao2025-02-145-10/+45
| | | | | | When listing commits, Gitea attempts to retrieve the actual user based on the commit email. Querying users one by one from the database is inefficient. This PR optimizes the process by batch querying users by email, reducing the number of database queries.
* Performance optimization for pull request files loading comments attachments ↵Lunny Xiao2025-02-141-6/+6
| | | | (#33585)
* Fix PR's target branch dropdown (#33589)wxiaoguang2025-02-141-8/+16
| | | | | | Fix #33586 It only moves `PrepareBranchList` and `retrieveAssigneesData` to before the `CanModifyIssueOrPull` check, and adds more comments
* Fix various problems (artifact order, api empty slice, assignee check, fuzzy ↵wxiaoguang2025-02-131-4/+7
| | | | | | | | | | prompt, mirror proxy, adopt git) (#33569) * Make artifact list output a stable order * Fix #33506 * Fix #33521 * Fix #33288 * Fix #33196 * Fix #33561
* Enhance routers for the Actions runner operations (#33549)Jason Song2025-02-111-187/+0
| | | | | | | | | - Find the runner before deleting - Move the main logic from `routers/web/repo/setting/runners.go` to `routers/web/shared/actions/runners.go`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enhance routers for the Actions variable operations (#33547)Jason Song2025-02-111-140/+0
| | | | | | | | | | - Find the variable before updating or deleting - Move the main logic from `routers/web/repo/setting/variables.go` to `routers/web/shared/actions/variables.go`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Feature: Support workflow event dispatch via API (#33545)wxiaoguang2025-02-111-130/+11
| | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Rework suggestion backend (#33538)Lunny Xiao2025-02-101-49/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #33522 The suggestion backend logic now is - If the keyword is empty, returned the latest 5 issues/prs with index desc order - If the keyword is digital, find all issues/prs which `index` has a prefix with that, with index asc order - If the keyword is non-digital or if the queried records less than 5, searching issues/prs title with a `like`, with index desc order ## Empty keyword <img width="310" alt="image" src="https://github.com/user-attachments/assets/1912c634-0d98-4eeb-8542-d54240901f77" /> ## Digital <img width="479" alt="image" src="https://github.com/user-attachments/assets/0356a936-7110-4a24-b21e-7400201bf9b8" /> ## Digital and title contains the digital <img width="363" alt="image" src="https://github.com/user-attachments/assets/6e12f908-28fe-48de-8ccc-09cbeab024d4" /> ## non-Digital <img width="435" alt="image" src="https://github.com/user-attachments/assets/2722bb53-baa2-4d67-a224-522a65f73856" /> <img width="477" alt="image" src="https://github.com/user-attachments/assets/06708dd9-80d1-4a88-b32b-d29072dd1ba6" /> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Revert "Feature: Support workflow event dispatch via API (#32059)" (#33541)wxiaoguang2025-02-101-24/+136
| | | This reverts commit 523751dc82bbb9d3f8d413f232e23ab0476eb4d4.
* Feature: Support workflow event dispatch via API (#32059)Bence Sántha2025-02-101-136/+24
| | | | | | | | | ref: https://github.com/go-gitea/gitea/issues/31765 --------- Signed-off-by: Bence Santha <git@santha.eu> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Add a option "--user-type bot" to admin user create, improve role display ↵mscherer2025-02-071-44/+37
| | | | | | | | | | | (#27885) Partially solve #13044 Fix #33295 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move gitgraph from modules to services layer (#33527)Lunny Xiao2025-02-071-1/+1
| | | Just move, no code change.
* Refactor web route handler (#33488)wxiaoguang2025-02-054-91/+100
|
* Fix commit status events (#33320)Lunny Xiao2025-02-041-0/+1
| | | | | | | | | | Fix #32873 Fix #33201 ~Fix #33244~ ~Fix #33302~ depends on ~#33396~ A part of this PR should be backported to v1.23 manually.
* chore: fix some trivial problems and TODOs (#33473)wxiaoguang2025-02-021-5/+0
| | | | | | | | | | | 1. Fix incorrect `MentionCount` (actually it seems to be deadcode, affects nothing) 2. Remove fallback sha1 support for time limit token 3. Use route middleware `reqRepoActionsWriter` for `ArtifactsDeleteView` 4. Use clearer message "Failed to authenticate user" instead of "Verify" when auth fails 5. `tests/integration/benchmarks_test.go` is not quite right, actually it is never used, so delete it. 6. Remove or update TODO comments
* actions view: move loading of task attributes etc... into own func (#31494)65432025-02-021-67/+81
| | | | just a smal refactor to make the function length smaler ... and code more reusable in the future
* Support choose email when creating a commit via web UI (more) (#33445)wxiaoguang2025-01-314-27/+83
| | | Follow #33432
* Fix "redirect link" handling (#33440)wxiaoguang2025-01-312-7/+18
| | | | | | | `a%2fb` should not redirect to `a/b` --------- Co-authored-by: delvh <dev.lh@web.de>
* Refactor repository transfer (#33211)Lunny Xiao2025-01-302-50/+37
| | | | | | | | | | | | | - Both have `RejectTransfer` and `CancelTransfer` because the permission checks are not the same. `CancelTransfer` can be done by the doer or those who have admin permission to access this repository. `RejectTransfer` can be done by the receiver user if it's an individual or those who can create repositories if it's an organization. - Some tests are wrong, this PR corrects them. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support choose email when creating a commit via web UI (#33432)wxiaoguang2025-01-301-22/+46
| | | Initial PR for #24469
* Link to tree views of submodules if possible (#33424)Rowan Bohde2025-01-301-0/+6
| | | | | | | | | | | | | | This is a follow-up to https://github.com/go-gitea/gitea/pull/33097. When linking a submodule at a commit in either the repo view, or a diff when adding a new submodule, link to the tree view of that submodules intead of the individual commit. This shows the user the full tree, instead of the diff of the commit. This makes the assumption that the tree for a given SHA is at `<repo_url>/tree/<sha>`. This URL format is supported by both Github & Gitlab, but not Gitea. To fix this, add a redirect from `<username>/<repo>/tree/<ref>` to `<username>/<repo>/src/<ref>`, so that Gitea can support this URL structure.
* Refactor context flash msg and global variables (#33375)wxiaoguang2025-01-251-14/+14
| | | | | | 1. add `GetSiteCookieFlashMessage` to help to parse flash message 2. clarify `handleRepoHomeFeed` logic 3. remove unnecessary global variables, use `sync.OnceValue` instead 4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
* Refactor webhook events (#33337)Lunny Xiao2025-01-231-21/+21
| | | | | | | 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.
* Remove duplicate "ResponseWriter.Status" method (#33346)wxiaoguang2025-01-223-29/+29
|
* Fix incorrect ref commit ID usage (#33331)wxiaoguang2025-01-205-5/+13
| | | | | | | After the RefName refactoring, the `ctx.Repo.CommitID` is only set when there is a `RepoRefByType` middleware. Many handlers do not use that middleware and they only use "default branch"
* Make tracked time representation display as hours (#33315)Vladimir Sysoev2025-01-191-1/+1
| | | | | | | | | | Estimated time represented in hours it might be convenient to have tracked time represented in the same way to be compared and managed. --------- Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix push message behavior (#33215)Chai-Shi2025-01-171-1/+19
| | | | | | | Fixes #32769 by the logic from pr #33192 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Trivial fixes (#33304)wxiaoguang2025-01-173-3/+3
| | | | | | | 1. the error check was added for go-git, it was caused by the empty `.keep` file in the test fixtures. 2. use `PostFormValue` instead of `PostForm.Get` (`Get` needs to parse the form ahead) 3. fix incorrect container text (it should show "Images" in the header but not "OS/Arch") 4. align maven xml 5. fix closed PR color&icon
* Fix incorrect ref usages (#33301)wxiaoguang2025-01-162-13/+1
| | | | | Fix #33297 By the way, improve some locales
* Only allow admins to rename default/protected branches (#33276)Kemal Zebari2025-01-151-0/+8
| | | | | | | | | | | | | Currently, anyone with write permissions to a repo are able to rename default or protected branches. This change follows [GitHub's](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch) design by only allowing repo/site admins to change these branches. However, it also follows are current design for protected branches and only allows admins to modify branch names == branch protection rule names. Glob-based rules cannot be renamed by anyone (as was already the case, but we now catch `ErrBranchIsProtected` which we previously did not catch, throwing a 500).
* Fix incorrect TagName/BranchName usages (#33279)wxiaoguang2025-01-152-1/+2
| | | Add add a new test
* Simplify context ref name (#33267)wxiaoguang2025-01-155-15/+5
|
* Refactor ref type (#33242)Lunny Xiao2025-01-142-2/+2
| | | | | | | | | | | | 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>
* Support public code/issue access for private repositories (#33127)wxiaoguang2025-01-142-10/+17
| | | Close #8649, close #639 (will add "anonymous access" in following PRs)
* Validate that the tag doesn't exist when creating a tag via the web (#33241)Kemal Zebari2025-01-142-153/+230
| | | | | | | | | | | | | | | | Found while investigating #33210. This line no longer makes sense because the form field "TagName" is required, so this would mean that this code path would never be covered. Because it isn't covered, we end up going down the "update release" logic where we eventually set `Release.IsTag` to false (meaning it will now be treated as a release instead of a tag). This snapshot rewrites the condition to ensure that we aren't trying to create a tag that already exists. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix incorrect ref "blob" (#33240)wxiaoguang2025-01-131-1/+7
| | | | | 1. "blob" is not a "ref", it shouldn't (and not unable to) be handled by `RepoRefByType` 2. the `/blob/{sha}` handle should use the path param "sha" directly
* Refactor context RefName and RepoAssignment (#33226)wxiaoguang2025-01-135-32/+9
| | | | | | | The `ctx.Repo.RefName` was used to be a "short name", it causes a lot of ambiguity. This PR does some refactoring and use `RefFullName` to replace the legacy `RefName`, and simplify RepoAssignment
* Refactor context repository (#33202)wxiaoguang2025-01-1214-42/+34
|
* Some small refactors (#33144)Lunny Xiao2025-01-101-7/+23
|
* Automerge supports deleting branch automatically after merging (#32343)Lunny Xiao2025-01-102-13/+3
| | | | | | | | | | | | 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`.
* Refactor older tests to use testify (#33140)TheFox0x72025-01-092-15/+11
| | | | | Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
* add submodule diff links (#33097)Rowan Bohde2025-01-081-1/+0
| | | | | | | | | | | | This adds links to submodules in diffs, similar to the existing link when viewing a repo at a specific commit. It does this by expanding diff parsing to recognize changes to submodules, and find the specific refs that are added, deleted or changed. Related #25888 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Filter reviews of one pull request in memory instead of database to reduce ↵Lunny Xiao2025-01-071-8/+2
| | | | | | | | | | | | | | 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>
* fix empty repo updated time (#33120)Chai-Shi2025-01-071-1/+4
| | | | | | | | | | | | | | | | | | fixes #33119 routers/web/repo/view_home.go ![image](https://github.com/user-attachments/assets/b0d6c5f5-7abc-478a-8d41-4b44dbd460aa) Calling `updateContextRepoEmptyAndStatus` will always ask the DB to update the updated Unix attributes. When revisiting the repo's home page, the timestamp will be updated unexpectedly, so I added the needsUpdate variable to check whether, in the end, the commitment to db update is necessary if columns have not changed at all. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix repo empty guide (#33114)wxiaoguang2025-01-061-0/+1
|
* workflow_dispatch use workflow from trigger branch (#33098)ChristopherHX2025-01-052-92/+133
| | | | | | | | | | | | | * htmx updates the input form on branch switch * add workflow warning to dispatch modal * use name if description of input is empty * show error if workflow_dispatch not available on branch Closes #33073 Closes #33099 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix empty git repo handling logic (#33101)wxiaoguang2025-01-041-16/+30
| | | Fix #33092