feat(gitlab): Track merge request lifecycle state on PullRequest#118604
Open
malwilley wants to merge 2 commits into
Open
feat(gitlab): Track merge request lifecycle state on PullRequest#118604malwilley wants to merge 2 commits into
malwilley wants to merge 2 commits into
Conversation
Populate the PullRequest lifecycle fields (state, opened_at, closed_at, merged_at, head_commit_sha, draft) from the GitLab merge request webhook, mirroring the GitHub integration so the shared PR metrics pipeline has the same facts for both providers. GitLab reports the merge request state directly (opened/closed/merged/locked) and only exposes created_at/updated_at, so closed_at/merged_at are derived from updated_at based on the state. A merged merge request is treated as closed as well, matching the GitHub convention where a merged PR has both closed_at and merged_at set.
Use the merge request's merged_at directly instead of inferring it from updated_at, and derive closed_at from the lifecycle action rather than the state. Actions that do not change lifecycle state (e.g. an edit while merged) leave closed_at untouched via a sentinel, so terminal timestamps no longer drift to the edit time. head_commit_sha is only written when the event includes a last commit, preserving the stored value otherwise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've noticed that the PullRequest model, for GitLab PRs, does not have the correct
statelike it does for the GitHub provider. You can see this redash query which shows that it is alwaysnull.All the information is available in the webhook already, so this creates and updates the PullRequest model with the same information that we give for github.
Motivation: We are relying more on the PullRequest model to display up-to-date PR statuses on the issue, which will not work as expected for gitlab without this change.