Skip to content

Add support for Groups API method transfer. #1807

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

Closed
wants to merge 0 commits into from

Conversation

sattlerc
Copy link
Contributor

@sattlerc sattlerc commented Jan 5, 2022

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2022

Codecov Report

Merging #1807 (e42b07e) into main (9894b35) will decrease coverage by 0.08%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #1807      +/-   ##
==========================================
- Coverage   92.02%   91.93%   -0.09%     
==========================================
  Files          76       76              
  Lines        4790     4800      +10     
==========================================
+ Hits         4408     4413       +5     
- Misses        382      387       +5     
Flag Coverage Δ
cli_func_v4 81.31% <50.00%> (-0.07%) ⬇️
py_func_v4 80.14% <50.00%> (-0.07%) ⬇️
unit 83.12% <50.00%> (-0.07%) ⬇️

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

Impacted Files Coverage Δ
gitlab/v4/objects/groups.py 84.89% <37.50%> (-2.90%) ⬇️
gitlab/exceptions.py 100.00% <100.00%> (ø)

@JohnVillalovos
Copy link
Member

Thanks for the PR. Can you please squash the commits down to one commit. And make sure there is a commit message.

Also if possible unit and/or functional tests would be great.

Thanks again!

@JohnVillalovos
Copy link
Member

And updating the documentation on how to use it would also be useful.

@sattlerc
Copy link
Contributor Author

sattlerc commented Jan 5, 2022

Note that the typo fix commit is unrelated to the feature commit. Should I remove it?

I looked at the documentation, but it seems to be autogenerated.

There are usage examples for a limited number of group methods in docs/gl_objects/groups.rst. The related group method transfer_project doesn't appear there, so I thought it appropriate not to add transfer_group.

@sattlerc
Copy link
Contributor Author

sattlerc commented Jan 5, 2022

I wasn't able to find tests for the related group method transfer_project. If you add tests for that one, I can base the ones for transfer_group on those.

JohnVillalovos
JohnVillalovos previously approved these changes Jan 5, 2022
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 for this PR @sattlerc! Just another small comment from me.

thought: I also would almost prefer to just call it transfer() since the transfer direction is inverted from the transfer_project() in this same class, but unfortunately we have transfer_project() in the projects module already as well. Maybe that one could be deprecated and have both methods that do "transfer this resource somewhere" called transfer(). Outside the scope of this PR but open to hear opinions here :)

And thanks for changing the functional code as this does look closer to the rest of the library e.g. further down in this module.

if parent_id is not None:
data["parent_id"] = parent_id
return self.gitlab.http_post(
"/groups/import", post_data=data, files=files, **kwargs
)

@nejch
Copy link
Member

nejch commented Jan 5, 2022

I wasn't able to find tests for the related group method transfer_project. If you add tests for that one, I can base the ones for transfer_group on those.

I'll try and add some tests for transfer_project as well.
Edit: I think the more equivalent tests would be for transfer_project from here https://github.com/python-gitlab/python-gitlab/blob/main/gitlab/v4/objects/projects.py#L529-L544

@sattlerc
Copy link
Contributor Author

sattlerc commented Jan 5, 2022

I would prefer transfer as well (that's also the name of the API path). Should I change it?

@nejch
Copy link
Member

nejch commented Jan 5, 2022

I would prefer transfer as well (that's also the name of the API path). Should I change it?

Yeah, let's do that. This just looks nicer:

group = gl.groups.get("gitlab-org/maintainers")
group.transfer("gitlab-com")

It also avoids us getting into an awkward situation if GitLab comes up with a "transfer a group into this group" endpoint at some point 😅 (as is the case with transfer_project here)

@sattlerc
Copy link
Contributor Author

sattlerc commented Jan 5, 2022

Okay. I have have also renamed the exception from GitlabTransferGroupError to GitlabGroupTransferError.

@nejch
Copy link
Member

nejch commented Jan 6, 2022

Thanks, LGTM @sattlerc, not sure if John has any more comments. I'll open an accompanying PR for project transfer and you can rebase after merge if you like, I'll ping here.

@sattlerc sattlerc changed the title Add support for Groups API method transfer_group. Add support for Groups API method transfer. Jan 6, 2022
@JohnVillalovos
Copy link
Member

not sure if John has any more comments.

Only that tests would be nice. But I think you said you will work on setting up the test framework and then we can land this on top of that.

@nejch
Copy link
Member

nejch commented Jan 14, 2022

Hey @sattlerc I'm really sorry for the mixup here, I prepared the environment in #1833 and was then eager to get this one merged, so I rebased and amended the commit to reflect the new method name. But I pushed to your fork too early and github auto-closed the PR so I can't push/reopen anymore :(

We've recreated it here https://github.com/python-gitlab/python-gitlab/pull/1837/files and you remain the author of the feature commit. I hope this is ok with you 🙇

@sattlerc
Copy link
Contributor Author

Don't worry about it.

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.

4 participants