forgejo/modules
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
..
actions [gitea] week 2025-22 cherry pick (gitea/main -> forgejo) (#8198) 2025-06-17 18:28:07 +02:00
activitypub fix various typos (#7690) 2025-04-28 06:46:29 +00:00
analyze
assetfs [v12.0/forgejo] fix: follow symlinks for local assets (#8610) 2025-07-22 18:41:03 +02:00
auth chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
avatar chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
base
cache chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
card
charset feat: update ambigious characters (#7988) 2025-05-29 10:00:12 +02:00
container
csv
emoji chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
eventsource
forgefed refactor & enhance AP elements used (#7728) 2025-06-02 22:29:10 +02:00
generate chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00
git feat: improve checking if diffs differ (#8451) 2025-08-26 08:43:08 +00:00
gitrepo
graceful
hcaptcha
highlight
hostmatcher
html
httpcache
httplib fix: omit Content-Length on 307 redirects when serving direct manifest for containers (#8037) 2025-06-09 08:43:41 +02:00
indexer [v12.0/forgejo] fix(code-search): HighlightSearchResultCode should count the number of bytes and not the number of runes (#8498) 2025-07-12 19:00:07 +02:00
issue/template chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994) 2025-05-29 17:34:29 +02:00
json
keying chore(sec): unify usage of crypto/rand.Read (#7453) 2025-04-04 03:31:37 +00:00
label
lfs
log
markup [v12.0/forgejo] fix(ui): add missing lazy load attribute to images (#8282) 2025-06-25 20:42:35 +02:00
mcaptcha
metrics
migration fix(migrations): transfer PR flow information (#7421) 2025-04-03 06:47:37 +00:00
nosql
optional
options
packages [v12.0/forgejo] fix: allow double digit epoch for Debian packages (#8733) 2025-07-30 20:31:39 +02:00
paginator
pprof
private
process
proxy
proxyprotocol
public add model viewer for .glb (GLTF) model in file view (#8111) 2025-06-21 14:42:35 +02:00
queue chore: QoL improvements to tests (#7917) 2025-05-21 15:45:56 +02:00
recaptcha
references fix: pull request cross references (#7979) 2025-05-28 14:50:05 +02:00
regexplru
repository feat: configurable default units for mirrors (#7902) 2025-06-03 08:12:29 +02:00
secret
session
setting [v12.0/forgejo] fix: query token auth version mismatch (#8670) 2025-07-26 00:45:07 +02:00
sitemap
ssh
storage [v12.0/forgejo] fix: minio initialization can freeze indefinitely if misconfigured (#8914) 2025-08-16 06:43:42 +02:00
structs [v12.0/forgejo] fix(ui): Add pasted images to dropzone (#8362) 2025-06-30 16:19:58 +02:00
svg
sync
system
templates [v12.0/forgejo] fix(ui): add missing lazy load attribute to images (#8282) 2025-06-25 20:42:35 +02:00
test chore: QoL improvements to tests (#7917) 2025-05-21 15:45:56 +02:00
testlogger
timeutil
translation Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154) 2025-05-03 14:11:01 +00:00
turnstile
typesniffer add model viewer for .glb (GLTF) model in file view (#8111) 2025-06-21 14:42:35 +02:00
updatechecker
uri
user
util [v12.0/forgejo] fix: ASCII equal fold for authorization header (#8459) 2025-07-10 01:30:07 +02:00
validation fix: allow instance API URLs in release assets (#7644) 2025-06-09 10:01:59 +02:00
web feat: make Forgejo Actions server logs less noisy (#7986) 2025-05-29 10:06:30 +02:00
webhook Actions Failure, Succes, Recover Webhooks (#7508) 2025-06-03 14:29:19 +02:00
zstd