aboutsummaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Add health check endpoint (#18465)ttys32022-05-044-1/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * chore: add health check endpoint docs: update document about health check fix: fix up Sqlite3 ping. current ping will success even if the db file is missing fix: do not expose privacy information in output field * refactor: remove HealthChecker struct * Added `/api/healthz` to install routes. This was needed for using /api/healthz endpoint in Docker healthchecks, otherwise, Docker would never become healthy if using healthz endpoint and users would not be able to complete the installation of Gitea. * Update modules/cache/cache.go * fine tune * Remove unnecessary test code. Now there are 2 routes for installation (and maybe more in future) Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Marcos de Oliveira <marcossantos@furb.br>
* Use correct context in `routers/web` (#19597)Gusted2022-05-031-3/+3
| | | - Don't use the `APIContext` in the web routers.
* Use for a repo action one database transaction (#19576)65432022-05-034-43/+33
| | | | | ... more context (part of #9307)
* Fix sending empty notifications (#19589)Gusted2022-05-021-1/+1
| | | - Don't send empty notifications on read notifications API.
* Handle the error of a missing blob object fix #19530 (#19552)99rgosse2022-05-021-2/+11
| | | | | | | | | | | | | | | | | | | | | * Handle the error of a missing blob object * Show error in logs * as per @zeripath * Add missing error check * Add missing error check * Update compare.go * Use formal code * Update compare.go Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Remove legacy `+build:` constraint (#19582)wxiaoguang2022-05-024-4/+0
| | | Go 1.17 and later use modern `//go:build` constraints, the old `// +build:` constraints should be removed.
* Federation: return useful statistic information for nodeinfo (#19561)65432022-05-022-5/+39
| | | Add statistic information for total user count, active user count, issue count and comment count for `/nodeinfo`
* add smtp password to install page (#17564)Vladimir Smagin2022-05-021-0/+1
| | | | | | | | * add smtp password to install page * Update routers/install/install.go Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Dont overwrite err with nil & rename PullCheckingFuncs to reflect there ↵65432022-05-021-1/+1
| | | | | | | | | | | usage (#19572) - dont overwrite err with nil unintentionaly - rename CheckPRReadyToMerge to CheckPullBranchProtections - rename prQueue to prPatchCheckerQueue from #9307 Co-authored-by: delvh <dev.lh@web.de>
* Add API to check if team has repo access (#19540)qwerty2872022-05-012-1/+51
| | | | | * Add API to check if team has repo access * Add test case
* Simplify loops to copy (#19569)Gusted2022-05-011-3/+1
| | | - Simplify two loops into `copy` statements.
* Use middleware to open gitRepo (#19559)65432022-04-302-7/+3
|
* Respect DefaultUserIsRestricted system default when creating new user (#19310)Jimmy Praet2022-04-297-39/+52
| | | | | | | | | | | | | | | | | | | * Apply DefaultUserIsRestricted in CreateUser * Enforce system defaults in CreateUser Allow for overwrites with CreateUserOverwriteOptions * Fix compilation errors * Add "restricted" option to create user command * Add "restricted" option to create user admin api * Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed * Revert "Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed" This reverts commit ee95d3e8dc9e9fff4fa66a5111e4d3930280e033.
* Add API to query collaborators permission for a repository (#18761)Florin Hillebrand2022-04-293-3/+68
| | | | | | | | | | | | | | | | | | | | | Targeting #14936, #15332 Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository. ### Checks the repository permissions of a collaborator. `GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission` Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`. ```json { "permission": "admin", "role_name": "admin", "user": {} } ``` Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
* Don't error when branch's commit doesn't exist (#19547)Gusted2022-04-291-2/+8
| | | | | | | | | | * Don't error when branch's commit doesn't exist - If one of the branches no longer exists, don't throw an error, it's possible that the branch was destroyed during the process. Simply skip it and disregard it. - Resolves #19541 * Don't send empty objects * Use more minimal approach
* Add "Allow edits from maintainer" feature (#18002)qwerty2872022-04-2810-32/+95
| | | | | | | | | | | | | | | | | Adds a feature [like GitHub has](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) (step 7). If you create a new PR from a forked repo, you can select (and change later, but only if you are the PR creator/poster) the "Allow edits from maintainers" option. Then users with write access to the base branch get more permissions on this branch: * use the update pull request button * push directly from the command line (`git push`) * edit/delete/upload files via web UI * use related API endpoints You can't merge PRs to this branch with this enabled, you'll need "full" code write permissions. This feature has a pretty big impact on the permission system. I might forgot changing some things or didn't find security vulnerabilities. In this case, please leave a review or comment on this PR. Closes #17728 Co-authored-by: 6543 <6543@obermui.de>
* Better describe what `/repos/{owner}/{repo}/raw/{filepath}` returns on 200 ↵Gusted2022-04-281-1/+1
| | | | | | (#19542) - Set on the description that it returns the raw file content. - Resolves #19514
* more context for models (#19511)65432022-04-2815-54/+56
| | | | | make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
* Update image URL for Discord webhook (#19536)John Olheiser2022-04-271-1/+0
| | | Signed-off-by: jolheiser <john.olheiser@gmail.com>
* When view _Siderbar or _Footer, just display once (#19501)Lunny Xiao2022-04-261-26/+47
| | | Co-authored-by: zeripath <art27@cantab.net>
* Add commit status popup to issuelist (#19375)parnic2022-04-262-5/+7
| | | | | | | | | | This gets the necessary data to the issuelist for it to support a clickable commit status icon which pops up the full list of commit statuses related to the commit. It accomplishes this without any additional queries or fetching as the existing codepath was already doing the necessary work but only returning the "last" status. All methods were wrapped to call the least-filtered version of each function in order to maximize code reuse. Note that I originally left `getLastCommitStatus()` in `pull.go` which called to the new function, but `make lint` complained that it was unused, so I removed it. I would have preferred to keep it, but alas. The only thing I'd still like to do here is force these popups to happen to the right by default instead of the left. I see that the only other place this is popping up right is on view_list.tmpl, but I can't figure out how/why right now. Fixes #18810
* Improve dashboard's repo list performance (#18963)Gusted2022-04-262-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Improve dashboard's repo list performance - Avoid a lot of database lookups for all the repo's, by adding a undocumented "minimal" mode for this specific task, which returns the data that's only needed by this list which doesn't require any database lookups. - Makes fetching these list faster. - Less CPU overhead when a user visits home page. * Refactor javascript code + fix Fork icon - Use async in the function so we can use `await`. - Remove `archivedFilter` check for count, as it doesn't make sense to show the count of repos when you can't even see them(as they are filited away). * Add `count_only` * Remove uncessary code * Improve comment Co-authored-by: delvh <dev.lh@web.de> * Update web_src/js/components/DashboardRepoList.js Co-authored-by: delvh <dev.lh@web.de> * Update web_src/js/components/DashboardRepoList.js Co-authored-by: delvh <dev.lh@web.de> * By default apply minimal mode * Remove `minimal` paramater * Refactor count header * Simplify init Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Refactor readme file renderer (#19502)Lunny Xiao2022-04-261-112/+125
| | | | | * Refactor readme file renderer * improve
* Improve Stopwatch behavior (#18930)Gusted2022-04-252-33/+14
| | | | - Don't send empty stopwatch over and over again, only send once. - Stop interval to update stopwatch's timer when there is no more stopwatch.
* Pass gitRepo down to GetRawDiff, since its used for main repo and wiki (#19461)65432022-04-253-18/+21
| | | | | as per https://github.com/go-gitea/gitea/pull/19449#issuecomment-1105283931 pass gitRepo down to GetRawDiff, since its used for main repo and wiki
* Use queue instead of memory queue in webhook send service (#19390)Lunny Xiao2022-04-252-1/+6
|
* User specific repoID or xorm builder conditions for issue search (#19475)65432022-04-253-13/+9
| | | | | | | | | * extend models.IssuesOptions to have more specific repo filter options * use new options * unrelated refactor * rm RepoIDs
* Mark TemplateLoading error as "UnprocessableEntity" (#19445)Gusted2022-04-221-1/+3
| | | | | - Don't return Internal Server error if the user provide incorrect label template, instead return UnprocessableEntity. - Resolves #19399
* Fix logging of Transfer API (#19456)Gusted2022-04-221-4/+6
| | | | | | - Use the correct fullname's in tracing calls. - Return correct function name in error. Co-authored-by: 6543 <6543@obermui.de>
* RepoAssignment ensure to close before overwrite (#19449)65432022-04-216-43/+38
| | | | | | | * check if GitRepo already open and close if * only run RepoAssignment once * refactor context helper for api to open GitRepo
* Fix DELETE request for non-existent public key (#19443)Gusted2022-04-211-4/+9
| | | | | | - Add a return for the first "block" of errors, which fixes the double error messages. - Add a return for `externallyManaged`. - Resolves #19398
* Don't panic on `ErrEmailInvalid` (#19441)Gusted2022-04-201-3/+10
| | | | | - Don't panic on `ErrEmailInvalid`, this was caused due that we were trying to force `ErrEmailCharIsNotSupported` interface, which panics. - Resolves #19397
* Fix panic in team repos API (#19431)qwerty2872022-04-202-1/+2
| | | | | | | * Fix panic in team repos API * Fix pagination * fmt
* When updating mirror repo intervals by API reschedule next update too (#19429)zeripath2022-04-202-28/+53
| | | | | | | | | When a mirror repo interval is updated by the UI it is rescheduled with that interval however the API does not do this. The API also lacks the enable_prune option. This PR adds this functionality in to the API Edit Repo endpoint. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add Helm Chart registry (#19406)KN4CK3R2022-04-193-1/+212
|
* Use a struct as test options (#19393)Lunny Xiao2022-04-146-6/+18
| | | | | | | * Use a struct as test options * Fix name * Fix test
* Document 409 error returned by repos/migrate api (#19376)Chongyi Zheng2022-04-121-0/+2
| | | | | | | * Document 409 error returned by repos/migrate api * Generate swagger spec Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix middleware function's placements for some `/user/...` (#19377)Gusted2022-04-121-5/+5
| | | | | - Add reqSignIn to `/user/task/{task}` as it specific to a logged in user currently not-logged in user could cause a NPE. - Move `/user/stopwatch` & `/user/search` middleware before the actual function is called, because functions are executed in order and currently hadn't any effect and could as well cause a NPE due to that. - Remove `/user/active` reqSignIn middleware, because when you want to active a account you're not "signed in" so it doesn't make sense to add that middleware.
* Fix panic in teams API when requesting members (#19360)delvh2022-04-111-1/+1
|
* Add logic to switch between source/rendered on Markdown (#19356)Gusted2022-04-101-2/+10
| | | Adds a button to switch between the source blob and the rendered markdown.
* Allow package linking to private repository (#19348)KN4CK3R2022-04-091-1/+2
| | | | | | | * Display private repos too. * lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Move milestone to models/issues/ (#19278)Lunny Xiao2022-04-0810-63/+66
| | | | | | | | | | | * Move milestone to models/issues/ * Fix lint * Fix test * Fix lint * Fix lint
* Refactor CSRF protection modules, make sure CSRF tokens can be up-to-date. ↵wxiaoguang2022-04-082-2/+2
| | | | | | (#19337) Do a refactoring to the CSRF related code, remove most unnecessary functions. Parse the generated token's issue time, regenerate the token every a few minutes.
* Remove dependent on session auth for api/v1 routers (#19321)Lunny Xiao2022-04-085-26/+119
| | | | | | | | | | | * Remove dependent on session auth for api/v1 routers * Remove unnecessary session on API context * remove missed header * fix test * fix missed api/v1
* Never use /api/v1 from Gitea UI Pages (#19318)Lunny Xiao2022-04-0715-96/+719
| | | | | | | | | | | | | Reusing `/api/v1` from Gitea UI Pages have pros and cons. Pros: 1) Less code copy Cons: 1) API/v1 have to support shared session with page requests. 2) You need to consider for each other when you want to change something about api/v1 or page. This PR moves all dependencies to API/v1 from UI Pages. Partially replace #16052
* Package registry changes (#19305)KN4CK3R2022-04-068-24/+41
| | | | | | | | * removed debug logs * fixed SELECT * removed unneeded error type * use common SearchVersions method * remove empty container upload versions * return err
* Remove legacy unmaintained packages, refactor to support change default ↵wxiaoguang2022-04-032-3/+2
| | | | | | | | | | locale (#19308) Remove two unmaintained vendor packages `i18n` and `paginater`. Changes: * Rewrite `i18n` package with a more clear fallback mechanism. Fix an unstable `Tr` behavior, add more tests. * Refactor the legacy `Paginater` to `Paginator`, test cases are kept unchanged. Trivial enhancement (no breaking for end users): * Use the first locale in LANGS setting option as the default, add a log to prevent from surprising users.
* An attempt to sync a non-mirror repo must give 400 (Bad Request) (#19300)Peter Gardfjäll2022-04-011-0/+11
| | | | | | | | * An attempt to sync a non-mirror repo must give 400 (Bad Request) * add missing return statement Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Refactor legacy `unknwon/com` package, improve golangci lint (#19284)wxiaoguang2022-04-012-19/+24
| | | | | | | | The main purpose is to refactor the legacy `unknwon/com` package. 1. Remove most imports of `unknwon/com`, only `util/legacy.go` imports the legacy `unknwon/com` 2. Use golangci's depguard to process denied packages 3. Fix some incorrect values in golangci.yml, eg, the version should be quoted string `"1.18"` 4. Use correctly escaped content for `go-import` and `go-source` meta tags 5. Refactor `com.Expand` to our stable (and the same fast) `vars.Expand`, our `vars.Expand` can still return partially rendered content even if the template is not good (eg: key mistach).
* Skip frontend ROOT_URL check on installation page, remove unnecessary global ↵wxiaoguang2022-04-011-9/+7
| | | | | | var (#19291) Skip `checkAppUrl` message on installation page because the ROOT_URL is not determined yet Move global var `supportedDbTypeNames` into `install.Init` as a local var