- Add a test case specifically verifying that `Gitea.SetLabels`
is called with `staging/Auto` when a *new* project PR is created
for submodules.
- Verify `PrjGitDescription` and `SetSubmodulesToMatchPRSet` behave
correctly when a single `PRSet` contains 5+ different package
repositories.
Also,
- Add simple unit tests to verify mapping of `models.StateType`
to internal event strings.
- Verify it correctly wraps `ProcesPullRequest` and handles panics
via the deferred recovery block.
- Add tests for scenarios where `GetRecentPullRequests` fails.
- Verify the random sleep interval logic (can be tested by mocking
`time.Sleep` if refactored, or verifying behavior with interval=0).
- PullRequestWebhookEvent: Verified that PR events correctly
trigger processing with all necessary Gitea and Git mocks.
- IssueCommentWebhookEvent: Verified that issue comment events
(which Gitea often uses for PR comments) are handled correctly.
- Recursion Limit: Verified that the recursion protection logic
correctly terminates and cleans up when the limit is reached.
- Invalid Data Format: Verified that non-event data types return
appropriate errors.
- Add scenarios for closed/merged project PRs that trigger
submodule checks and downstream PR updates (manual merge vs close).
- Test the "Consistency check" logic where submodules are reset
if they don't match the PR set.
- Test the "superfluous PR" check (no-op PRs that should be closed).
In previous fix attempt, there were changes to process IssueComments
but PRComments are their instance of IssueComments distinct from
IssueComments webhook events
Fixes: a418b48809
Maintainer review is only required if the PR is created by non-maintainer
or ProjetGit PR is created by non-bot. If maintainer review is not required,
but the maintainer is also listed as a Reviewer, then we cannot remove
this review request from the PR.
Move the function to request and unrequest reviewers to a different
function. This will allow later simplification of the function
that determines if all reviews are complete.
Unrequesting of reviews is only possible in case of bot issued
review requests. The rest are left as-is.
If project or package maintainer already reviewed the PR, as
appropriate, they are no longer re-added to the PR. We also need
to remove reviewers, but only if they were previously requested
by the bot and not something else.
When a repository is created, there appears to be a race condition
where the default branch is not yet set in the message webhook
event.
We should additionally take care if the submodule is "registered"
but it wasn't correctly added, mostly due to earlier error. So,
always deinit submodules
If we fetch only one commit and force fetch the branch to local,
it seems that the remote head ref is not actually set. So, we should
just use the local version anyway, as it's updated.
We need to cycle through all project configs before we try to
match non-project config branches/packages. If we have multiple
project gits in one org, this coudl match wrong config