aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo.go
Commit message (Collapse)AuthorAgeFilesLines
* Fix issues count bug (#21557)Lunny Xiao2022-10-251-9/+4
| | | | | fix #19349 , #19505 Co-authored-by: delvh <dev.lh@web.de>
* Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)delvh2022-10-241-10/+10
| | | | | | | | | Found using `find . -type f -name '*.go' -print -exec vim {} -c ':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;` Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Decouple HookTask from Repository (#17940)KN4CK3R2022-10-211-1/+5
| | | | | | | | | | | | | At the moment a repository reference is needed for webhooks. With the upcoming package PR we need to send webhooks without a repository reference. For example a package is uploaded to an organization. In theory this enables the usage of webhooks for future user actions. This PR removes the repository id from `HookTask` and changes how the hooks are processed (see `services/webhook/deliver.go`). In a follow up PR I want to remove the usage of the `UniqueQueue´ and replace it with a normal queue because there is no reason to be unique. Co-authored-by: 6543 <6543@obermui.de>
* Add system setting table with cache and also add cache supports for user ↵Lunny Xiao2022-10-171-9/+14
| | | | setting (#18058)
* Refactor GetNextResourceIndex to make it work properly with transaction (#21469)wxiaoguang2022-10-161-1/+1
| | | | | | | | | | | | | | Related: * #21362 This PR uses a general and stable method to generate resource index (eg: Issue Index, PR Index) If the code looks good, I can add more tests ps: please skip the diff, only have a look at the new code. It's entirely re-written. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add Num{Issues,Pulls} stats checks (#21404)Gusted2022-10-111-1/+13
| | | | | | | | - Currently `repository.Num{Issues,Pulls}` weren't checked and could become out-of-consistency. Adds these two checks to `CheckRepoStats`. - Fix incorrect SQL query for `repository.NumClosedPulls`, the check should be for `repo_num_pulls`. - Reference: https://codeberg.org/Codeberg/Community/issues/696
* fix hard-coded timeout and error panic in API archive download endpoint (#20925)Peter Gardfjäll2022-08-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix hard-coded timeout and error panic in API archive download endpoint This commit updates the `GET /api/v1/repos/{owner}/{repo}/archive/{archive}` endpoint which prior to this PR had a couple of issues. 1. The endpoint had a hard-coded 20s timeout for the archiver to complete after which a 500 (Internal Server Error) was returned to client. For a scripted API client there was no clear way of telling that the operation timed out and that it should retry. 2. Whenever the timeout _did occur_, the code used to panic. This was caused by the API endpoint "delegating" to the same call path as the web, which uses a slightly different way of reporting errors (HTML rather than JSON for example). More specifically, `api/v1/repo/file.go#GetArchive` just called through to `web/repo/repo.go#Download`, which expects the `Context` to have a `Render` field set, but which is `nil` for API calls. Hence, a `nil` pointer error. The code addresses (1) by dropping the hard-coded timeout. Instead, any timeout/cancelation on the incoming `Context` is used. The code addresses (2) by updating the API endpoint to use a separate call path for the API-triggered archive download. This avoids producing HTML-errors on errors (it now produces JSON errors). Signed-off-by: Peter Gardfjäll <peter.gardfjall.work@gmail.com>
* Move some files into models' sub packages (#20262)Lunny Xiao2022-08-251-164/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
* Add option to purge users (#18064)zeripath2022-07-141-10/+2
| | | | | | | Add the ability to purge users when deleting them. Close #15588 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add more linters to improve code readability (#19989)Wim2022-06-201-1/+1
| | | | | | | | | | Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
* Move issues related files into models/issues (#19931)Lunny Xiao2022-06-131-13/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Move access and repo permission to models/perm/access * fix test * fix git test * Move functions sequence * Some improvements per @KN4CK3R and @delvh * Move issues related code to models/issues * Move some issues related sub package * Merge * Fix test * Fix test * Fix test * Fix test * Rename some files
* Move some code into models/git (#19879)Lunny Xiao2022-06-121-11/+9
| | | | | | | | | | | | | | | | | | | * Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
* Move some repository related code into sub package (#19711)Lunny Xiao2022-06-061-396/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move some repository related code into sub package * Move more repository functions out of models * Fix lint * Some performance optimization for webhooks and others * some refactors * Fix lint * Fix * Update modules/repository/delete.go Co-authored-by: delvh <dev.lh@web.de> * Fix test * Merge * Fix test * Fix test * Fix test * Fix test Co-authored-by: delvh <dev.lh@web.de>
* improvement some release related code (#19867)Lunny Xiao2022-06-031-1/+1
|
* feat: add DEFAULT_MERGE_STYLE to `repository.pull-request` section for repo ↵ttys32022-06-021-1/+1
| | | | init (#19751)
* Move almost all functions' parameter db.Engine to context.Context (#19748)Lunny Xiao2022-05-201-33/+24
| | | | * Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
* Move access and repo permission to models/perm/access (#19350)Lunny Xiao2022-05-111-41/+10
| | | | | * Move access and repo permission to models/perm/access * Remove unnecessary code
* Move some helper files out of models (#19355)Lunny Xiao2022-05-081-11/+4
| | | | | | | * Move some helper files out of models * Some improvements Co-authored-by: delvh <dev.lh@web.de>
* Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649)65432022-05-081-1/+5
| | | | | | * delete pullautomerges on repo/user deletion * delete reviewstates on repo/user deletion * optimize automerhe code * add index to reviewstate
* Prevent NPE when checking repo units if the user is nil (#19625)zeripath2022-05-061-1/+1
| | | | | | | | | CheckRepoUnitUser should tolerate nil users. Fix #19613 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Use for a repo action one database transaction (#19576)65432022-05-031-3/+3
| | | | | ... more context (part of #9307)
* more context for models (#19511)65432022-04-281-3/+3
| | | | | make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
* Move milestone to models/issues/ (#19278)Lunny Xiao2022-04-081-7/+4
| | | | | | | | | | | * Move milestone to models/issues/ * Fix lint * Fix test * Fix lint * Fix lint
* Make git.OpenRepository accept Context (#19260)65432022-03-301-6/+6
| | | | | * OpenRepositoryCtx -> OpenRepository * OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
* Move project files into models/project sub package (#17704)Lunny Xiao2022-03-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Move project files into models/project sub package * Fix test * Fix test * Fix test * Fix build * Fix test * Fix template bug * Fix bug * Fix lint * Fix test * Fix import * Improve codes Co-authored-by: 6543 <6543@obermui.de>
* Move init repository related functions to modules (#19159)Lunny Xiao2022-03-291-112/+2
| | | | | | | | | * Move init repository related functions to modules * Fix lint * Use ctx but db.DefaultContext Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move organization related structs into sub package (#18518)Lunny Xiao2022-03-291-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move organization related structs into sub package * Fix test * Fix lint * Move more functions into sub packages * Fix bug * Fix test * Update models/organization/team_repo.go Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> * Fix fmt * Follow suggestion from @Gusted * Fix test * Fix test * Fix bug * Use ctx but db.DefaultContext on routers * Fix bug * Fix bug * fix bug * Update models/organization/team_user.go * Fix bug Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* use xorm builder for models.getReviewers() (#19033)65432022-03-101-34/+28
| | | | | * xorm builder * dedup code
* Allow users to self-request a PR review (#19030)Norwin2022-03-081-4/+12
| | | | | | | | | | | The review request feature was added in https://github.com/go-gitea/gitea/pull/10756, where the doer got explicitly excluded from available reviewers. I don't see a functionality or security related reason to forbid this case. As shown by GitHubs implementation, it may be useful to self-request a review, to be reminded oneselves about reviewing, while communicating to team mates that a review is missing. Co-authored-by: delvh <dev.lh@web.de>
* Fix potential assignee query for repo (#18994)Otto Richter (fnetX)2022-03-041-1/+1
| | | | | | | | | | | * Fix potential assignee query for repo * Add tests for `GetRepoAssignees` - As per https://github.com/go-gitea/gitea/pull/18994#issuecomment-1058506640 Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Add config option to disable "Update branch by rebase" (#18745)Jimmy Praet2022-03-041-1/+1
|
* fix & refactor (#18973)65432022-03-031-10/+10
| | | Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Don't clean up hardcoded `tmp` (#18983)KN4CK3R2022-03-021-2/+2
| | | | | * Don't clean up hardcoded `tmp`. * Fixed import.
* Update assignees check to include any writing team and change org sidebar ↵zeripath2022-02-231-11/+40
| | | | | | | | | | | | (#18680) Following the merging of #17811 teams can now have differing write and readonly permissions, however the assignee list will not include teams which have mixed perms. Further the org sidebar is no longer helpful as it can't describe these mixed permissions situations. Fix #18572 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move deletebeans into models/db (#18781)Lunny Xiao2022-02-171-1/+1
|
* format with gofumpt (#18184)65432022-01-201-4/+4
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Fix CheckRepoStats and reuse it during migration (#18264)Aravinth Manivannan2022-01-171-63/+159
| | | | | | | | | | | | | | | | | | | The CheckRepoStats function missed the following counters: - label num_closed_issues & num_closed_pulls - milestone num_closed_issues & num_closed_pulls The update SQL statements for updating the repository num_closed_issues & num_closed_pulls fields were repeated in three functions (repo.CheckRepoStats, migrate.insertIssues and models.Issue.updateClosedNum) and were moved to a single helper. The UpdateRepoStats is implemented and called in the Finish migration method so that it happens immediately instead of wating for the CheckRepoStats to run. Signed-off-by: Loïc Dachary loic@dachary.org --- [source](https://lab.forgefriends.org/forgefriends/forgefriends/-/merge_requests/34)
* Fix various typos (#18219)luzpaz2022-01-101-1/+1
| | | | | Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix performance regression when user has many organization (#18125)Lunny Xiao2021-12-301-12/+18
|
* Improve behavior of "Fork" button (#17288)qwerty2872021-12-131-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Improbe behaviour of fork button * Apply suggestions from code review * Remove old lines * Apply suggestions * Fix test * Remove unnecessary or * Update templates/repo/header.tmpl Co-authored-by: silverwind <me@silverwind.io> * Add comment * Fix situation if you can't fork but don't have forks * Fix lint * Apply changes from #17783 * fmt * fmt * Apply tweaks Co-authored by: silverwind <me@silverwind.io> * Rm dupl css * Fix build Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Some repository refactors (#17950)Lunny Xiao2021-12-121-287/+16
| | | | | | | | | * some repository refactors * remove unnecessary code * Fix test * Remove unnecessary banner
* Move keys to models/asymkey (#17917)Lunny Xiao2021-12-101-2/+59
| | | | | | | | | | | | | | | | | | | * Move keys to models/keys * Rename models/keys -> models/asymkey * change the missed package name * Fix package alias * Fix test * Fix docs * Fix test * Fix test * merge
* Move repository model into models/repo (#17933)Lunny Xiao2021-12-101-911/+127
| | | | | | | | | | | | | | | * Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
* Move repo archiver to models/repo (#17913)Lunny Xiao2021-12-061-49/+2
| | | | | | | | | | | * Move repo archiver to models/repo * Move archiver service into services/repository/ * Fix imports * Fix test * Fix test
* Move accessmode into models/perm (#17828)Lunny Xiao2021-11-281-9/+10
|
* Allow forks to org if you can create repos (#17783)qwerty2872021-11-251-1/+1
|
* Move user related model into models/user (#17781)Lunny Xiao2021-11-241-42/+40
| | | | | | | | | | | | | * Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
* More pleasantly handle broken or missing git repositories (#17747)zeripath2021-11-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | * More pleasantly handle broken or missing git repositories In #17742 it was noted that there a completely invalid git repository underlying a repo on gitea.com. This happened due to a problem during a migration however, it is not beyond the realms of possibility that a corruption could occur to another user. This PR adds a check to RepoAssignment that will detect if a repository loading has failed due to an absent git repository. It will then show a page suggesting the user contacts the administrator or deletes the repository. Fix #17742 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update options/locale/locale_en-US.ini Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Remove unnecessary attributes of User struct (#17745)Lunny Xiao2021-11-221-9/+22
| | | | | | | | | | | | | | | * Remove unnecessary functions of User struct * Move more database methods out of user struct * Move more database methods out of user struct * Fix template failure * Fix bug * Remove finished FIXME * remove unnecessary code
* Remove NewSession method from db.Engine interface (#17577)Lunny Xiao2021-11-211-44/+48
| | | | | | | | | | | | | * Remove NewSession method from db.Engine interface * Fix bug * Some improvements * Fix bug * Fix test * Use XXXBean instead of XXXExample