Skip to content

feat(api): add project templates #3057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

gerry-pratama
Copy link
Contributor

@gerry-pratama gerry-pratama commented Dec 7, 2024

Changes

Project template classes have been added to objects/templates.py and their respective managers added to the Project class in objects/projects.py to represent the project templates API.

The project merge request template, in particular, will facilitate creating merge requests with a description template, like the following example:

mr_description_template = project.merge_request_templates.get("Default")
mr = project.mergerequests.create({'source_branch': 'cool_feature',
                                   'target_branch': 'main',
                                   'title': 'merge cool feature',
                                   'description': mr_description_template.content})

Documentation and testing

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

  • Documentation in the matching docs section.
    • Documentation for the new classes has been added to docs/gl_objects/templates.rst.
    • docs/gl_objects/merge_requests.rst has been updated to include an example of creating an MR with a default description template.
  • Unit tests and/or functional tests
    • tests/unit/objects/test_templates.py has been added to test both instance and project templates.

@gerry-pratama gerry-pratama changed the title feat(api): add project templates feat(templates): add project templates Dec 7, 2024
@gerry-pratama gerry-pratama force-pushed the add-project-templates branch 2 times, most recently from 6d203b3 to 2056b2c Compare December 7, 2024 07:29
Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (735efff) to head (24af304).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3057      +/-   ##
==========================================
+ Coverage   96.64%   96.67%   +0.02%     
==========================================
  Files          95       95              
  Lines        6142     6197      +55     
==========================================
+ Hits         5936     5991      +55     
  Misses        206      206              
Flag Coverage Δ
api_func_v4 82.63% <89.09%> (+0.07%) ⬆️
cli_func_v4 82.65% <89.09%> (+0.05%) ⬆️
unit 88.99% <100.00%> (+0.16%) ⬆️

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

Files with missing lines Coverage Δ
gitlab/v4/objects/projects.py 98.84% <100.00%> (+0.02%) ⬆️
gitlab/v4/objects/templates.py 100.00% <100.00%> (ø)

Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this @gerry-pratama, looks great! Just a nit on the naming and the tests, but I'm ok with this as well otherwise. These endpoints are definitely a bit funny on the GitLab side so makes sense to parametrize a bit.

@gerry-pratama gerry-pratama requested a review from nejch December 10, 2024 02:24
@nejch nejch changed the title feat(templates): add project templates feat(api): add project templates Dec 10, 2024
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks again @gerry-pratama, looks great! I might squash this one as we use it for the changelog and users are mostly interested in the public API in the release notes. 🙇

@nejch nejch merged commit 0d41da3 into python-gitlab:main Dec 10, 2024
18 checks passed
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