# Implement \`extract_pull_request\` for GitLab provider \(\#47973\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f7fe6181cde07b1bf9e5e27ed11badc1ab647fb6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f7fe6181cde07b1bf9e5e27ed11badc1ab647fb6

Requested commit: f7fe6181cde07b1bf9e5e27ed11badc1ab647fb6

Commit: f7fe6181cde07b1bf9e5e27ed11badc1ab647fb6

Tree: 07ce47c3f3e5e56da4c037cb5631c6c44663e97e

Author: littleKitchen

Committer: GitHub

## Message

```
Implement `extract_pull_request` for GitLab provider (#47973)

Fixes #38709

## Summary
This implements the `extract_pull_request` method for GitLab's
`GitHostingProvider` trait, enabling merge request links to be shown in
the git blame hover popover.

## Implementation
The implementation parses GitLab MR references from commit messages
using a regex that matches two common patterns:

1. **Squash merge pattern**: `message (!123)` - When GitLab
squash-merges, it appends the MR number in parentheses
2. **Standard merge commit**: `See merge request group/project!123` -
The default merge commit message

## Tests Added
- `test_extract_merge_request_from_squash_commit` - Validates the
`(!123)` pattern
- `test_extract_merge_request_from_merge_commit` - Validates the `See
merge request` pattern
- `test_extract_merge_request_self_hosted` - Ensures it works with
self-hosted GitLab instances
- `test_extract_merge_request_no_match` - Confirms None is returned for
non-matching messages

## Related
This follows the same pattern as the GitHub provider implementation.

## Release Notes

- Added support for GitLab merge request links in git blame hover
popover
```

## Parents

- [839b4f1e60acd6f67e9b50f6bad5bc3284835872](https://git.cafe/gitcafe/zed/commit/839b4f1e60acd6f67e9b50f6bad5bc3284835872?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f7fe6181cde07b1bf9e5e27ed11badc1ab647fb6?format=markdown)
