forgejo/services/pull
Earl Warren 50822f361e
Do not update PRs based on events that happened before they existed
* Split TestPullRequest out of AddTestPullRequestTask
* A Created field is added to the Issue table
* The Created field is set to the time (with nano resolution) on creation
* Record the nano time repo_module.PushUpdateOptions is created by the hook
* The decision to update a pull request created before a commit was
  pushed is based on the time (with nano resolution) the git hook
  was run and the Created field

It ensures the following happens:

* commit C is pushed
* the git hook queues AddTestPullRequestTask for processing and returns with success
* TestPullRequest is not called yet
* a pull request P with commit C as the head is created
* TestPullRequest runs and ignores P because it was created after the commit was received

When the "created" column is NULL, no verification is done, pull
requests that were created before the column was created in the
database cannot be newer than the latest call to a git hook.

Fixes: https://codeberg.org/forgejo/forgejo/issues/2009
(cherry picked from commit 998a431747)

Conflicts:
	models/forgejo_migrations/migrate.go
	see https://codeberg.org/forgejo/forgejo/pulls/3165#issuecomment-1755941
	services/pull/pull.go
	trivial conflicts
2024-04-12 10:41:19 +02:00
..
check.go [FEAT] Configure if protected branch rule should apply to admins 2024-04-01 19:31:43 +00:00
check_test.go Replace assert.Fail with assert.FailNow (#27578) 2023-10-11 11:02:24 +00:00
comment.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
commit_status.go Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995) 2024-03-26 19:04:27 +01:00
commit_status_test.go Fixing the issue when status check per rule matches multiple actions (#29631) 2024-03-11 23:36:59 +07:00
edits.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
lfs.go Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 2023-12-07 15:27:36 +08:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
merge.go Do not update PRs based on events that happened before they existed 2024-04-12 10:41:19 +02:00
merge_ff_only.go Add merge style fast-forward-only (#28954) 2024-02-14 17:19:19 +01:00
merge_merge.go Add merge style fast-forward-only (#28954) 2024-02-14 17:19:19 +01:00
merge_prepare.go Refactor merge/update git command calls (#23366) 2023-03-09 09:48:52 -06:00
merge_rebase.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
merge_squash.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
merge_test.go Support template for merge message description (#22248) 2022-12-29 14:40:20 +02:00
patch.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
patch_unmerged.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
pull.go Do not update PRs based on events that happened before they existed 2024-04-12 10:41:19 +02:00
pull_test.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
review.go Prevent re-review and dismiss review actions on closed and merged PRs (#30065) 2024-03-30 07:17:32 +01:00
review_test.go Prevent re-review and dismiss review actions on closed and merged PRs (#30065) 2024-03-30 07:17:32 +01:00
temp_repo.go Adjust object format interface (#28469) 2023-12-17 11:56:08 +00:00
update.go Do not update PRs based on events that happened before they existed 2024-04-12 10:41:19 +02:00
update_rebase.go Refactor and tidy-up the merge/update branch code (#22568) 2023-03-07 15:07:35 -05:00