summaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Ensure that blob-excerpt links work for wiki (#18587) (#18624)zeripath2022-02-062-1/+29
| | | | | | | | | | | Backport #18587 It appears that the blob-excerpt links do not work on the wiki - likely since their introduction. This PR adds support for the wiki on these links. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Collaborator trust model should trust collaborators (#18539) (#18557)zeripath2022-02-032-2/+2
| | | | | | | | | | | | Backport #18539 There was an unintended regression in #17917 which leads to only repository admin commits being trusted. This PR restores the old logic. Fix #18501 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Prevent panic on prohibited user login with oauth2 (#18562) (#18563)zeripath2022-02-031-1/+1
| | | | | | | | | | | | Backport #18562 There was an unfortunate regression in #17962 where following detection of the UserProhibitLogin error the err is cast to a pointer by mistake. This causes a panic due to an interface error. Fix #18561 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add `GetUserTeams` (#18499) (#18531)zeripath2022-02-022-7/+6
| | | | | | | | | | | | | | | | | | | | | | | Backport #18499 * Correct use `UserID` in `SearchTeams` - Use `UserID` in the `SearchTeams` function, currently it was useless to pass such information. Now it does a INNER statement to `team_user` which obtains UserID -> TeamID data. - Make OrgID optional. - Resolves #18484 * Seperate searching specific user * Add condition back * Use correct struct type Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix OAuth Source Edit Page (#18495) (#18503)zeripath2022-01-312-0/+7
| | | | | | | | | | Backport #18495 * Fix OAuth Source Edit Page to ensure restricted and group settings are set * Also tolerate []interface in the groups Fix #18432 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Only view milestones from current repo (#18414) (#18417)zeripath2022-01-262-3/+3
| | | | | | | | Backport #18414 The endpoint /{username}/{reponame}/milestone/{id} is not currently restricted to the repo. This PR restricts the milestones to those within the repo. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix partial cloning a repo (#18373) (#18377)Gusted2022-01-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | * Fix partial cloning a repo (#18373) - Backport from: #18373 - Backport isn't 1-1, because the frontport had a refactor in that area, which v1.16 doesn't have. * Include diff & use copy * Add partial clone test * patch * Apply suggestions from code review * globalArgs first * avoid copy but make GlobalCMDArgs append first * please linter Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
* Stop trimming preceding and suffixing spaces from editor filenames (#18334)v1.16.0-rc1zeripath2022-01-191-1/+1
| | | | | | | | | | | | | | * Stop trimming preceding and suffixing spaces from editor filenames In #5702 it was decided to trim preceding and suffixed spaces aswell as / from editing file filenames. This was because at this point in time the url-safety of Gitea was much poorer. We can now drop this requirement and file editing should work correctly. Fix #18176 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix incorrect OAuth message (#18332)wxiaoguang2022-01-191-1/+1
| | | | | As the title, Fix #18327
* Fix PR comments UI (#18323)wxiaoguang2022-01-192-9/+13
| | | | | Closes: * Review comment cannot be edited #17768 * Changing PR Comment Resolved State Disables Further Changes #18315
* Use indirect comparison when showing pull requests (#18313)zeripath2022-01-182-6/+6
| | | | | | | | When generating the commits list and number of files changed for PRs and compare we should use "..." always not "..". Fix #18303 Signed-off-by: Andrew Thornton <art27@cantab.net>
* show pull link for agit pull request also (#18235)a10121127962022-01-171-0/+38
|
* Handle missing default branch better in owner/repo/branches page (#18290)zeripath2022-01-161-20/+33
| | | | | | | This PR more nicely handles a missing default branch in owner/repo/branches Fix #18265 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Return nicer error if trying to pull from non-existent user (#18288)zeripath2022-01-161-3/+12
| | | | | | | | | | | * Return nicer error if trying to pull from non-existent user Gitea serv will currently return an 500 if we try to pull from a repository where the owner does not exist. This PR checks for the UserNotExist Error when checking for the user and will return a NotFound error instead. Fix #18225
* Webauthn nits (#18284)zeripath2022-01-152-10/+12
| | | | | | | This contains some additional fixes and small nits related to #17957 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support webauthn (#17957)Lunny Xiao2022-01-1410-281/+322
| | | | | | | Migrate from U2F to Webauthn Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix NPE on try to get tag reference via API (#18245)65432022-01-121-1/+1
| | | | | * fix npe * rm gitRepo from Tag
* Fix various typos (#18219)luzpaz2022-01-103-3/+3
| | | | | Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Show OAuth callback error message (#18185)KN4CK3R2022-01-071-1/+35
| | | | | | | | | | | * Show callback error message. * lint * Use error code to display a message. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add warning for BIDI characters in page renders and in diffs (#17562)zeripath2022-01-074-16/+40
| | | | | | | | | | | | Fix #17514 Given the comments I've adjusted this somewhat. The numbers of characters detected are increased and include things like the use of U+300 to make à instead of à and non-breaking spaces. There is a button which can be used to escape the content to show it. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Gwyneth Morgan <gwymor@tilde.club> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add replay of webhooks. (#18191)KN4CK3R2022-01-052-5/+36
|
* Load EasyMDE/CodeMirror dynamically, remove RequireEasyMDE (#18069)wxiaoguang2022-01-057-19/+0
| | | This PR makes frontend load EasyMDE/CodeMirror dynamically, and removes `RequireEasyMDE`.
* refactoring nits (#18188)65432022-01-051-1/+0
| | | | | | | * no octal for time values * rm artifact from refactoring Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Team permission allow different unit has different permission (#17811)Lunny Xiao2022-01-052-55/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Team permission allow different unit has different permission * Finish the interface and the logic * Fix lint * Fix translation * align center for table cell content * Fix fixture * merge * Fix test * Add deprecated * Improve code * Add tooltip * Fix swagger * Fix newline * Fix tests * Fix tests * Fix test * Fix test * Max permission of external wiki and issues should be read * Move team units with limited max level below units table * Update label and column names * Some improvements * Fix lint * Some improvements * Fix template variables * Add permission docs * improve doc * Fix fixture * Fix bug * Fix some bug * fix * gofumpt * Integration test for migration (#18124) integrations: basic test for Gitea {dump,restore}-repo This is a first step for integration testing of DumpRepository and RestoreRepository. It: runs a Gitea server, dumps a repo via DumpRepository to the filesystem, restores the repo via RestoreRepository from the filesystem, dumps the restored repository to the filesystem, compares the first and second dump and expects them to be identical The verification is trivial and the goal is to add more tests for each topic of the dump. Signed-off-by: Loïc Dachary <loic@dachary.org> * Team permission allow different unit has different permission * Finish the interface and the logic * Fix lint * Fix translation * align center for table cell content * Fix fixture * merge * Fix test * Add deprecated * Improve code * Add tooltip * Fix swagger * Fix newline * Fix tests * Fix tests * Fix test * Fix test * Max permission of external wiki and issues should be read * Move team units with limited max level below units table * Update label and column names * Some improvements * Fix lint * Some improvements * Fix template variables * Add permission docs * improve doc * Fix fixture * Fix bug * Fix some bug * Fix bug Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Aravinth Manivannan <realaravinth@batsense.net>
* Don't delete branch if other PRs with this branch are open (#18164)a10121127962022-01-033-1/+46
| | | | | fix #18149 Signed-off-by: a1012112796 <1012112796@qq.com>
* Remove unused route "/tasks/trigger" (#18160)Gusted2022-01-033-66/+0
| | | ref: https://github.com/go-gitea/gitea/pull/18160#issuecomment-1004091325
* Refactor auth package (#17962)Lunny Xiao2022-01-0225-2245/+2372
|
* Unify and simplify TrN for i18n (#18141)wxiaoguang2022-01-023-17/+4
| | | | | Refer: https://github.com/go-gitea/gitea/pull/18135#issuecomment-1003246099 Now we have a unique and simple `TrN`, and make the fix of PR #18135 also use the better `TrN` logic.
* Use correct user when determining max repo limits for error messages (#18153)Gusted2022-01-023-3/+3
| | | - Use the correct user(`owner` instead of `ctx.User`) to get the maxCreationLimit.
* Add API to get issue/pull comments and events (timeline) (#17403)qwerty2872022-01-013-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add API to get issue/pull comments and events (timeline) Adds an API to get both comments and events in one endpoint with all required data. Closes go-gitea/gitea#13250 * Fix swagger * Don't show code comments (use review api instead) * fmt * Fix comment * Time -> TrackedTime * Use var directly * Add logger * Fix lint * Fix test * Add comments * fmt * [test] get issue directly by ID * Update test * Add description for changed refs * Fix build issues + lint * Fix build * Use string enums * Update swagger * Support `page` and `limit` params * fmt + swagger * Use global slices Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Allow admin to associate missing LFS objects for repositories (#18143)wxiaoguang2022-01-011-10/+18
| | | | | | | This PR reworked the Find pointer files feature in Settings -> LFS page. When a LFS object is missing from database but exists in LFS content store, admin can associate it to the repository by clicking the Associate button. This PR is not perfect (because the LFS module itself should be improved too), it's just a nice-to-have feature to help users recover their LFS repositories (eg: database was lost / table was truncated)
* Use correct translation key (#18135)Gusted2021-12-313-3/+22
| | | | | - Resolves #18122 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix wrong redirect on org labels (#18128)KN4CK3R2021-12-301-1/+1
|
* Removed unused method. (#18129)KN4CK3R2021-12-301-36/+0
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Removed unused endpoint. (#18127)KN4CK3R2021-12-292-15/+0
|
* Use conditions but not repo ids as query condition (#16839)Lunny Xiao2021-12-291-156/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use conditions but not repo ids as query condition * Improve the performance of pulls/issue * Remove duplicated code * fix lint * Fix bug * Fix stats * More fixes * Fix build * Fix lint * Fix test * Fix build * Adjust the logic * Merge * Fix conflicts * improve the performance * Add comments for the query conditions functions * Some improvements
* Instead of using routerCtx just escape the url before routing (#18086)zeripath2021-12-252-5/+3
| | | | | | | | | | | | | | | | A consequence of forcibly setting the RoutePath to the escaped url is that the auto routing to endpoints without terminal slashes fails (Causing #18060.) This failure raises the possibility that forcibly setting the RoutePath causes other unexpected behaviors too. Therefore, instead we should simply pre-escape the URL in the process registering handler. Then the request URL will be properly escaped for all the following calls. Fix #17938 Fix #18060 Replace #18062 Replace #17997 Signed-off-by: Andrew Thornton <art27@cantab.net>
* When the git repository on storage is changed, the repository modal should ↵wxiaoguang2021-12-241-2/+24
| | | | | | | | | | also be updated (#18088) User would keep seeing an empty repo if: * An error occurs during the first git pushing/receiving * A user replaces the Gitea's empty repository manually Fix: when a user is viewing the repository web page, if the repoModal.IsEmpty is true, we check the git repository again to detect whether it is really empty. However: the IsEmpty flag is deeply broken and should be removed. For example it's possible for a repository to be non-empty by that flag but still 500 because there are no branches - only tags -or the default branch is non-extant as it has been 0-pushed.
* - name: new parameter in CreateForkOption to give the forked repository (#18066)Aravinth Manivannan2021-12-241-2/+15
| | | | | | | | | | | a custom name, intended to be used when there's a name conflict - When a fork request results in a name conflict, HTTP 409: Conflict is returned instead of 500 - API documentation for the above mentioned changes Signed-off-by: realaravinth <realaravinth@batsense.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* When attempting to subscribe other user to issue report why access denied ↵zeripath2021-12-241-1/+2
| | | | | | | | | (#18091) Fix #18090 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Improve interface when comparing a branch which has created a pull request ↵Lunny Xiao2021-12-241-0/+4
| | | | | | | | (#17911) * Improve interface when comparing a branch which has created a pull request * Take the note back
* Add API to manage repo tranfers (#17963)qwerty2872021-12-232-0/+104
|
* Do not read or write git reference files directly (#18079)zeripath2021-12-231-2/+2
| | | | | | | | | | Git will and can pack references into packfiles and therefore if you write/read the files directly you will get false results. Instead you should use update-ref and show-ref. To that end I have created three new functions in git/repo_commit.go that will do this correctly. Related #17191 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Migrated Repository will show modifications when possible (#17191)99rgosse2021-12-231-1/+39
| | | | * Read patches to get history
* Add NotFound handler (#18062)zeripath2021-12-221-0/+10
| | | | | | | | | | | | | PR #17997 means that urls with terminal '/' are no longer immediately mapped to the url without a terminal slash. However, it has revealed that the NotFound handler appears to have been lost. This PR adds back in a NotFound handler that simply redirects to a path without the terminal slash or runs the NotFound handler. Fix #18060 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add API to get file commit history (#17652)qwerty2872021-12-221-24/+55
| | | | | | Adds an API endpoint `api/v1/repos/{owner}/{repo}/git/history/{filepath}` to get the commits affecting the given file or directory. Closes https://github.com/go-gitea/gitea/issues/16206 and closes https://github.com/go-gitea/gitea/issues/16703
* Ensure that git repository is closed before transfer (#18049)zeripath2021-12-212-0/+10
| | | | | | | | | | Repository Transfer requires that the repository directory is renamed - which is not possible on Windows if the git repository is open. Fix #17885 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move POST /{username}/action/{action} to simply POST /{username} (#18045)zeripath2021-12-202-5/+3
| | | | | | | | | | The current code unfortunately requires that `action` be a reserved repository name as it prevents posts to change the settings for action repositories. However, we can simply change action handler to work on POST /{username} instead. Fix #18037 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Reset Session ID on login (#18018)zeripath2021-12-202-5/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Reset Session ID on login When logging in the SessionID should be reset and the session cleaned up. Signed-off-by: Andrew Thornton <art27@cantab.net> * with new session.RegenerateID function Signed-off-by: Andrew Thornton <art27@cantab.net> * update go-chi/session Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure that session id is changed after oauth data is set and between account linking pages too Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per review Signed-off-by: Andrew Thornton <art27@cantab.net>
* Simplify parameter types (#18006)Gusted2021-12-206-8/+8
| | | Remove repeated type declarations in function definitions.