aboutsummaryrefslogtreecommitdiffstats
path: root/services/context/repo.go
Commit message (Collapse)AuthorAgeFilesLines
* Move git references checking to gitrepo packages to reduce expose of ↵Lunny Xiao11 days1-3/+3
| | | | repository path (#33891)
* Refactor error system (#33610)wxiaoguang2025-02-161-9/+9
|
* Fix "redirect link" handling (#33440)wxiaoguang2025-01-311-12/+25
| | | | | | | `a%2fb` should not redirect to `a/b` --------- Co-authored-by: delvh <dev.lh@web.de>
* Refactor repository transfer (#33211)Lunny Xiao2025-01-301-1/+1
| | | | | | | | | | | | | - Both have `RejectTransfer` and `CancelTransfer` because the permission checks are not the same. `CancelTransfer` can be done by the doer or those who have admin permission to access this repository. `RejectTransfer` can be done by the receiver user if it's an individual or those who can create repositories if it's an organization. - Some tests are wrong, this PR corrects them. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Do not access GitRepo when a repo is being created (#33380)wxiaoguang2025-01-241-0/+3
|
* Fix incorrect ref usages (#33301)wxiaoguang2025-01-161-0/+12
| | | | | Fix #33297 By the way, improve some locales
* Fix incorrect TagName/BranchName usages (#33279)wxiaoguang2025-01-151-4/+0
| | | Add add a new test
* Simplify context ref name (#33267)wxiaoguang2025-01-151-29/+10
|
* Refactor ref type (#33242)Lunny Xiao2025-01-141-53/+25
| | | | | | | | | | | | Major changes: 1. do not sync ".keep" file during tests 2. fix incorrect route handler and empty repo handling (backported as #33253 with tests) 3. do not use `RepoRef`: most of the calls are abuses. 4. Use `git.RefType` instead of a new type definition `RepoRefType` on `context`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix incorrect ref "blob" (#33240)wxiaoguang2025-01-131-10/+0
| | | | | 1. "blob" is not a "ref", it shouldn't (and not unable to) be handled by `RepoRefByType` 2. the `/blob/{sha}` handle should use the path param "sha" directly
* Refactor RefName (#33234)wxiaoguang2025-01-131-10/+1
| | | And fix some FIXMEs
* Refactor context RefName and RepoAssignment (#33226)wxiaoguang2025-01-131-84/+71
| | | | | | | The `ctx.Repo.RefName` was used to be a "short name", it causes a lot of ambiguity. This PR does some refactoring and use `RefFullName` to replace the legacy `RefName`, and simplify RepoAssignment
* Refactor context repository (#33202)wxiaoguang2025-01-121-38/+27
|
* Fix raw file API ref handling (#33172)wxiaoguang2025-01-101-21/+17
| | | Fix #33164 and add more tests
* Make git clone URL could use current signed-in user (#33091)wxiaoguang2025-01-071-3/+3
| | | | | | | | | | | | | | close #33086 * Add a special value for "SSH_USER" setting: `(DOER_USERNAME)` * Improve parseRepositoryURL and add tests (now it doesn't have hard dependency on some setting values) Many changes are just adding "ctx" and "doer" argument to functions. By the way, improve app.example.ini, remove all `%(key)s` syntax, it only makes messy and no user really cares about it. Document: https://gitea.com/gitea/docs/pulls/138
* Fix empty git repo handling logic (#33101)wxiaoguang2025-01-041-3/+0
| | | Fix #33092
* [Feature] Private README.md for organization (#32872)Chai-Shi2024-12-311-2/+2
| | | | | | | | Implemented #29503 --------- Co-authored-by: Ben Chang <ben_chang@htc.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Clarify path param naming (#32969)wxiaoguang2024-12-241-7/+7
| | | | | | | | | In history (from some legacy frameworks), both `:name` and `name` are supported as path path name, `:name` is an alias to `name`. To make code consistent, now we should only use `name` but not `:name`. Also added panic check in related functions to make sure the name won't be abused in case some downstreams still use them.
* Refactor request context (#32956)wxiaoguang2024-12-241-63/+51
| | | | | | | | | | | Introduce RequestContext: is a short-lived context that is used to store request-specific data. RequestContext could be used to clean form tmp files, close context git repo, and do some tracing in the future. Then a lot of legacy code could be removed or improved. For example: most `ctx.Repo.GitRepo.Close()` could be removed because the git repo could be closed when the request is done.
* Move RepoTransfer from models to models/repo sub package (#32506)Lunny Xiao2024-12-181-2/+1
| | | | | | | | | | | | | `RepoTransfer` now is at models, but if we want to move it into `repo` model, it will depend on `Team`. So this PR also makes repo model depend on org model to make it possible. Just refactor, no code change. - [x] Move `DeleteOrganization` from `models/organization` to service layer - [x] Move `AccessibleTeamReposEnv` to `models/repo` - [x] Move `RepoTransfer` from `models` to `models/repo` - [x] Merge `getUserTeamIDs` and `GetUserTeamIDs`, Merge `GetUserTeams` and `getUserTeams`. - [x] Remove `Team`'s `Repos []*repo_model.Repository` to avoid dependency recycle.
* Make API "compare" accept commit IDs (#32801)wxiaoguang2024-12-121-23/+7
|
* GitHub like repo home page (#32213)yp053272024-12-061-8/+1
| | | | | | | Move some components (description, license, release, language stats) to sidebar --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove unnecessary code (#32560)Lunny Xiao2024-11-191-7/+0
| | | | PushMirrors only be used in the repository setting page. So it should not be loaded on every repository page.
* Refactor RepoRefByType (#32413)wxiaoguang2024-11-051-65/+73
| | | | | 1. clarify the "filepath" could(should) contain "{ref}" 2. remove unclear RepoRefLegacy and RepoRefAny, use RepoRefUnknown to guess 3. by the way, avoid using AppURL
* Allow maintainers to view and edit files of private repos when "Allow ↵Zettat1232024-10-111-1/+9
| | | | | maintainers to edit" is enabled (#32215) Fix #31539
* Fix javascript error when an anonymous user visiting migration page (#32144)Lunny Xiao2024-10-021-1/+4
| | | | | | | | | | | | This PR fixes javascript errors when an anonymous user visits the migration page. It also makes task view checking more restrictive. The router moved from `/user/task/{id}/status` to `/username/reponame/-/migrate/status` because it's a migrate status. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support repo license (#24872)yp053272024-10-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Close #278 Close #24076 ## Solutions: - Use [google/licenseclassifier](https://github.com/google/licenseclassifier/) Test result between [google/licensecheck](https://github.com/google/licensecheck) and [go-license-detector](https://github.com/go-enry/go-license-detector): https://github.com/go-gitea/gitea/pull/24872#issuecomment-1560361167 Test result between [google/licensecheck](https://github.com/google/licensecheck) and [google/licenseclassifier](https://github.com/google/licenseclassifier/): https://github.com/go-gitea/gitea/pull/24872#issuecomment-1576092178 - Generate License Convert Name List to avoid import license templates with same contents Gitea automatically get latest license data from[ spdx/license-list-data](https://github.com/spdx/license-list-data). But unfortunately, some license templates have same contents. #20915 [click here to see the list](https://github.com/go-gitea/gitea/pull/24872#issuecomment-1584141684) So we will generate a list of these license templates with same contents and create a new file to save the result when using `make generate-license`. (Need to decide the save path) - Save License info into a new table `repo_license` Can easily support searching repo by license in the future. ## Screen shot Single License: ![image](https://github.com/go-gitea/gitea/assets/18380374/41260bd7-0b4c-4038-8592-508706cffa9f) Multiple Licenses: ![image](https://github.com/go-gitea/gitea/assets/18380374/34ce2f73-7e18-446b-9b96-ecc4fb61bd70) Triggers: - [x] Push commit to default branch - [x] Create repo - [x] Mirror repo - [x] When Default Branch is changed, licenses should be updated Todo: - [x] Save Licenses info in to DB when there's a change to license file in the commit - [x] DB Migration - [x] A nominal test? - [x] Select which library to use(https://github.com/go-gitea/gitea/pull/24872#issuecomment-1560361167) - [x] API Support - [x] Add repo license table - ~Select license in settings if there are several licenses(Not recommended)~ - License board(later, not in this PR) ![image](https://github.com/go-gitea/gitea/assets/18380374/2c3c3bf8-bcc2-4c6d-8ce0-81d1a9733878) --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <m.huber@kithara.com> Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com>
* Refactor names (#31405)wxiaoguang2024-06-191-10/+10
| | | | | | | This PR only does "renaming": * `Route` should be `Router` (and chi router is also called "router") * `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`) * Use lower case for private functions to avoid exposing or abusing
* Refactor route path normalization (#31381)wxiaoguang2024-06-171-3/+3
| | | | Refactor route path normalization and decouple it from the chi router. Fix the TODO, fix the legacy strange path behavior.
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-291-4/+4
| | | | | | | | | | Resolve all cases for `unused parameter` and `unnecessary type arguments` Related: #30729 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-2/+0
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Clarify permission "HasAccess" behavior (#30585)wxiaoguang2024-04-201-2/+1
| | | | | | | | | | | | | | | Follow #30495 "HasAccess" behavior wasn't clear, to make it clear: * Use a new name `HasAnyUnitAccess`, it will be easier to review related code and permission problems. * Separate everyone access mode to a separate field, then all calls to HasAccess are reverted to old behavior before #30495. * Add new tests. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor web routes (#30519)wxiaoguang2024-04-171-17/+0
| | | | | | | Re-organize the routes in web.go and use ctx constants instead of `context.UnitTypes()` --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Move get/set default branch from git package to gitrepo package to hide ↵Lunny Xiao2024-03-081-1/+1
| | | | repopath (#29126)
* Use a predictiable fork URL to allow forking repositories without providing ↵wxiaoguang2024-03-011-20/+0
| | | | | | | | | | a repo ID (#29519) Close #29512 The "fork" URL: * Before: `/repo/fork/{RepoID}` * After: `/{OwnerName}/{RepoName}/fork`
* Let ctx.FormOptionalBool() return optional.Option[bool] (#29461)65432024-02-281-1/+1
| | | | just some refactoring bits towards replacing **util.OptionalBool** with **optional.Option[bool]**
* Move context from modules to services (#29440)Lunny Xiao2024-02-271-0/+1090
Since `modules/context` has to depend on `models` and many other packages, it should be moved from `modules/context` to `services/context` according to design principles. There is no logic code change on this PR, only move packages. - Move `code.gitea.io/gitea/modules/context` to `code.gitea.io/gitea/services/context` - Move `code.gitea.io/gitea/modules/contexttest` to `code.gitea.io/gitea/services/contexttest` because of depending on context - Move `code.gitea.io/gitea/modules/upload` to `code.gitea.io/gitea/services/context/upload` because of depending on context