aboutsummaryrefslogtreecommitdiffstats
path: root/services/gitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Don't use full-file highlight when there is a git diff textconv (#35114)wxiaoguang2025-07-181-2/+5
| | | Fix #35106
* Improve submodule relative path handling (#35056)wxiaoguang2025-07-143-10/+11
| | | | | | | Fix #35054 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix incorrect comment diff hunk parsing, fix github asset ID nil panic (#35046)Lunny Xiao2025-07-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | * Fix missing the first char when parsing diff hunk header * Fix #35040 * Fix #35049 ---- Introduced in https://github.com/go-gitea/gitea/pull/12047/files#diff-de48c2f70e24ff5603180acf8b5ce9d0356ede8a45bfbf2a485707282ace6d6aR268 Before: <img width="487" height="167" alt="image" src="https://github.com/user-attachments/assets/17524c76-a296-4b4b-a4f9-c5150c41bae5" /> After: <img width="749" height="144" alt="image" src="https://github.com/user-attachments/assets/bcb12c76-c1ae-40f1-81b7-183d15f891db" /> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* enforce explanation for necessary nolints and fix bugs (#34883)TheFox0x72025-06-271-48/+2
| | | | | | | Follows up https://github.com/go-gitea/gitea/pull/34851 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* 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>
* Ignore force pushes for changed files in a PR review (#34837)delvh2025-06-241-1/+2
| | | | | | | Fixes #34832 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Run `gopls modernize` on codebase (#34751)silverwind2025-06-184-13/+9
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Mark parent directory as viewed when all files are viewed (#33958)Kerwin Bryant2025-04-151-5/+8
| | | | | | | | Fix #25644 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor Git Attribute & performance optimization (#34154)Lunny Xiao2025-04-111-14/+12
| | | | | | | | | | | | | | | | 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>
* Enable addtional linters (#34085)TheFox0x72025-04-011-3/+4
| | | | | | | | 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-311-3/+3
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* enable staticcheck QFxxxx rules (#34064)TheFox0x72025-03-291-2/+3
|
* Try to figure out attribute checker problem (#33901)wxiaoguang2025-03-171-0/+2
| | | For #31600
* Ignore trivial errors when updating push data (#33864)wxiaoguang2025-03-141-2/+0
| | | Fix #23213
* Fix material icon & diff highlight (#33844)wxiaoguang2025-03-103-25/+61
|
* Full-file syntax highlighting for diff pages (#33766)Dustin Firebaugh2025-03-094-284/+318
| | | | | | | | | | | | Fix #33358, fix #21970 This adds a step in the `GitDiffForRender` that does syntax highlighting for the entire file and then only references lines from that syntax highlighted code. This allows things like multi-line comments to be syntax highlighted correctly. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Decouple diff stats query from actual diffing (#33810)wxiaoguang2025-03-082-104/+53
| | | | | | | | | The diff stats are no longer part of the diff generation. Use `GetDiffShortStat` instead to get the total number of changed files, added lines, and deleted lines. As such, `gitdiff.GetDiff` can be simplified: It should not do more than expected. And do not run "git diff --shortstat" for pull list. Fix #31492
* Remove context from git struct (#33793)TheFox0x72025-03-042-4/+4
| | | | Argument is moved from struct init in command run, which lets us remove context from struct.
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-202-5/+3
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Performance optimization for pull request files loading comments attachments ↵Lunny Xiao2025-02-141-1/+1
| | | | (#33585)
* Add go wrapper around git diff-tree --raw -r -M (#33369)Alexander McRae2025-02-072-0/+676
| | | | | * Implemented calling git diff-tree * Ensures wrapper function is called with valid arguments * Parses output into go struct, using strong typing when possible
* Refactor gitdiff test (#33507)wxiaoguang2025-02-0512-25/+10
|
* Link to tree views of submodules if possible (#33424)Rowan Bohde2025-01-301-1/+1
| | | | | | | | | | | | | | This is a follow-up to https://github.com/go-gitea/gitea/pull/33097. When linking a submodule at a commit in either the repo view, or a diff when adding a new submodule, link to the tree view of that submodules intead of the individual commit. This shows the user the full tree, instead of the diff of the commit. This makes the assumption that the tree for a given SHA is at `<repo_url>/tree/<sha>`. This URL format is supported by both Github & Gitlab, but not Gitea. To fix this, add a redirect from `<username>/<repo>/tree/<ref>` to `<username>/<repo>/src/<ref>`, so that Gitea can support this URL structure.
* Fix parentCommit invalid memory address or nil pointer dereference. (#33204)hiifong2025-01-191-2/+4
| | | | | | | | | When the parent Commit does not exist on gitea, an error will be reported when opening the Commit details page: invalid memory address or nil pointer dereference. ![image](https://github.com/user-attachments/assets/4c2a9802-935f-41e9-b5b9-a4f0d745f709) ![image](https://github.com/user-attachments/assets/7b0bc15e-7f5f-4d58-8d24-fee667a799fa)
* Refactor older tests to use testify (#33140)TheFox0x72025-01-092-12/+7
| | | | | Refactor checks to use assert/require Use require.Eventually for waiting in elastic and meilisearch tests Use require to exit early instead of assert
* add submodule diff links (#33097)Rowan Bohde2025-01-083-6/+327
| | | | | | | | | | | | 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>
* Refactor pprof labels and process desc (#32909)wxiaoguang2024-12-201-1/+0
| | | | | | * Deprecate "gopid" in log, it is not useful and requires very hacky approach * Remove "git.Command.SetDescription" because it is not useful and only makes the logs too flexible
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-151-3/+2
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Reduce integration test overhead (#32475)Rowan Bohde2024-11-142-7/+0
| | | | | | | | | | | | | In profiling integration tests, I found a couple places where per-test overhead could be reduced: * Avoiding disk IO by synchronizing instead of deleting & copying test Git repository data. This saves ~100ms per test on my machine * When flushing queues in `PrintCurrentTest`, invoke `FlushWithContext` in a parallel. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix git error handling (#32401)wxiaoguang2024-11-021-1/+1
|
* improve performance of diffs (#32393)Rowan Bohde2024-11-021-35/+27
| | | | | | | | | | | | | | | | | | | | | | | | This has two major changes that significantly reduce the amount of work done for large diffs: * Kill a running git process when reaching the maximum number of files in a diff, preventing it from processing the entire diff. * When loading a diff with the URL param `file-only=true`, skip loading stats. This speeds up loading both hidden files of a diff and sections of a diff when clicking the "Show More" button. A couple of minor things from profiling are also included: * Reuse existing repo in `PrepareViewPullInfo` if head and base are the same. The performance impact is going to depend heavily on the individual diff and the hardware it runs on, but when testing locally on a diff changing 100k+ lines over hundreds of files, I'm seeing a roughly 75% reduction in time to load the result of "Show More" --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Update golangci-lint to v1.59.0 (#31221)silverwind2024-06-031-3/+3
| | | | | One new error regarding `fmt.Fscanf` error return in `gitdiff.go` but I'm not touching that further right now as handling the error would introduce a behaviour difference.
* Refactor sha1 and time-limited code (#31023)wxiaoguang2024-05-201-2/+1
| | | | | | | Remove "EncodeSha1", it shouldn't be used as a general purpose hasher (just like we have removed "EncodeMD5" in #28622) Rewrite the "time-limited code" related code and write better tests, the old code doesn't seem quite right.
* Make sure git version&feature are always prepared (#30877)wxiaoguang2024-05-061-1/+1
| | | Otherwise there would be more similar issues like #29287
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-5/+4
| | | | | | | | | | | 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`.
* Fix incorrect diff expander for deletion of last lines in a file (#29501)silverwind2024-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: https://github.com/go-gitea/gitea/issues/29498 I don't quite understand this code, but this change does seem to fix the issue and I tested a number of diffs with it and saw no issue. The function gets such value if last line is an addition: ``` LastLeftIdx: (int) 0, LastRightIdx: (int) 47, LeftIdx: (int) 47, RightIdx: (int) 48, ``` If it's a deletion, it gets: ``` LastLeftIdx: (int) 47, LastRightIdx: (int) 0, LeftIdx: (int) 48, RightIdx: (int) 47, ``` So I think it's correct to make this check respect both left and right side.
* Refactor git attributes (#29356)KN4CK3R2024-02-241-26/+16
|
* Add option to disable ambiguous unicode characters detection (#28454)wxiaoguang2023-12-172-6/+6
| | | | | | | | * Close #24483 * Close #28123 * Close #23682 * Close #23149 (maybe more)
* Adjust object format interface (#28469)Lunny Xiao2023-12-171-3/+3
| | | | | | | - Remove `ObjectFormatID` - Remove function `ObjectFormatFromID`. - Use `Sha1ObjectFormat` directly but not a pointer because it's an empty struct. - Store `ObjectFormatName` in `repository` struct
* Abstract hash function usage (#28138)Adam Majer2023-12-131-8/+16
| | | | | | Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
* Even more `db.DefaultContext` refactor (#27352)JakobDev2023-10-033-25/+26
| | | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* make writing main test easier (#27270)Lunny Xiao2023-09-281-4/+1
| | | | | | | | | This PR removed `unittest.MainTest` the second parameter `TestOptions.GiteaRoot`. Now it detects the root directory by current working directory. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix successful return value for `SyncAndGetUserSpecificDiff` (#27152)v1.21.0-rc0delvh2023-09-201-1/+1
| | | | A function should not return an error when it is successful. Otherwise, things like https://discord.com/channels/322538954119184384/322538954119184384/1153705341620600833 happen…
* move repository deletion to service layer (#26948)Lunny Xiao2023-09-081-0/+2
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Use Go 1.21 and update dependencies (#26878)wxiaoguang2023-09-031-3/+1
| | | | | | To make sure Gitea's next release's lifecycle could have active Golang support. And min/max are builtin now.
* Fix stderr usages (#26477)wxiaoguang2023-08-131-3/+3
|
* Display human-readable text instead of cryptic filemodes (#26352)delvh2023-08-061-0/+17
| | | | | | | | | | | | | | | | Now, you don't need to be a git expert anymore to know what these numbers mean. ## Before ![grafik](https://github.com/go-gitea/gitea/assets/51889757/9a964bf6-10fd-40a6-aeb2-ac8f437f8c32) ## After ![grafik](https://github.com/go-gitea/gitea/assets/51889757/84573cb9-55b6-4dde-9866-95f71b657554) or when the mode actually changed: ![grafik](https://github.com/go-gitea/gitea/assets/51889757/0f327538-ebdc-40e7-8c99-f9e21b67f638)
* Less naked returns (#25713)65432023-07-071-15/+10
| | | | | just a step towards #25655 and some related refactoring
* Support displaying diff stats in PR tab bar (#25387)hiifong2023-07-031-0/+36
| | | | | | | Fix #25326 --------- Co-authored-by: silverwind <me@silverwind.io>
* Show outdated comments in files changed tab (#24936)sebastian-sauer2023-06-212-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If enabled show a clickable label in the comment. A click on the label opens the Conversation tab with the comment focussed - there you're able to view the old diff (or original diff the comment was created on). **Screenshots** ![image](https://github.com/go-gitea/gitea/assets/1135157/63ab9571-a9ee-4900-9f02-94ab0095f9e7) ![image](https://github.com/go-gitea/gitea/assets/1135157/78f7c225-8d76-46f5-acfd-9b8aab988a6c) When resolved and outdated: ![image](https://github.com/go-gitea/gitea/assets/1135157/6ece9ebd-c792-4aa5-9c35-628694e9d093) Option to enable/disable this (stored in user settings - default is disabled): ![image](https://github.com/go-gitea/gitea/assets/1135157/ed99dfe4-76dc-4c12-bd96-e7e62da50ab5) ![image](https://github.com/go-gitea/gitea/assets/1135157/e837a052-e92e-4a28-906d-9db5bacf93a6) fixes #24913 --------- Co-authored-by: silverwind <me@silverwind.io>