-
Notifications
You must be signed in to change notification settings - Fork 669
feat: add support for /import/github #959
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
feat: add support for /import/github #959
Conversation
Thanks for the MR. I think we should follow the GitLab API as closely as possible, without adding helpers to keep it as thin of a layer as possible. Then we could also remove the dependency to another API wrapper library. It should be implemented like descriped here: https://docs.gitlab.com/ee/api/import.html#import-repository-from-github. API requests can be faked pretty easily as test, like done here: https://github.com/python-gitlab/python-gitlab/blob/master/gitlab/tests/test_gitlab.py#L757 |
Ok, no problem, I can clean out the |
@max-wittig i'm not quite familiar with this error (see failed pipeline build), and it doesn't look like its anywhere near code that i've touched. Do you have a moment to take a look? I can dig deeper too, but I wanted to check first if this is a known issue. |
Left a few comments. |
As requested in an outdated discussion: i've lightly modified the base |
@andrew-littlebits Sorry for letting you wait so long. LGTM. Could you just rebase your branch to the latest master? Thanks! |
Addresses #952 This adds a method to the `ProjectManager` called `import_github`, which maps to the `/import/github` API endpoint. Calling `import_github` will trigger an import operation from <repo_id> into <target_namespace>, using <personal_access_token> to authenticate against github. In practice a gitlab server may take many 10's of seconds to respond to this API call, so we also take the liberty of increasing the default timeout (only for this method invocation). Unfortunately since `import` is a protected keyword in python, I was unable to follow the endpoint structure with the manager namespace. I'm open to suggestions on a more sensible interface. I'm successfully using this addition to batch-import hundreds of github repositories into gitlab.
On startup, the `timeout` parameter is loaded from config and stored on the base gitlab object instance. This instance parameter is used as the timeout for all API requests (it's passed into the `session` object when making HTTP calls). This change allows any API method to specify a `timeout` argument to `**kwargs` that will override the global timeout value. This was somewhat needed / helpful for the `import_github` method. I have also updated the docs accordingly.
@max-wittig no worries, thank you for walking me through the process! I've rebased and lightly squashed. |
Addresses #952
This adds a method to the
ProjectManager
calledimport_github
, which maps to the/import/github
API endpoint. Callingimport_github
will trigger an import operation from <repo_id> into <target_namespace>, using <personal_access_token> to authenticate against github. In practice a gitlab server may take many 10's of seconds to respond to this API call, so we also take the liberty of increasing the default timeout (only for this method invocation).Unfortunately since
import
is a protected keyword in python, I was unable to follow the endpoint structure with the manager namespace (eg:gitlab.import.github
is not allowed`). I'm open to suggestions on a more sensible interface.I'm successfully using this addition to batch-import hundreds of github repositories into gitlab. I didn't see any low-hanging-fruit way to add a unit test for this - please advise if this is acceptable.