summaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Add actions support to package auth verification (#23729) (#24028)Giteabot2023-04-102-37/+22
| | | | | | | | | | | | | | | Backport #23729 by @yp05327 Partly fixes https://github.com/go-gitea/gitea/issues/23642 Error info: ![image](https://user-images.githubusercontent.com/18380374/227827027-4280a368-ec9e-49e0-bb93-6b496ada7cd9.png) ActionsUser (userID -2) is used to login in to docker in action jobs. Due to we have no permission policy settings of ActionsUser now, ActionsUser can only access public registry by this quick fix. Co-authored-by: yp05327 <576951401@qq.com>
* Fix protected branch for API (#24013) (#24027)Giteabot2023-04-101-4/+8
| | | | | | | Backport #24013 by @lunny Fix #23998 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Set `ref` to fully-formed of the tag when trigger event is `release` ↵Giteabot2023-04-081-1/+2
| | | | | | | | | | | (#23944) (#23989) Backport #23944 by @sillyguodong Fix #23943 When trigger event is `release`, ref should be like `refs/tags/<tag_name>` instead of `CommitID` Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
* Fix redirect bug when creating issue from a project (#23971) (#23997)Giteabot2023-04-081-2/+2
| | | | | | | Backport #23971 by @lunny Fix #23966 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Ensure RSS icon is present on all repo tabs (#23904) (#23973)Giteabot2023-04-071-3/+0
| | | | | | | | | | | | | | | | | | | Backport #23904 by @silverwind Previously, not all repo tabs had shown the RSS icon in the repo header because the context data was not being set. Added this context data in a new function. Before: <img width="806" alt="image" src="https://user-images.githubusercontent.com/115237/229639615-9cc00e75-3a26-4ff4-a6f2-316c1fccc596.png"> After: <img width="815" alt="Screenshot 2023-04-04 at 00 16 17" src="https://user-images.githubusercontent.com/115237/229639201-2e1c015b-1f13-46d4-aa14-e7a82fab3982.png"> Co-authored-by: silverwind <me@silverwind.io>
* Title can be empty when creating tag only (#23917) (#23961)Giteabot2023-04-071-0/+6
| | | | | | | | | | | | Backport #23917 by @Zettat123 Fixes #23809 Make the title not required. If the title is empty when creating release (not tag), an error message will be displayed. ![image](https://user-images.githubusercontent.com/15528715/229761056-c52e338b-5f25-4d7d-bb44-2cb0304abcee.png) Co-authored-by: Zettat123 <zettat123@gmail.com>
* Support "." char as user name for User/Orgs in RSS/ATOM/GPG/KEYS path ... ↵65432023-04-071-10/+42
| | | | | (#23874) (#23878) Backport #23874
* User/Org Feed render description as per web (#23887) (#23906)Giteabot2023-04-041-1/+15
| | | | | | | | | | Backport #23887 by @6543 User descriptions should be rendered so that links and other markup appear correct in RSS feeds. test will be added by #23874 Co-authored-by: 6543 <6543@obermui.de>
* Use User.ID instead of User.Name in ActivityPub API for Person IRI (#23823) ↵Giteabot2023-04-033-11/+18
| | | | | | | | | | | | | | (#23905) Backport #23823 by @wxiaoguang Thanks to @trwnh Close #23802 The ActivityPub id is an HTTPS URI that should remain constant, even if the user changes their name. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix 500 error if there is a name conflict when edit authentication source ↵Giteabot2023-03-311-2/+4
| | | | | | | (#23832) (#23852) Backport #23832 by @yp05327 Co-authored-by: yp05327 <576951401@qq.com>
* Fix incorrect visibility dropdown list in add/edit user page (#23804) (#23833)Giteabot2023-03-311-0/+2
| | | | | | | | Backport #23804 by @yp05327 Visibility dropdown list will not work in add/edit user page when error occurred Co-authored-by: yp05327 <576951401@qq.com>
* Add ONLY_SHOW_RELEVANT_REPOS back, fix explore page bug, make code more ↵wxiaoguang2023-03-301-3/+11
| | | | | | | | | | | | | | | | | strict (#23766) (#23791) Follow #21962 After I eat my own dogfood, I would say that ONLY_SHOW_RELEVANT_REPOS=false is necessary for many private/enterprise instances, because many private repositories do not have "description/topic", users just want to search by their names. This PR also adds `PageIsExploreRepositories` check, to make code more strict, because the `search` template is shared for different purpose. And during the test, I found a bug that the "Search" button didn't respect the "relevant" parameter, so this PR fixes the bug by the way together.
* Fix cancel button in the page of project edit not work (#23655) (#23813)sillyguodong2023-03-302-0/+3
| | | | | | | | | | | | | | | | | | | | | Backport #23655 Before, in project edit page, the cancel button is not work. https://user-images.githubusercontent.com/33891828/227182731-6478e29f-0e52-48c4-beb0-6a7d1dda6a1d.mov 1. The wrong classname `cancel` was added to the `<a>` tag. That classname caused the default click event of `<a>` tag to be cancelled. Because we have the following settings in the global. So I remove the classname `cancel`. https://github.com/go-gitea/gitea/blob/9be90a58754061171bbd5025d85d2b891364efd3/web_src/js/features/common-global.js#L325-L327 2. Another change is that page will redirect to the previous page. https://user-images.githubusercontent.com/33891828/227187326-c653c6d6-9715-440f-a732-ba0a6f012c81.mov
* Fix profile page email display, respect settings (#23747) (#23756)Giteabot2023-03-281-1/+1
| | | | | | | | | | | | | | | | | Backport #23747 by @wxiaoguang Always respect the `setting.UI.ShowUserEmail` and `KeepEmailPrivate` setting. * It doesn't make sense to show user's own E-mail to themself. * Always hide the E-mail if KeepEmailPrivate=true, then the user could know how their profile page looks like for others. * Revert the `setting.UI.ShowUserEmail` change from #4981 . This setting is used to control the E-mail display, not only for the user list page. ps: the incorrect `<div .../>` tag on the profile page has been fixed by #23748 together, so this PR becomes simpler. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Redirect to project again after editing it (#23326) (#23739)Giteabot2023-03-272-2/+12
| | | | | | | | | | | Backport #23326 by @yp05327 A part of https://github.com/go-gitea/gitea/pull/22865 We have edit buttons in projects list page and project view page. But after user edit a project, it will always redirect to the projects list page. Co-authored-by: yp05327 <576951401@qq.com>
* Fix pagination on `/notifications/watching` (#23564) (#23603)Giteabot2023-03-211-1/+4
| | | | | | | | | Backport #23564 by @silverwind The `q` parameter was not rendered in pagination links because `context.Pagination:AddParam` checks for existance of the parameter in `ctx.Data` where it was absent. Added the parameter there to fix it. Co-authored-by: silverwind <me@silverwind.io>
* Match api migration behavior to web behavior (#23552) (#23573)Giteabot2023-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | Backport #23552 by @atomaka When attempting to migrate a repository via the API endpoint comments are always included. This can create a problem if your source repository has issues or pull requests but you do not want to import them into Gitea that displays as something like: > Error 500: We were unable to perform the request due to server-side problems. 'comment references non existent IssueIndex 4 There are only two ways to resolve this: 1. Migrate using the web interface 2. Migrate using the API including at issues or pull requests. This PR matches the behavior of the API migration router to the web migration router. Co-authored-by: Andrew Tomaka <atomaka@atomaka.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Handle missing `README` in create repos API (#23387) (#23510)Zettat1232023-03-162-0/+13
| | | | | | | | | | | Backport #23387 Close #22934 In `/user/repos` API (and other APIs related to creating repos), user can specify a readme template for auto init. At present, if the specified template does not exist, a `500` will be returned . This PR improved the logic and will return a `400` instead of `500`. Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Make branches list page operations remember current page (#23420) (#23460)Giteabot2023-03-141-10/+7
| | | | | | | | | | | | | | Backport #23420 by @wxiaoguang Close #23411 Always pass "page" query parameter to backend, and make backend respect it. The `ctx.FormInt("limit")` is never used, so removed. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Purge API comment (#23451) (#23452)Giteabot2023-03-131-0/+4
| | | | | | | | | | | | | Backport #23451 by @jolheiser This PR just adds the `purge` query parameter to the swagger docs for admin user delete. I considered using the same verbiage we have in the UI, but that seemed more verbose than descriptions we use elsewhere in swagger. I'm fine if that's preferred, though, just let me know. 🙂 Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Fix actions frontend bugs (pagination, long name alignment) and small ↵Giteabot2023-03-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | simplify (#23370) (#23436) Backport #23370 by @HesterG 1 Right now on actions page, the action list will not be aligned if commit message is long. In this PR, the changes are: - The branch tag is moved to bottom row - Width percentage is given to make them aligned - Show "..." if commit is longer than two lines. - Align the status icon with the commit message with baseline Before: <img width="1068" alt="截屏2023-03-08 12 23 22" src="https://user-images.githubusercontent.com/17645053/223628534-6b9472cb-29f5-40a3-9714-c5152553049e.png"> After: <img width="756" alt="截屏2023-03-08 13 34 28" src="https://user-images.githubusercontent.com/17645053/223628571-da94698b-0e0a-43e3-ae82-34d8c780e5ba.png"> 2 Right now the actions list's pagination is not working properly because Param is not passed to pagination template, in this PR Param Strings are passed to the pager Before: <img width="1176" alt="截屏2023-03-08 12 23 50" src="https://user-images.githubusercontent.com/17645053/223629207-8b67ce74-2342-4259-bc81-036e37752716.png"> After: <img width="1343" alt="截屏2023-03-08 13 11 54" src="https://user-images.githubusercontent.com/17645053/223629321-4f538f8a-45dc-4d6f-ae60-2c82680ae3e7.png"> 3 A small simplify in `RepoActionView.vue` . Co-authored-by: Hester Gong <hestergong@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Show edit/close/delete button on organization wide repositories (#23388) ↵Giteabot2023-03-121-1/+1
| | | | | | | | | (#23429) Backport #23388 by @yp05327 A part of https://github.com/go-gitea/gitea/pull/22865 Co-authored-by: yp05327 <576951401@qq.com>
* Preserve file size when creating attachments (#23406) (#23426)Giteabot2023-03-124-4/+4
| | | | | | | | | | | | | | Backport #23406 by @baez90 When creating attachments (issue, release, repo) the file size (being part of the multipart file header) is passed through the chain of creating an attachment to ensure the MinIO client can stream the file directly instead of having to read it to memory completely at first. Fixes #23393 Co-authored-by: Peter <peter.kurfer@googlemail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add missing tabs to org projects page (#22705) (#23412)Giteabot2023-03-106-15/+31
| | | | | | | | | | | | | | | | | | | | | Backport #22705 by @yp05327 Fixes https://github.com/go-gitea/gitea/issues/22676 Context Data `IsOrganizationMember` and `IsOrganizationOwner` is used to control the visibility of `people` and `team` tab. https://github.com/go-gitea/gitea/blob/2871ea08096cba15546f357d0ec473734ee9d8be/templates/org/menu.tmpl#L19-L40 And because of the reuse of user projects page, User Context is changed to Organization Context. But the value of `IsOrganizationMember` and `IsOrganizationOwner` are not being given. I reused func `HandleOrgAssignment` to add them to the ctx, but may have some unnecessary variables, idk whether it is ok. I found there is a missing `PageIsViewProjects` at create project page. Co-authored-by: yp05327 <576951401@qq.com>
* Handle OpenID discovery URL errors a little nicer when creating/editing ↵Giteabot2023-03-101-0/+23
| | | | | | | | | | | | | sources (#23397) (#23403) Backport #23397 When there is an error creating a new openIDConnect authentication source try to handle the error a little better. Close #23283 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Rename `canWriteUnit` to `canWriteProjects` (#23386) (#23399)Giteabot2023-03-091-7/+7
| | | | | | | Backport #23386 A part of https://github.com/go-gitea/gitea/pull/22865 Co-authored-by: yp05327 <576951401@qq.com>
* Fix incorrect NotFound conditions in org/projects.go (#23384) (#23395)Giteabot2023-03-091-3/+3
| | | | | | | | | Backport #23384 A part of https://github.com/go-gitea/gitea/pull/22865 user/org project's `RepoID` is always 0, we need to check `OwnerID` Co-authored-by: yp05327 <576951401@qq.com>
* Set `X-Gitea-Debug` header once (#23361) (#23381)Giteabot2023-03-093-3/+3
|
* Fix panic when getting notes by ref (#23372) (#23377)Giteabot2023-03-081-1/+11
| | | | | | | | | | | | | | | | | | Backport #23372 Fix #23357 . Now the `/repos/{owner}/{repo}/git/notes/{sha}` API supports getting notes by a ref or sha (https://try.gitea.io/api/swagger#/repository/repoGetNote). But the `GetNote` func can only accept commit ID. https://github.com/go-gitea/gitea/blob/a12f5757372f751d25f9e5ca1f168f6920ded894/modules/git/notes_nogogit.go#L18 So we need to convert the query parameter to commit ID before calling `GetNote`. Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Refactor `setting.Database.UseXXX` to methods (#23354) (#23356)Giteabot2023-03-073-5/+5
| | | | | | | | | | | | | | | Backport #23354 Replace #23350. Refactor `setting.Database.UseMySQL` to `setting.Database.Type.IsMySQL()`. To avoid mismatching between `Type` and `UseXXX`. This refactor can fix the bug mentioned in #23350, so it should be backported. Co-authored-by: Jason Song <i@wolfogre.com>
* Fix cannot reopen after pushing commits to a closed PR (#23189) (#23324)sillyguodong2023-03-072-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport: #23189 Close: #22784 1. On GH, we can reopen a PR which was closed before after pushing commits. After reopening PR, we can see the commits that were pushed after closing PR in the time line. So the case of [issue](https://github.com/go-gitea/gitea/issues/22784) is a bug which needs to be fixed. 2. After closing a PR and pushing commits, `headBranchSha` is not equal to `sha`(which is the last commit ID string of reference). If the judgement exists, the button of reopen will not display. So, skip the judgement if the status of PR is closed. ![image](https://user-images.githubusercontent.com/33891828/222037529-651fccf9-0bba-433e-b2f0-79c17e0cc812.png) 3. Even if PR is already close, we should still insert comment record into DB when we push commits. So we should still call function `CreatePushPullComment()`. https://github.com/go-gitea/gitea/blob/067b0c2664d127c552ccdfd264257caca4907a77/services/pull/pull.go#L260-L282 So, I add a switch(`includeClosed`) to the `GetUnmergedPullRequestsByHeadInfo` func to control whether the status of PR must be open. In this case, by setting `includeClosed` to `true`, we can query the closed PR. ![image](https://user-images.githubusercontent.com/33891828/222621045-bb80987c-10c5-4eac-aa0c-1fb9c6aefb51.png) 4. In the loop of comments, I use the`latestCloseCommentID` variable to record the last occurrence of the close comment. In the go template, if the status of PR is closed, the comments whose type is `CommentTypePullRequestPush(29)` after `latestCloseCommentID` won't be rendered. ![image](https://user-images.githubusercontent.com/33891828/222058913-c91cf3e3-819b-40c5-8015-654b31eeccff.png) e.g. 1). The initial status of the PR is opened. ![image](https://user-images.githubusercontent.com/33891828/222453617-33c5093e-f712-4cd6-8489-9f87e2075869.png) 2). Then I click the button of `Close`. PR is closed now. ![image](https://user-images.githubusercontent.com/33891828/222453694-25c588a9-c121-4897-9ae5-0b13cf33d20b.png) 3). I try to push a commit to this PR, even though its current status is closed. ![image](https://user-images.githubusercontent.com/33891828/222453916-361678fb-7321-410d-9e37-5a26e8095638.png) But in comments list, this commit do not display.This is as expected :) ![image](https://user-images.githubusercontent.com/33891828/222454169-7617a791-78d2-404e-be5e-77d555f93313.png) 4). Click the `Reopen` button, the commit which is pushed after closing PR display now. ![image](https://user-images.githubusercontent.com/33891828/222454533-897893b6-b96e-4701-b5cb-b1800f382b8f.png) --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix incorrect redirect link of delete org project (#23327) (#23339)Giteabot2023-03-061-1/+1
| | | | | | | | | | Backport #23327 A part of https://github.com/go-gitea/gitea/pull/22865/commits The old code will cause 500 error. Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Fix various bugs for "install" page (#23194) (#23286)v1.19.0-rc1Giteabot2023-03-052-18/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #23194 ## TLDR * Fix the broken page / broken image problem when click "Install" * Fix the Password Hash Algorithm display problem for #22942 * Close #20089 * Close #23183 * Close #23184 ## Details ### The broken page / broken image problem when clicking on "Install" (Redirect failed after install - #23184) Before: when clicking on "install", all new requests will fail, because the server has been restarted. Users just see a broken page with broken images, sometimes the server is not ready but the user would have been redirect to "/user/login" page, then the users see a new broken page (connection refused or something wrong ...) After: only check InstallLock=true for necessary handlers, and sleep for a while before restarting the server, then the browser has enough time to load the "post-install" page. And there is a script to check whether "/user/login" is ready, the user will only be redirected to the login page when the server is ready. ### During new instance setup fill 'Gitea Base URL' with window.location.origin - #20089 If the "app_url" input contains `localhost` (the default value from config), use current window's location href as the `app_url` (aka ROOT_URL) ### Fix the Password Hash Algorithm display problem for "Provide the ability to set password hash algorithm parameters #22942" Before: the UI shows `pbkdf2$50000$50` <details> ![image](https://user-images.githubusercontent.com/2114189/221917143-e1e54798-1698-4fee-a18d-00c48081fc39.png) </details> After: the UI shows `pbkdf2` <details> ![image](https://user-images.githubusercontent.com/2114189/221916999-97a15be8-2ebb-4a01-bf93-dac18e354fcc.png) </details> ### GET data: net::ERR_INVALID_URL #23183 Cause by empty `data:` in `<link rel="manifest" href="data:{{.ManifestData}}">` Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Support sanitising the URL by removing extra slashes in the URL (#21333) ↵Giteabot2023-03-052-2/+103
| | | | | | | | | | | | | | | | | | | | | | | (#23300) Backport #21333 Changes in this PR : Strips incoming request URL of additional slashes (/). For example an input like `https://git.data.coop//halfd/new-website.git` is translated to `https://git.data.coop/halfd/new-website.git` Fixes https://github.com/go-gitea/gitea/issues/20462 Fix #23242 Co-authored-by: Sandeep Bhat <sandyethadka@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <leon@kske.dev>
* Avoid panic caused by broken payload when creating commit status (#23216) ↵Giteabot2023-03-042-8/+16
| | | | | | | | | | | | | | | | | | | | | (#23294) Backport #23216 When creating commit status for Actons jobs, a payload with nil `HeadCommit` will cause panic. Reported at: https://gitea.com/gitea/act_runner/issues/28#issuecomment-732166 Although the `HeadCommit` probably can not be nil after #23215, `CreateCommitStatus` should protect itself, to avoid being broken in the future. In addition, it's enough to print error log instead of returning err when `CreateCommitStatus` failed. Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: delvh <dev.lh@web.de>
* Use correct README link to render the README (#23152) (#23264)Giteabot2023-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Backport #23152 `renderReadmeFile` needs `readmeTreelink` as parameter but gets `treeLink`. The values of them look like as following: `treeLink`: `/{OwnerName}/{RepoName}/src/branch/{BranchName}` `readmeTreelink`: `/{OwnerName}/{RepoName}/src/branch/{BranchName}/{ReadmeFileName}` `path.Dir` in https://github.com/go-gitea/gitea/blob/8540fc45b11eff9a73753ca139f8ea5c38509bf5/routers/web/repo/view.go#L316 should convert `readmeTreelink` into `/{OwnerName}/{RepoName}/src/branch/{BranchName}` instead of the current `/{OwnerName}/{RepoName}/src/branch`. Fixes #23151 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
* Add loading yaml label template files (#22976) (#23232)Giteabot2023-03-015-51/+47
| | | | | | | | | | | | Backport #22976 Extract from #11669 and enhancement to #22585 to support exclusive scoped labels in label templates * Move label template functionality to label module * Fix handling of color codes * Add Advanced label template Co-authored-by: Lauris BH <lauris@nix.lv>
* Avoid too long names for actions (#23162) (#23190)Yarden Shoham2023-02-281-1/+3
| | | | | | | | | Backport #23162 The name of the job or step comes from the workflow file, while the name of the runner comes from its registration. If the strings used for these names are too long, they could cause db issues. Co-authored-by: Jason Song <i@wolfogre.com>
* Remove useless comment in #23114 (#23173) (#23175)Yarden Shoham2023-02-271-1/+0
| | | | | | | | | Backport #23173 The `isAdmin` param is no longer used so the comment should be removed. https://github.com/go-gitea/gitea/blob/d27d36f2f4dd389050e613967ad2a5d02d250acc/routers/web/explore/repo.go#L36-L37 Co-authored-by: Zettat123 <zettat123@gmail.com>
* Return 404 instead of 403 if user can not access the repo (#23155) (#23158)Yarden Shoham2023-02-261-1/+1
| | | | | | | | | | | | | | | | Backport #23155 Fixes https://github.com/go-gitea/gitea/issues/23150 Before: ![image](https://user-images.githubusercontent.com/18380374/221390802-2317c6bc-d163-4def-b68b-6bb297143fe2.png) After: ![image](https://user-images.githubusercontent.com/18380374/221390823-87490351-39c3-4a40-b1d2-11fc5b85fa24.png) Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Redirect to the commit page after applying patch (#23056) (#23127)Yarden Shoham2023-02-241-6/+4
| | | | | | | Backport #23056 Fixes https://github.com/go-gitea/gitea/issues/22621 Co-authored-by: yp05327 <576951401@qq.com>
* Avoid warning for system setting when start up (#23054) (#23116)Yarden Shoham2023-02-242-2/+2
| | | | | | | | | | | | | | Backport #23054 Partially fix #23050 After #22294 merged, it always has a warning log like `cannot get context cache` when starting up. This should not affect any real life but it's annoying. This PR will fix the problem. That means when starting up, getting the system settings will not try from the cache but will read from the database directly. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
* Show empty repos in Admin Repository Management page (#23114) (#23130)Yarden Shoham2023-02-242-21/+23
| | | | | | | | | | | | | | | | | | | | | | Backport #23114 The **Admin Repository Management** page and the **Explore Repository** page both use the `RenderRepoSearch` function. In this function, the `OnlyShowRelevant` search option is `true` when querying repositories for admin page. https://github.com/go-gitea/gitea/blob/edf98a2dc30956c8e04b778bb7f1ce55c14ba963/routers/web/explore/repo.go#L99-L115 Refer to [#19361](https://github.com/go-gitea/gitea/pull/19361/files#diff-8058dfb85557010e0592d586675ec62ce406af7068e6311f39c160deac37f149R497), the repositories with `is_empty=true` will be hidden if `OnlyShowRelevant` is `true`. Administrators should be able to see all repositories. So `OnlyShowRelevant` shouldn't be set to `true` . Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Andrew Thornton <art27@cantab.net>
* Fix commit name in Apply Patch page (#23086) (#23099)Yarden Shoham2023-02-241-0/+3
| | | | | | | | Backport #23086 Fixes https://github.com/go-gitea/gitea/issues/22621#issuecomment-1439309200 Co-authored-by: yp05327 <576951401@qq.com>
* Add force_merge to merge request and fix checking mergable (#23010)Jason Song2023-02-212-8/+23
| | | Fix #23000.
* Add scopes to API to create token and display them (#22989)zeripath2023-02-201-2/+11
| | | | | | | | The API to create tokens is missing the ability to set the required scopes for tokens, and to show them on the API and on the UI. This PR adds this functionality. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)sillyguodong2023-02-201-2/+4
| | | | | | | | | | | | | | | Close: #22910 --- I'm confused about that why does the api (`GET /repos/{owner}/{repo}/pulls/{index}/files`) require caller to pass the parameters `limit` and `page`. In my case, the caller only needs to pass a `skip-to` to paging. This is consistent with the api `GET /{owner}/{repo}/pulls/{index}/files` So, I deleted the code related to `listOptions` --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Get rules by id when editing branch protection rule (#22932)Zettat1232023-02-201-4/+30
| | | | | | | | | | | | | | | | | | | | When users rename an existing branch protection rule, a new rule with the new name will be created and the old rule will still exist. ![image](https://user-images.githubusercontent.com/15528715/219276442-d3c001ad-e693-44ec-9ad2-b33f2666b49b.png) --- ![image](https://user-images.githubusercontent.com/15528715/219276478-547c3b93-b3f1-4292-a1ef-c1b7747fe1bb.png) The reason is that the `SettingsProtectedBranchPost` function only get branch protection rule by name before updating or creating a rule. When the rule name changes, the function cannot find the existing rule so it will create a new rule rather than update the existing rule. To fix the bug, the function should get rule by id first. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Use beforeCommit instead of baseCommit (#22949)Kyle D2023-02-201-6/+5
| | | | | | | | | | | | | | | | | Replaces: https://github.com/go-gitea/gitea/pull/22947 Fixes https://github.com/go-gitea/gitea/issues/22946 Probably related to https://github.com/go-gitea/gitea/issues/19530 Basically, many of the diffs were broken because they were comparing to the base commit, where a 3-dot diff should be comparing to the [last common ancestor](https://matthew-brett.github.io/pydagogue/git_diff_dots.html). This should have an integration test so that we don’t run into this issue again. --------- Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* Refactor the setting to make unit test easier (#22405)Lunny Xiao2023-02-208-25/+27
| | | | | | | | | | | | | | | | | | | | | | Some bugs caused by less unit tests in fundamental packages. This PR refactor `setting` package so that create a unit test will be easier than before. - All `LoadFromXXX` files has been splited as two functions, one is `InitProviderFromXXX` and `LoadCommonSettings`. The first functions will only include the code to create or new a ini file. The second function will load common settings. - It also renames all functions in setting from `newXXXService` to `loadXXXSetting` or `loadXXXFrom` to make the function name less confusing. - Move `XORMLog` to `SQLLog` because it's a better name for that. Maybe we should finally move these `loadXXXSetting` into the `XXXInit` function? Any idea? --------- Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: delvh <dev.lh@web.de>