aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
Commit message (Collapse)AuthorAgeFilesLines
* Fix various bugs (#35177)wxiaoguang11 days2-13/+5
| | | | | | * Fix #35144 * Fix #35117 * Fix https://github.com/go-gitea/gitea/issues/35054#issuecomment-3131793977 * Fix #35136
* Use db.WithTx/WithTx2 instead of TxContext when possible (#35130)Lunny Xiao2025-07-224-120/+82
|
* Fix submodule parsing when the gitmodules is missing (#35109)wxiaoguang2025-07-181-1/+3
| | | | | | Follow up #35096, fix #35095, fix #35115 and add more tests The old code used some fragile behaviors which depend on the "nil" receiver. This PR should be a complete fix for more edge cases.
* Rename pull request GetGitRefName to GetGitHeadRefName (#35093)Lunny Xiao2025-07-161-1/+1
|
* Improve submodule relative path handling (#35056)wxiaoguang2025-07-142-11/+12
| | | | | | | Fix #35054 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Enable gocritic `equalFold` and fix issues (#34952)silverwind2025-07-061-1/+1
| | | | | | | Continuation of https://github.com/go-gitea/gitea/pull/34678. --------- Signed-off-by: silverwind <me@silverwind.io>
* Support getting last commit message using contents-ext API (#34904)RickyMa2025-07-033-98/+40
| | | | | | | | Fix #34870 Fix #34929 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Follow file symlinks in the UI to their target (#28835)delvh2025-07-011-1/+1
| | | | | | | | | | Symlinks are followed when you click on a link next to an entry, either until a file has been found or until we know that the link is dead. When the link cannot be accessed, we fall back to the current behavior of showing the document containing the target. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* enforce nolint scope (#34851)TheFox0x72025-06-271-5/+14
| | | | | | | | | | | | | | | 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>
* Refactor "change file" API (#34855)wxiaoguang2025-06-252-2/+1
| | | | | | | | | Follow up the "editor" refactor, use the same approach to simplify code, and fix some docs & comments --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Refactor repo contents API and add "contents-ext" API (#34822)wxiaoguang2025-06-254-200/+151
| | | See the updated swagger document for details.
* Refactor editor (#34780)wxiaoguang2025-06-215-241/+145
| | | A complete rewrite
* Add ff_only parameter to POST /repos/{owner}/{repo}/merge-upstream (#34770)Dan Čermák2025-06-191-1/+6
| | | | | | | | | The merge-upstream route was so far performing any kind of merge, even those that would create merge commits and thus make your branch diverge from upstream, requiring manual intervention via the git cli to undo the damage. With the new optional parameter ff_only, we can instruct gitea to error out, if a non-fast-forward merge would be performed.
* Remove unused param `doer` (#34545)Philip Peterson2025-06-188-11/+11
|
* Run `gopls modernize` on codebase (#34751)silverwind2025-06-189-46/+18
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Refactor some file edit related code (#34744)wxiaoguang2025-06-184-153/+148
| | | | | | | Follow up #34350 --------- Co-authored-by: delvh <dev.lh@web.de>
* Fix ghost user in feeds when pushing in an actions, it should be ↵Lunny Xiao2025-06-171-25/+7
| | | | gitea-actions (#34703)
* Replace update repository function in some places (#34566)Lunny Xiao2025-06-176-36/+108
| | | | | | | | | | | | `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`.
* Allow renaming/moving binary/LFS files in the UI (#34350)bytedream2025-06-161-25/+128
| | | | | | | | | | | | | | | | | | | Adds the ability to rename/move binary files like binary blobs or images and files that are too large in the web ui. This was purposed in #24722, along with the ability edit images via an upload of a new image, which I didn't implement here (could be done in a separate PR). Binary file content: ![binary](https://github.com/user-attachments/assets/61d9ff71-25d3-4832-9288-452cdefc7283) File too large: ![toolarge](https://github.com/user-attachments/assets/3b42dbd0-e76a-4c3c-92d2-52ebffedea64) GitHub does the same (I've copied the text from there): ![gh](https://github.com/user-attachments/assets/e1499813-fb71-4544-9d58-086046a5f13e)
* Improve instance wide ssh commit signing (#34341)ChristopherHX2025-06-112-6/+12
| | | | | | | | | | | | | | | | | * Signed SSH commits can look in the UI like on GitHub, just like gpg keys today in Gitea * SSH format can be added in gitea config * SSH Signing worked before with DEFAULT_TRUST_MODEL=committer `TRUSTED_SSH_KEYS` can be a list of additional ssh public key contents to trust for every user of this instance Closes #34329 Related #31392 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Keeping consistent between UI and API about combined commit status state and ↵Lunny Xiao2025-06-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix some bugs (#34562) Extract from #34531 ## Move Commit status state to a standalone package Move the state from `structs` to `commitstatus` package. It also introduce `CommitStatusStates` so that the combine function could be used from UI and API logic. ## Combined commit status Changed This PR will follow Github's combined commit status. Before this PR, every commit status could be a combined one. According to https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#get-the-combined-status-for-a-specific-reference > Additionally, a combined state is returned. The state is one of: > failure if any of the contexts report as error or failure > pending if there are no statuses or a context is pending > success if the latest status for all contexts is success This PR will follow that rule and remove the `NoBetterThan` logic. This also fixes the inconsistent between UI and API. In the API convert package, it has implemented this which is different from the UI. It also fixed the missing `URL` and `CommitURL` in the API. ## `CalcCommitStatus` return nil if there is no commit statuses The behavior of `CalcCommitStatus` is changed. If the parameter commit statuses is empty, it will return nil. The reference places should check the returned value themselves.
* Refactor some tests (#34580)wxiaoguang2025-06-031-1/+2
| | | | 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-2/+2
| | | | | | | | | | | | | | 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>
* Fix some trivial problems (#34579)wxiaoguang2025-06-022-4/+26
|
* Fix doctor deleting orphaned issues attachments (#34142)Lunny Xiao2025-05-301-1/+2
| | | | Fix the bug when deleting orphaned issues attachments. The attachments maybe stored on other storages service rather than disk.
* Split GetLatestCommitStatus as two functions (#34535)Lunny Xiao2025-05-261-1/+1
| | | | | | | | Extract from #34531. This will reduce unnecessary count operation in databases. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Performance optimization for tags synchronization (#34355)Lunny Xiao2025-05-222-10/+4
| | | | | | | | | 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 ephemeral runner deletion (#34447)ChristopherHX2025-05-201-0/+9
| | | | | | | | | * repository deletion, delete ephemeral runners with active tasks as well skips regular cleanup * user deletion, delete ephemeral runners with active tasks as well skips regular cleanup * delete ephemeral runners once status changes to done * You no longer see used ephemeral runners after the task is done * if you see one the cron job takes care of it
* Only git operations should update `last changed` of a repository (#34388)Lunny Xiao2025-05-119-14/+14
| | | Try to fix #32046
* Fix incorrect divergence cache after switching default branch (#34370)GWDx2025-05-081-0/+5
| | | | | | | | | | Issue: After switching the default branch, other branches are still compared against the old default branch due to outdated divergence cache. Change: Clear the divergence cache in SetRepoDefaultBranch to ensure correct comparisons against the new default branch. Fixes #34369
* Fix LFS file not stored in LFS when uploaded/edited via API or web UI (#34367)bytedream2025-05-081-0/+7
| | | | | | | | Files that should be stored in LFS and are uploaded/edited from the API or web UI aren't stored in LFS. This may be a regression from #34154. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* support the open-icon of folder (#34168)Kerwin Bryant2025-04-282-21/+18
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add API endpoint to request contents of multiple files simultaniously (#34139)Denys Konovalov2025-04-225-249/+84
| | | | | | | | | | | | | | | | Adds an API POST endpoint under `/repos/{owner}/{repo}/file-contents` which receives a list of paths and returns a list of the contents of these files. This API endpoint will be helpful for applications like headless CMS (reference: https://github.com/sveltia/sveltia-cms/issues/198) which need to retrieve a large number of files by reducing the amount of needed API calls. Close #33495 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix bug when migrating repository (#34182)Lunny Xiao2025-04-143-7/+8
| | | This PR fixed a bug which is a regression from #31035
* Move and rename UpdateRepository (#34136)Lunny Xiao2025-04-125-33/+145
|
* Refactor Git Attribute & performance optimization (#34154)Lunny Xiao2025-04-113-36/+11
| | | | | | | | | | | | | | | | This PR moved git attributes related code to `modules/git/attribute` sub package and moved language stats related code to `modules/git/languagestats` sub package to make it easier to maintain. And it also introduced a performance improvement which use the `git check-attr --source` which can be run in a bare git repository so that we don't need to create a git index file. The new parameter need a git version >= 2.40 . If git version less than 2.40, it will fall back to previous implementation. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: yp05327 <576951401@qq.com>
* Uniform all temporary directories and allow customizing temp path (#32352)Lunny Xiao2025-04-084-23/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-076-21/+21
| | | | | | | | | | | | 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-0710-321/+459
| | | | | | | | | | | | | | | | | | | 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.
* Keep file tree view icons consistent with icon theme (#33921)Kerwin Bryant2025-04-062-11/+46
| | | | | | | | | | | | | | | | | Fix #33914 before: ![3000-gogitea-gitea-y4ulxr46c4k ws-us118 gitpod io_test_test gitea_src_branch_main_ gitmodules](https://github.com/user-attachments/assets/ca50eeff-cc44-4041-b01f-c0c5bdd3b6aa) after: ![3000-gogitea-gitea-y4ulxr46c4k ws-us118 gitpod io_test_test gitea_src_branch_main_README md](https://github.com/user-attachments/assets/3b87fdbd-81d0-4831-8a74-4dbfcd5b6d91) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Avoid creating unnecessary temporary cat file sub process (#33942)Lunny Xiao2025-04-041-1/+1
| | | | | | | | | | | | | Extract from #33934 In the same goroutine, we should reuse the exist cat file sub process which exist in `git.Repository` to avoid creating a unnecessary temporary subprocess. This PR reuse the exist cate file writer and reader in `getCommitFromBatchReader`. It also move `prepareLatestCommitInfo` before creating dataRc which will hold the writer so other git operation will create a temporary cat file subprocess.
* Add `last_committer_date` and `last_author_date` for file contents API (#32921)Lunny Xiao2025-04-023-24/+38
| | | | | | | | Fix #32886 Add `last_committer_date` and `last_author_date` in the content API which is not implemented by Github API v3 at the moment. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor Branch struct in package modules/git (#33980)Lunny Xiao2025-04-023-22/+23
| | | | The `Branch` struct in `modules/git` package is unnecessary. We can just use a `string` to represent a branch
* Enable addtional linters (#34085)TheFox0x72025-04-018-14/+17
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* fix users being able bypass limits with repo transfers (#34031)TheFox0x72025-03-312-1/+63
| | | | prevent user from being able to transfer repo to user who cannot have more repositories
* Enable testifylint rules (#34075)TheFox0x72025-03-317-15/+15
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* enable staticcheck QFxxxx rules (#34064)TheFox0x72025-03-291-4/+5
|
* Fix some migration and repo name problems (#33986)wxiaoguang2025-03-241-0/+14
| | | | | | 1. Ignore empty inputs in `UnmarshalHandleDoubleEncode` 2. Ignore non-existing `stateEvent.User` in gitlab migration 3. Enable `release` and `wiki` units when they are selected in migration 4. Sanitize repo name for migration and new repo
* Use filepath.Join instead of path.Join for file system file operations (#33978)Lunny Xiao2025-03-241-1/+1
|
* Extract code to their own functions for push update (#33944)Lunny Xiao2025-03-201-86/+111
|