summaryrefslogtreecommitdiffstats
path: root/models/repo.go
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Move attachment into models/repo/ (#17650)Lunny Xiao2021-11-191-3/+28
| | | | | | | * Move attachment into models/repo/ * Fix test * Fix bug
* Use a standalone struct name for Organization (#17632)Lunny Xiao2021-11-191-13/+13
| | | | | | | | | | | | | | | | | | | | | * Use a standalone struct name for Organization * recover unnecessary change * make the code readable * Fix template failure * Fix template failure * Move HasMemberWithUserID to org * Fix test * Remove unnecessary user type check * Fix test Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move user/org deletion to services (#17673)KN4CK3R2021-11-191-10/+10
|
* Move user functions into user.go (#17659)Lunny Xiao2021-11-181-8/+9
| | | | | * Move user functions into user.go * Fix test
* A better go code formatter, and now `make fmt` can run in Windows (#17684)wxiaoguang2021-11-171-1/+2
| | | | * go build / format tools * re-format imports
* Multiple Escaping Improvements (#17551)zeripath2021-11-161-13/+8
| | | | | | | | | | | | | | There are multiple places where Gitea does not properly escape URLs that it is building and there are multiple places where it builds urls when there is already a simpler function available to use this. This is an extensive PR attempting to fix these issues. 1. The first commit in this PR looks through all href, src and links in the Gitea codebase and has attempted to catch all the places where there is potentially incomplete escaping. 2. Whilst doing this we will prefer to use functions that create URLs over recreating them by hand. 3. All uses of strings should be directly escaped - even if they are not currently expected to contain escaping characters. The main benefit to doing this will be that we can consider relaxing the constraints on user names and reponames in future. 4. The next commit looks at escaping in the wiki and re-considers the urls that are used there. Using the improved escaping here wiki files containing '/'. (This implementation will currently still place all of the wiki files the root directory of the repo but this would not be difficult to change.) 5. The title generation in feeds is now properly escaped. 6. EscapePound is no longer needed - urls should be PathEscaped / QueryEscaped as necessary but then re-escaped with Escape when creating html with locales Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net>
* Move webhook into models/webhook/ (#17579)Lunny Xiao2021-11-101-7/+8
|
* Move unit into models/unit/ (#17576)Lunny Xiao2021-11-091-19/+20
| | | | | * Move unit into models/unit/ * Rename unit.UnitType as unit.Type
* Ensure that git daemon export ok is created for mirrors (#17243)zeripath2021-10-131-26/+33
| | | | | | | | | | | | | * Ensure that git daemon export ok is created for mirrors There is an issue with #16508 where it appears that create repo requires that the repo does not exist. This causes #17241 where an error is reported because of this. This PR fixes this and also runs update-server-info for mirrors and generated repos. Fix #17241 Signed-off-by: Andrew Thornton <art27@cantab.net>