← 返回首页
feat: introduce related_issues to merge requests by xakepnz · Pull Request #2996 · python-gitlab/python-gitlab · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

feat: introduce related_issues to merge requests#2996

Merged
nejch merged 11 commits into
python-gitlab:mainfrom
xakepnz:main
Sep 24, 2024
Merged

feat: introduce related_issues to merge requests#2996
nejch merged 11 commits into
python-gitlab:mainfrom
xakepnz:main

Conversation

Copy link
Copy Markdown
Contributor

xakepnz commented Sep 23, 2024

Changes

  • This PR introduces related_issues for the merge_requests object, returning a list of all related issues.

Context

GitLab released related_issues (official docs), an endpoint which collects all issues that relate to the current MR. This can be from:

  • commit messages on the MR that contain issue links
  • issue links commented in the MR
  • issue links in the title of the MR
  • issues created from discussions in the MR

See the change introduced: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155422

PoC:

curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://127.0.0.1:3000/api/v4/projects/7/merge_requests/1/related_issues"

Documentation and testing

Both docs & tests updated

Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated:

Copy link
Copy Markdown
Member

nejch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Thanks a lot for your contribution @xakepnz!

I just left a few initial comments to get tests green hopefully. Let me know if anything's unclear.

Comment thread tests/unit/objects/test_merge_requests.py Outdated Show resolved Hide resolved
Comment thread tests/unit/objects/test_merge_requests.py Outdated Show resolved Hide resolved
xakepnz marked this pull request as draft September 23, 2024 10:54
Copy link
Copy Markdown

codecov Bot commented Sep 23, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.61%. Comparing base (a2ab54c) to head (412d92d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@ ## main #2996 +/- ## ======================================= Coverage 96.61% 96.61% ======================================= Files 95 95 Lines 6080 6087 +7 ======================================= + Hits 5874 5881 +7 Misses 206 206
Flag Coverage Δ
api_func_v4 82.58% <42.85%> (+0.06%) ⬆️
cli_func_v4 82.89% <42.85%> (-0.05%) ⬇️
unit 88.74% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
gitlab/v4/objects/merge_requests.py 89.67% <100.00%> (+0.48%) ⬆️

Copy link
Copy Markdown
Contributor Author

xakepnz commented Sep 23, 2024

Thanks a lot for your contribution @xakepnz!

I just left a few initial comments to get tests green hopefully. Let me know if anything's unclear.

Hey @nejch, thanks for the quick replies! - I ended up reverting my test before seeing your suggestions. So i've re-added it and i'm still working on Mocking the calls to /related_issues

You're correct, the response from GitLab API is a list of dicts containing a lot more than just the issue id's.

I'll keep working on this to try and pass CI tests.

xakepnz and others added 8 commits September 24, 2024 00:37
Add related_issues mock endpoint call and resp test
Update title attr and ensure GET request is mocked
Ensure related_issues URL calls match expected mocks
Ensure related_issues mock request matches the same project & MR mock request
RESTObjectList iters an expected ProjectIssue obj
xakepnz marked this pull request as ready for review September 23, 2024 12:52
xakepnz requested a review from nejch September 23, 2024 12:52
Copy link
Copy Markdown
Contributor Author

xakepnz commented Sep 23, 2024

Hey @nejch should be all set now thanks!

Copy link
Copy Markdown
Member

nejch left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Thanks again for your contribution @xakepnz, LGTM now!

These days I'd probably prefer a manager with .list() which would also solve your next(iter(..)) issues, but it's a bit of overhead in the code and I see we already have the same approach for commits, closes_issues etc.

I'll squash the commits just so we have a clean history here.

nejch merged commit 174d992 into python-gitlab:main Sep 24, 2024
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.