aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo
Commit message (Collapse)AuthorAgeFilesLines
* Also display "recently pushed branch" alert on PR view (#35001)Naxdy2 days1-0/+6
| | | | | | | | | | | This commit adds the "You recently pushed to branch X" alert also to PR overview, as opposed to only the repository's home page. GitHub also shows this alert on the PR list, as well as the home page. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Enable gocritic `equalFold` and fix issues (#34952)silverwind6 days1-5/+4
| | | | | | | Continuation of https://github.com/go-gitea/gitea/pull/34678. --------- Signed-off-by: silverwind <me@silverwind.io>
* enforce nolint scope (#34851)TheFox0x72025-06-271-1/+1
| | | | | | | | | | | | | | | enable nolintlint scope requirement add comments to new directives so it's more obvious why they are in place --- I can also toggle the mandatory comments on if that's something of interest. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Use standalone function to update repository cols (#34811)Lunny Xiao2025-06-261-12/+6
| | | | | | | | Extract `UpdateRepository` Follow up #34762 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Edit file workflow for creating a fork and proposing changes (#34240)Brecht Van Lommel2025-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When viewing a file that the user can't edit because they can't write to the branch, the new, upload, patch, edit and delete functionality is no longer disabled. If no user fork of the repository exists, there is now a page to create one. It will automatically create a fork with a single branch matching the one being viewed, and a unique repository name will be automatically picked. When a fork exists, but it's archived, a mirror or the user can't write code to it, there will instead be a message explaining the situation. If the usable fork exists, a message will appear at the top of the edit page explaining that the changes will be applied to a branch in the fork. The base repository branch will be pushed to a new branch to the fork, and then the edits will be applied on top. The suggestion to fork happens when accessing /_edit/, so that for example online documentation can have an "edit this page" link to the base repository that does the right thing. Also includes changes to properly report errors when trying to commit to a new branch that is protected, and when trying to commit to an existing branch when choosing the new branch option. Resolves #9017, #20882 --------- Co-authored-by: Brecht Van Lommel <brecht@blender.org> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Run `gopls modernize` on codebase (#34751)silverwind2025-06-183-7/+5
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Replace update repository function in some places (#34566)Lunny Xiao2025-06-172-1/+7
| | | | | | | | | | | | `UpdateAllCols` is dangerous, the columns should be updated when necessary. This PR replaces some `updateRepository` invokes to reduce possible problems and wrongly updated time. Some parts have been fixed in #34388, but some are hidden in the function `updateRepository`. Alternatively, using `UpdateRepositoryColsNoAutoTime` to update the changed columns. Some `UpdateRepoSize` invokes are duplicated, so they will be removed when extracting from `updateRepository`.
* Refactor some tests (#34580)wxiaoguang2025-06-031-2/+0
| | | | 1. use `test.MockVariableValue` as much as possible 2. avoid `time.Sleep` as much as possible
* Do not mutate incoming options to SearchRepositoryByName (#34553)Philip Peterson2025-06-022-60/+62
| | | | | | | | | | | | | | Similar to #34544, this PR changes the `opts` argument in `SearchRepositoryByName()` to be passed by value instead of by pointer, as its mutations do not escape the function scope and are not used elsewhere. This simplifies reasoning about the function and avoids unnecessary pointer usage. This insight emerged during an initial attempt to refactor `RenderUserSearch()`, which currently intermixes multiple concerns. --------- Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
* Performance optimization for tags synchronization (#34355)Lunny Xiao2025-05-221-54/+7
| | | | | | | | | The tags synchronization is very slow for a non-mirror repository with many tags especially forking. This PR make all repositories' tags synchronization use the same function and remove the low performance synchronization function. The commit count of tag now will not be stored into database when syncing. Since the commits count will always be read from cache or git data, the `NumCommits` in the release table will be updated for the first read from git data.
* Fix remove org user failure on mssql (#34449)ChristopherHX2025-05-141-27/+4
| | | | | | | | | | | * mssql does not support fetching 0 repositories * remove paging by NumRepos that might be 0 * extend admin api test to purge user 2 Fixes #34448 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Only git operations should update `last changed` of a repository (#34388)Lunny Xiao2025-05-112-4/+4
| | | Try to fix #32046
* Fix a bug when uploading file via lfs ssh command (#34408)Lunny Xiao2025-05-092-9/+33
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Uniform all temporary directories and allow customizing temp path (#32352)Lunny Xiao2025-04-081-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR uniform all temporary directory usage so that it will be easier to manage. Relate to #31792 - [x] Added a new setting to allow users to configure the global temporary directory. - [x] Move all temporary files and directories to be placed under os.Temp()/gitea. - [x] `setting.Repository.Local.LocalCopyPath` now will be `setting.TempPath/local-repo` and the customized path is removed. ```diff -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;[repository.local] -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Path for local repository copy. Defaults to TEMP_PATH + `local-repo`, this is deprecated and cannot be changed -;LOCAL_COPY_PATH = local-repo ``` - [x] `setting.Repository.Upload.TempPath` now will be `settting.TempPath/uploads` and the customized path is removed. ```diff ;[repository.upload] -;; -;; Path for uploads. Defaults to TEMP_PATH + `uploads` -;TEMP_PATH = uploads ``` - [x] `setting.Packages.ChunkedUploadPath` now will be `settting.TempPath/package-upload` and the customized path is removed. ```diff ;[packages] -;; -;; Path for chunked uploads. Defaults it's `package-upload` under `TEMP_PATH` unless it's an absolute path. -;CHUNKED_UPLOAD_PATH = package-upload ``` - [x] `setting.SSH.KeyTestPath` now will be `settting.TempPath/ssh_key_test` and the customized path is removed. ```diff [server] -;; -;; Directory to create temporary files in when testing public keys using ssh-keygen, -;; default is the system temporary directory. -;SSH_KEY_TEST_PATH = ``` TODO: - [ ] setting.PprofDataPath haven't been changed because it may need to be kept until somebody read it but temp path may be clean up any time. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Check user/org repo limit instead of doer (#34147)DrMaxNix2025-04-071-8/+8
| | | | | | | | | | | | This PR tries to finally fix the bug mentioned in #30011 and #15504, where the user repo limit is checked when creating a repo in an organization. Fix #30011 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
* Rework create/fork/adopt/generate repository to make sure resources will be ↵Lunny Xiao2025-04-071-0/+5
| | | | | | | | | | | | | | | | | | | cleanup once failed (#31035) Fix #28144 To make the resources will be cleanup once failed. All repository operations now follow a consistent pattern: - 1. Create a database record for the repository with the status being_migrated. - 2. Register a deferred cleanup function to delete the repository and its related data if the operation fails. - 3. Perform the actual Git and database operations step by step. - 4. Upon successful completion, update the repository’s status to ready. The adopt operation is a special case — if it fails, the repository on disk should not be deleted.
* Fix markdown render behaviors (#34122)wxiaoguang2025-04-052-16/+17
| | | | | | | * Fix #27645 * Add config options `MATH_CODE_BLOCK_DETECTION`, problematic syntaxes are disabled by default * Fix #33639 * Add config options `RENDER_OPTIONS_*`, old behaviors are kept
* Enable addtional linters (#34085)TheFox0x72025-04-015-8/+9
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable testifylint rules (#34075)TheFox0x72025-03-314-12/+12
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* enable staticcheck QFxxxx rules (#34064)TheFox0x72025-03-291-6/+7
|
* Add anonymous access support for private/unlisted repositories (#34051)wxiaoguang2025-03-291-0/+6
| | | | | | | | | | | Follow #33127 Fix #8649, fix #639 This is a complete solution. A repo unit could be set to: * Anonymous read (non-signed-in user) * Everyone read (signed-in user) * Everyone write (wiki-only)
* Add anonymous access support for private repositories (backend) (#33257)wxiaoguang2025-03-281-6/+7
| | | | | | | | | | | Follow #33127 This PR add backend logic and test for "anonymous access", it shares the same logic as "everyone access", so not too much change. By the way, split `SettingsPost` into small functions to make it easier to make frontend-related changes in the future. Next PR will add frontend support for "anonymous access"
* Use filepath.Join instead of path.Join for file system file operations (#33978)Lunny Xiao2025-03-241-3/+3
|
* Don't create duplicated functions for code repositories and wiki ↵Lunny Xiao2025-03-191-4/+16
| | | | | | | | | | repositories (#33924) Fix https://github.com/go-gitea/gitea/pull/33910#pullrequestreview-2688913865 This PR changed the Repositroy interface in `gitrepo` package which makes it only focus the relative path in the disk and abstract whether it's a wiki repository or not.
* Decouple context from repository related structs (#33823)TheFox0x72025-03-081-20/+17
| | | Calls that required context implicitly are made to pass it as argument
* Small refactor to reduce unnecessary database queries and remove duplicated ↵Lunny Xiao2025-03-042-5/+3
| | | | functions (#33779)
* Refactor error system (#33771)wxiaoguang2025-03-031-3/+3
| | | It should not expose `util.SilentWrap` or construct it manually.
* Clone repository with Tea CLI (#33725)Quentin2025-02-271-5/+13
| | | | | | | | | | | | This PR adds "Tea CLI" as a clone method. <img width="350" alt="Capture d’écran 2025-02-25 à 23 38 47" src="https://github.com/user-attachments/assets/8e86e54a-998b-45d1-9f20-167b449e79b6" /> --------- Signed-off-by: Quentin Guidée <quentin.guidee@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix some user name usages (#33689)wxiaoguang2025-02-232-2/+20
| | | | | | | 1. GetUserOrgsList should "order by" lower_name 2. GetIssuePostersWithSearch should search in-case-sensitive-ly 3. LoginName should not be used as username By the way, remove unnecessary "onGiteaRun"
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-201-2/+1
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor repository transfer (#33211)Lunny Xiao2025-01-301-15/+52
| | | | | | | | | | | | | - 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>
* Refactor context flash msg and global variables (#33375)wxiaoguang2025-01-252-8/+20
| | | | | | 1. add `GetSiteCookieFlashMessage` to help to parse flash message 2. clarify `handleRepoHomeFeed` logic 3. remove unnecessary global variables, use `sync.OnceValue` instead 4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
* Fix missing license when sync mirror (#33255)yp053272025-01-141-0/+1
| | | Fix #33222
* Refactor context RefName and RepoAssignment (#33226)wxiaoguang2025-01-131-8/+3
| | | | | | | 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
* add submodule diff links (#33097)Rowan Bohde2025-01-082-129/+2
| | | | | | | | | | | | This adds links to submodules in diffs, similar to the existing link when viewing a repo at a specific commit. It does this by expanding diff parsing to recognize changes to submodules, and find the specific refs that are added, deleted or changed. Related #25888 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make git clone URL could use current signed-in user (#33091)wxiaoguang2025-01-074-89/+199
| | | | | | | | | | | | | | 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 repo updated time (#33120)Chai-Shi2025-01-071-0/+6
| | | | | | | | | | | | | | | | | | fixes #33119 routers/web/repo/view_home.go ![image](https://github.com/user-attachments/assets/b0d6c5f5-7abc-478a-8d41-4b44dbd460aa) Calling `updateContextRepoEmptyAndStatus` will always ask the DB to update the updated Unix attributes. When revisiting the repo's home page, the timestamp will be updated unexpectedly, so I added the needsUpdate variable to check whether, in the end, the commitment to db update is necessary if columns have not changed at all. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix empty git repo handling logic (#33101)wxiaoguang2025-01-041-0/+2
| | | Fix #33092
* Fix unittest and repo create bug (#33061)wxiaoguang2024-12-312-4/+19
| | | | | | | 1. `StatDir` was not right, fix the FIXME 2. Clarify the test cases for `IsUsableRepoName` 3. Fix regression bug in `repo-new.ts` Fix #33060
* Refactor "string truncate" (#32984)wxiaoguang2024-12-261-1/+1
|
* Move some errors to their own sub packages (#32880)Lunny Xiao2024-12-201-1/+16
|
* Move RepoTransfer from models to models/repo sub package (#32506)Lunny Xiao2024-12-182-0/+450
| | | | | | | | | | | | | `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.
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-154-11/+11
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Fix issue title rendering and refactor legacy function names (#32703)wxiaoguang2024-12-041-1/+1
| | | | | | | | Fix #32700, regression of recent markup refactoring And by the way, clarify many legacy problems: 1. Some "RenderXxx" functions do not really "render", they only call "post processors" 2. Merge "RenderEmoji | RenderCodeBlock", they are all for "simple issue title"
* Fix get reviewers' bug (#32415)Lunny Xiao2024-11-222-95/+0
| | | | | | | | | | This PR rewrites `GetReviewer` function and move it to service layer. Reviewers should not be watchers, so that this PR removed all watchers from reviewers. When the repository is under an organization, the pull request unit read permission will be checked to resolve the bug of #32394 Fix #32394
* Refactor markup render system (#32589)wxiaoguang2024-11-221-4/+1
| | | | This PR mainly moves some code and introduces `RenderContext.WithXxx` functions
* Refactor push mirror find and add check for updating push mirror (#32539)Lunny Xiao2024-11-181-16/+34
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor find forks and fix possible bugs that weak permissions check (#32528)Lunny Xiao2024-11-182-23/+18
| | | | | | | | | | | - Move models/GetForks to services/FindForks - Add doer as a parameter of FindForks to check permissions - Slight performance optimization for get forks API with batch loading of repository units - Add tests for forking repository to organizations --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix and refactor markdown rendering (#32522)wxiaoguang2024-11-162-52/+64
|
* Fix `recentupdate` sorting bugs (#32505)Zettat1232024-11-151-0/+1
| | | | | | Fix #32499 - Add the missing `recentupdate` to `OrderByFlatMap` - Assign default value(`recentupdate`) to `EXPLORE_PAGING_DEFAULT_SORT`