summaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Add mimetype mapping settings (#15133)Adam Szatyin2021-05-101-0/+8
| | | | | | | | | | | | | * Fix APK's Content-Type header * Fix case sensitive comparison * Add custom mime type mapping for downloadable files * Add documentation for MIME type mapping * Rename download.mimetype.mapping configuration to repository.mimetype_mapping Co-authored-by: zeripath <art27@cantab.net>
* don't record error when request a non-exist user (#15819)Lunny Xiao2021-05-101-1/+1
| | | | | | | | | | * don't record error when request a non-exist user * Update routers/repo/http.go Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix goth user infer bug (#15821)Lunny Xiao2021-05-101-5/+10
|
* Move restore repo to internal router and invoke from command to avoid open ↵Lunny Xiao2021-05-102-0/+52
| | | | | | | | | | | the same db file or queues files (#15790) * Move restore repo to internal router and invoke from command to avoid open the same db file or queues files * Follow @zeripath's review * set no timeout for resotre repo private request * make restore repo cancelable
* Use single shared random string generation function (#15741)silverwind2021-05-101-2/+2
| | | | | | | | | | | | | | | | | | * Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: #15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
* On open repository open common cat file batch and batch-check (#15667)zeripath2021-05-101-0/+12
| | | | | | | Use common git cat-file --batch and git cat-file --batch-check to significantly reduce calls to git. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Return go-get info on subdirs (#15642)zeripath2021-05-092-65/+88
| | | | | | | | | | This PR is an alternative to #15628 and makes the go get handler a handler. Fix #15625 Close #15628 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Fix incorrect asset URL (#15805)silverwind2021-05-091-1/+1
| | | | Fixes another regression from https://github.com/go-gitea/gitea/pull/15219.
* Allow only internal registration (#15795)65432021-05-092-3/+11
| | | | | * Add ALLOW_ONLY_INTERNAL_REGISTRATION into settings * OpenID respect setting too
* Ensure that ctx.Written is checked after issues(...) calls (#15797)zeripath2021-05-091-0/+3
| | | | | Fix issue noted in #15783 Signed-off-by: Andrew Thornton <art27@cantab.net>
* [API] make change repo settings work on empty repos (#15778)65432021-05-082-9/+9
| | | | | * API: Fix #15602 * Add TEST
* Add selecting tags on the compare page (#15723)Jonathan Tran2021-05-071-16/+37
| | | | | | | | | | | * Add selecting tags on the compare page * Remove unused condition and change indentation * Fix tag tab in dropdown to be black * Add compare tag integration test Co-authored-by: Jonathan Tran <jon@allspice.io>
* Feature/oauth userinfo (#15721)N. L. H2021-05-062-0/+74
| | | | | | | | | | | | | | | | | | | | | | * Implemented userinfo #8534 * Make lint happy * Add userinfo endpoint to openid-configuration * Give an error when uid equals 0 * Implemented BearerTokenErrorCode handling * instead of ctx.error use ctx.json so that clients parse error and error_description correctly * Removed unneeded if statement * Use switch instead of subsequent if statements Have a default for unknown errorcodes. Co-authored-by: Nils Hillmann <hillmann@nlh-software.de> Co-authored-by: nlhsoftware <nlhsoftware@noreply.localhost>
* fix some ui bug about draft release (#15137)a10121127962021-05-062-10/+18
| | | | | | | | | | | | | | | | | | | * fix some ui bug about draft release - should not show draft release in tag list because it will't create real tag - still show draft release without tag and commit message for draft release instead of 404 error - remove tag load for attachement links because it's useless Signed-off-by: a1012112796 <1012112796@qq.com> * add test code * fix test That's because has added a new release in relaese test database. * fix dropdown link for draft release
* Fix broken avatars since #15301 (#15731)zeripath2021-05-051-2/+2
| | | | | | | There was a missing * from the avatars routes in #15301. Fix #15727 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Use route rather than use thus reducing the number of stack frames (#15301)zeripath2021-05-042-46/+51
| | | | | | | | | | | | Since the move to Chi the number of stack frames has proliferated somewhat catastrophically and we're up to 96 frames with multiple tests of the url outside of a trie which is inefficient. This PR reduces the number of stack frames by 6 through careful use of Route, moves Captcha into its own router so that it only fires on Captcha routes, similarly for avatars and repo-avatars. The robots.txt, / and apple-touch-icon.png are moved out of requiring Contexter. It moves access logger higher in the stack frame because there is no reason why it can't be higher. Extract from #15186 Contains #15292
* Add compare tag dropdown to releases page (#15695)Jonathan Tran2021-05-031-0/+12
| | | | | | | | | | * Add compare tag dropdown to releases page * Change defaults to be more intuitive and remove unneeded option * Fix to select branch on releases page Co-authored-by: Jonathan Tran <jon@allspice.io> Co-authored-by: Kyle D <kdumontnu@gmail.com>
* Addition to (Add Location, Website and Description to API #15675) (#15690)KN4CK3R2021-05-021-0/+3
| | | | | | | | | * Use same name as other structs. * Sync with normal forms. * Edit description with API. * Workaround for nil value.
* Fixed several activation bugs (#15473)KN4CK3R2021-04-302-6/+38
| | | | | | | | | | | * Removed unneeded form tag. * Fixed typo. * Fixed NPE. * Use better error page. * Splitted GET and POST.
* Unified link creation. (#15619)KN4CK3R2021-04-306-11/+10
|
* Added missing prefix on install route. (#15677)KN4CK3R2021-04-301-0/+1
| | | Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Fix readme render bug (#15649)Lunny Xiao2021-04-281-0/+1
|
* add `/assets` as root dir of public files (#15219)a10121127962021-04-282-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * add `/assets` as root dir of public files Signed-off-by: a1012112796 <1012112796@qq.com> * move serviceworker.js * make fmt * fix some link * fix test * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Attachment support repository route (#15580)Lunny Xiao2021-04-231-0/+1
|
* Refactor renders (#15175)Lunny Xiao2021-04-1913-76/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
* add well-known config for OIDC (#15355)techknowlogick2021-04-152-0/+11
| | | | | | | | | | | | | | * add well-known config for OIDC * spacing per feedback * Update oidc_wellknown.tmpl * add id_token * Update oidc_wellknown.tmpl Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix bug clone wiki (#15499)Lunny Xiao2021-04-151-0/+10
| | | | | | | Fix #15494 Co-authored-by: Lauris BH <lauris@nix.lv>
* Performance improvement for list pull requests (#15447)Lunny Xiao2021-04-152-17/+12
|
* Disable Stars config option (#14653)Kyle D2021-04-152-0/+22
| | | | | | | * Add config option to disable stars * Replace "stars" with watched in user profile * Add documentation
* fix wrong file link in code search page (#15466)a10121127962021-04-141-2/+1
| | | | | | | | | | | | | | | | | | in previous the grenrated link is ``testg/testrepo/src/commit/....`` which is not right. the right version is ``/testg/testrepo/.......`` (start wiht ``/``) or ``http://127.0.0.1:3000/xxxxx`` (full link) to make it hase same result with explore page I choose the secound style. fix #15438 Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: 6543 <6543@obermui.de>
* OAuth2 auto-register (#5123)Martin Michaelis2021-04-142-132/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactored handleOAuth2SignIn in routers/user/auth.go The function handleOAuth2SignIn was called twice but some code path could only be reached by one of the invocations. Moved the unnecessary code path out of handleOAuth2SignIn. * Refactored user creation There was common code to create a user and display the correct error message. And after the creation the only user should be an admin and if enabled a confirmation email should be sent. This common code is now abstracted into two functions and a helper function to call both. * Added auto-register for OAuth2 users If enabled new OAuth2 users will be registered with their OAuth2 details. The UserID, Name and Email fields from the gothUser are used. Therefore the OpenID Connect provider needs additional scopes to return the coresponding claims. * Added error for missing fields in OAuth2 response * Linking and auto linking on oauth2 registration * Set default username source to nickname * Add automatic oauth2 scopes for github and google * Add hint to change the openid connect scopes if fields are missing * Extend info about auto linking security risk Co-authored-by: Viktor Kuzmin <kvaster@gmail.com> Signed-off-by: Martin Michaelis <code@mgjm.de>
* Prevent NPE on avatar direct rendering if federated avatars disabled (#15434)zeripath2021-04-121-2/+17
| | | | | | | | | | #13649 assumed that direct avatar urls would always be libravatar urls - this leads to NPEs if federated avatar service is disabled. Fix #15421 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add ETag header (#15370)KN4CK3R2021-04-122-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add ETag header. * Comply with RFC 7232. * Moved logic into httpcache.go * Changed name. * Lint * Implemented If-None-Match list. * Fixed missing header on * * Removed weak etag support. * Removed * support. * Added unit test. * Lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* add some reponse status on api docs (#15399)a10121127962021-04-111-0/+12
| | | | | | Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
* Fix delete nonexist oauth application 500 and prevent deadlock (#15384)Lunny Xiao2021-04-101-1/+5
| | | | | | | | | | | | | | | | | | * Fix delete nonexist oauth application 500 * Fix test * Close the session Signed-off-by: Andrew Thornton <art27@cantab.net> * Update integrations/api_oauth2_apps_test.go * Fix more missed sess.Close * Remove unnecessary blank line Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* rsponse 404 when delete not exist email (#15383)a10121127962021-04-101-0/+6
| | | | | fix #15357 Signed-off-by: a1012112796 <1012112796@qq.com>
* Turn RepoRef and RepoAssignment back into func(*Context) (#15372)zeripath2021-04-091-10/+10
| | | | | Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move FCGI req.URL.Path fix-up to the FCGI listener (#15292)zeripath2021-04-091-9/+0
| | | | | | | Simplify the web.go FCGI path by moving the req.URL.Path fix-up to listener Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Code Formats, Nits & Unused Func/Var deletions (#15286)65432021-04-099-21/+15
| | | | | | | | | | | | | | | * _ to unused func options * rm useless brakets * rm trifial non used models functions * rm dead code * rm dead global vars * fix routers/api/v1/repo/issue.go * dont overload import module
* Add LFS Migration and Mirror (#14726)KN4CK3R2021-04-087-266/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implemented LFS client. * Implemented scanning for pointer files. * Implemented downloading of lfs files. * Moved model-dependent code into services. * Removed models dependency. Added TryReadPointerFromBuffer. * Migrated code from service to module. * Centralised storage creation. * Removed dependency from models. * Moved ContentStore into modules. * Share structs between server and client. * Moved method to services. * Implemented lfs download on clone. * Implemented LFS sync on clone and mirror update. * Added form fields. * Updated templates. * Fixed condition. * Use alternate endpoint. * Added missing methods. * Fixed typo and make linter happy. * Detached pointer parser from gogit dependency. * Fixed TestGetLFSRange test. * Added context to support cancellation. * Use ReadFull to probably read more data. * Removed duplicated code from models. * Moved scan implementation into pointer_scanner_nogogit. * Changed method name. * Added comments. * Added more/specific log/error messages. * Embedded lfs.Pointer into models.LFSMetaObject. * Moved code from models to module. * Moved code from models to module. * Moved code from models to module. * Reduced pointer usage. * Embedded type. * Use promoted fields. * Fixed unexpected eof. * Added unit tests. * Implemented migration of local file paths. * Show an error on invalid LFS endpoints. * Hide settings if not used. * Added LFS info to mirror struct. * Fixed comment. * Check LFS endpoint. * Manage LFS settings from mirror page. * Fixed selector. * Adjusted selector. * Added more tests. * Added local filesystem migration test. * Fixed typo. * Reset settings. * Added special windows path handling. * Added unit test for HTTPClient. * Added unit test for BasicTransferAdapter. * Moved into util package. * Test if LFS endpoint is allowed. * Added support for git:// * Just use a static placeholder as the displayed url may be invalid. * Reverted to original code. * Added "Advanced Settings". * Updated wording. * Added discovery info link. * Implemented suggestion. * Fixed missing format parameter. * Added Pointer.IsValid(). * Always remove model on error. * Added suggestions. * Use channel instead of array. * Update routers/repo/migrate.go * fmt Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
* Add dashboard milestone search and repo milestone search by name (#14866)Roger Luo2021-04-082-5/+15
| | | | | Feature for issue #13845: - Add milestones search by name on dashboard milestones page. - Add milestones search by name on repo issue/milestones page.
* Fix CanCreateRepo check (#15311)John Olheiser2021-04-071-0/+3
| | | Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Move modules/forms to services/forms (#15305)zeripath2021-04-0648-327/+327
| | | | | | | | | | | Forms are dependent on models and therefore should be in services. This PR also removes the old auth. aliasing Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* [refactor] replace int with httpStatusCodes (#15282)65432021-04-0560-402/+462
| | | | | | | | | | | * replace "200" (int) with "http.StatusOK" (const) * ctx.Error & ctx.HTML * ctx.JSON Part1 * ctx.JSON Part2 * ctx.JSON Part3
* Drop the event source if we are unauthorized (#15275)zeripath2021-04-041-2/+2
| | | | | | | | | A previous commit that sent unauthorized if the user is unauthorized simply leads to the repeated reopening of the eventsource. # This PR changes the event returned to tell the client to close the eventsource and thus prevents the repeated reopening. Signed-off-by: Andrew Thornton <art27@cantab.net>
* [refactor] mailer service (#15072)65432021-04-024-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Unexport SendUserMail * Instead of "[]*models.User" or "[]string" lists infent "[]*MailRecipient" for mailer * adopt * code format * TODOs for "i18n" * clean * no fallback for lang -> just use english * lint * exec testComposeIssueCommentMessage per lang and use only emails * rm MailRecipient * Dont reload from users from db if you alredy have in ram * nits * minimize diff Signed-off-by: 6543 <6543@obermui.de> * localize subjects * linter ... * Tr extend * start tmpl edit ... * Apply suggestions from code review * use translation.Locale * improve mailIssueCommentBatch Signed-off-by: Andrew Thornton <art27@cantab.net> * add i18n to datas Signed-off-by: Andrew Thornton <art27@cantab.net> * a comment Co-authored-by: Andrew Thornton <art27@cantab.net>
* response 404 for diff/patch of a commit that not exist (#15221)a10121127962021-04-011-0/+6
| | | | | | | | | | | | | | | | * response 404 for diff/patch of a commit that not exist fix #15217 Signed-off-by: a1012112796 <1012112796@qq.com> * Update routers/repo/commit.go Co-authored-by: silverwind <me@silverwind.io> * use ctx.NotFound() Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
* Add Tabular Diff for CSV files (#14661)KN4CK3R2021-03-293-8/+87
| | | | | | | | | | | | | | | | | | | | | | | Implements request #14320 The rendering of CSV files does match the diff style. * Moved CSV logic into base package. * Added method to create a tabular diff. * Added CSV compare context. * Added CSV diff template. * Use new table style in CSV markup. * Added file size limit for CSV rendering. * Display CSV parser errors in diff. * Lazy read single file. * Lazy read rows for full diff. * Added unit tests for various CSV changes.
* Improve /api/v1/repos/issues/search by just getting repo ids (#15179)zeripath2021-03-291-20/+4
| | | | | | | | | | | | | | /api/v1/repos/issues/search is a highly inefficient search which is unfortunately the basis for our dependency searching algorithm. In particular it currently loads all of the repositories and their owners and their primary coding language all of which is immediately thrown away. This PR makes one simple change - just get the IDs. Related #14560 Related #12827 Signed-off-by: Andrew Thornton <art27@cantab.net>
* should run RetrieveRepoMetas() for empty pr (#15187)a10121127962021-03-291-3/+7
| | | Signed-off-by: a1012112796 <1012112796@qq.com>