forgejo/modules/git
Gusted b9a934f5dc feat: improve checking if diffs differ (#8451)
This change is very similar to what was done in forgejo/forgejo#7727. When a PR is updated, `checkIfPRContentChanged` is called to check if the diff changed - this is done on a temporary repository. This change improves this checking by doing this operation on the bare repository. The change is split into several commits.

The following changes were made (in this exact order)

1. Update the `getTestPatchCtx` function that was introduced in forgejo/forgejo#7727 so it can be used outside the context of conflict checking. This is a simple change by making the caller determine if it can use a bare repository or not.

2. Do a small refactor of `ValidatePullRequest` to avoid indentation hell in this function, this is purely a refactor but necessary to not blow my brain while working on this function.

3. The first enhancement, introduce `testPatchCtx` in `ValidatePullRequest` to get diverging commits via the bare repository.

4. The main enhancement, do a refactor to move the function to be part of the repository struct and do a rename as this fits as a general purpose function. This refactoring includes it no longer being specific to a temporary repository and works on a bare repository.

5. Add extensive units tests, integration tests are added in forgejo/forgejo#8450 it checks that both calls to `CheckIfDiffDiffers` work. Because it also fixes a bug I sent it as a different PR.

6. Extend the integration test to check for diffs with commits from different repositories, to demonstrate that `getTestPatchCtx` works (specifically the `env` variable).

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8451
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
(cherry picked from commit 772bb20875)
2025-08-26 08:43:08 +00:00
..
foreachref chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
internal
pipeline chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
pushoptions Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
tests/repos fix: use linguist-generated for language stats (#7685) 2025-04-27 23:29:21 +00:00
url Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
batch.go
batch_reader.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
blame.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
blame_sha256_test.go
blame_test.go
blob.go blob: GetBlobContent: reduce allocations (#8223) 2025-06-19 18:36:12 +02:00
blob_test.go git/blob: add truncated tests 2025-06-20 20:43:10 +02:00
command.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
command_race_test.go
command_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
commit.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
commit_info.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
commit_info_test.go
commit_reader.go fix: parse change-id in the git commit header (#7884) 2025-05-16 21:14:41 +00:00
commit_sha256_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
commit_test.go fix: parse change-id in the git commit header (#7884) 2025-05-16 21:14:41 +00:00
diff.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
diff_compare.go feat: improve checking if diffs differ (#8451) 2025-08-26 08:43:08 +00:00
diff_compare_test.go feat: improve checking if diffs differ (#8451) 2025-08-26 08:43:08 +00:00
diff_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
error.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
git.go fix: make test suite run on older git version (#8188) 2025-06-14 19:50:58 +02:00
git_test.go chore: fix tests for old git versions (#8144) 2025-06-11 09:38:15 +02:00
grep.go fix: make test suite run on older git version (#8188) 2025-06-14 19:50:58 +02:00
grep_test.go fix: make test suite run on older git version (#8188) 2025-06-14 19:50:58 +02:00
hook.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
last_commit_cache.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
log_name_status.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
notes.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
notes_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
object_format.go
object_id.go
object_id_test.go
object_signature.go
parse.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
parse_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
README.md
ref.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
ref_test.go
remote.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo.go feat: improved performances when checking for conflicts on pull requests (#7727) 2025-05-16 12:40:38 +00:00
repo_archive.go
repo_attribute.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
repo_attribute_test.go fix: make test suite run on older git version (#8188) 2025-06-14 19:50:58 +02:00
repo_base.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_base_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_blame.go
repo_blob_test.go
repo_branch.go chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
repo_branch_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_commit.go feat: sync forks (#2364) 2025-04-07 07:00:38 +00:00
repo_commit_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_commitgraph.go
repo_compare.go [v12.0/forgejo] fix: correctly get stats for API commits (#8758) 2025-08-02 13:46:34 +02:00
repo_compare_test.go [v12.0/forgejo] fix: correctly get stats for API commits (#8758) 2025-08-02 13:46:34 +02:00
repo_gpg.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_hook.go
repo_index.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_language_stats.go fix: use linguist-generated for language stats (#7685) 2025-04-27 23:29:21 +00:00
repo_language_stats_test.go fix: use linguist-generated for language stats (#7685) 2025-04-27 23:29:21 +00:00
repo_object.go
repo_ref.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_ref_test.go
repo_stats.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_stats_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_tag.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
repo_tag_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo_test.go feat: improved performances when checking for conflicts on pull requests (#7727) 2025-05-16 12:40:38 +00:00
repo_tree.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
signature.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
signature_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
submodule.go
submodule_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
tag.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
tag_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
tree.go
tree_blob.go
tree_entry.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
tree_entry_mode.go
tree_test.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
utils.go
utils_test.go

Git Module

This module is merged from https://github.com/go-gitea/git which is a Go module to access Git through shell commands. Now it's a part of gitea's main repository for easier pull request.