Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
max-wittig merged 2 commits intopython-gitlab:masterfromandrew-littlebits:feat/import-github
Dec 16, 2019
Merged

feat: add support for /import/github#959

max-wittig merged 2 commits intopython-gitlab:masterfromandrew-littlebits:feat/import-github
Dec 16, 2019

Conversation

andrew-littlebits
Copy link

Addresses#952

This adds a method to theProjectManager 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 sinceimport 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.

@max-wittig
Copy link
Member

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

@andrew-littlebits
Copy link
Author

andrew-littlebits commentedDec 4, 2019
edited
Loading

Ok, no problem, I can clean out thePyGithub dependency and add a test. I'll try to get on this shortly.

max-wittig reacted with thumbs up emoji

@andrew-littlebits
Copy link
Author

@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.

@max-wittig
Copy link
Member

Left a few comments.

@andrew-littlebits
Copy link
Author

As requested in an outdated discussion: i've lightly modified the basegitlab object to allowtimeout to be specified inkwargs. This helps to avoid hacky code: instead of needing to change the global timeout parameter for the/import/github API call, I can set it just for that request.

@max-wittig
Copy link
Member

@andrew-littlebits Sorry for letting you wait so long. LGTM. Could you just rebase your branch to the latest master? Thanks!

Andrew Tergis added2 commitsDecember 16, 2019 13:41
Addresses#952This adds a method to the `ProjectManager` called `import_github`, whichmaps to the `/import/github` API endpoint. Calling `import_github` willtrigger an import operation from <repo_id> into <target_namespace>,using <personal_access_token> to authenticate against github. Inpractice a gitlab server may take many 10's of seconds to respond tothis API call, so we also take the liberty of increasing the defaulttimeout (only for this method invocation).Unfortunately since `import` is a protected keyword in python, I was unableto follow the endpoint structure with the manager namespace. I'm open tosuggestions on a more sensible interface.I'm successfully using this addition to batch-import hundreds of githubrepositories into gitlab.
On startup, the `timeout` parameter is loaded from config and stored onthe base gitlab object instance. This instance parameter is used as thetimeout for all API requests (it's passed into the `session` object whenmaking HTTP calls).This change allows any API method to specify a `timeout` argument to`**kwargs` that will override the global timeout value. This wassomewhat needed / helpful for the `import_github` method.I have also updated the docs accordingly.
@andrew-littlebits
Copy link
Author

@max-wittig no worries, thank you for walking me through the process! I've rebased and lightly squashed.

@max-wittigmax-wittig merged commit97e1fca intopython-gitlab:masterDec 16, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@max-wittigmax-wittigAwaiting requested review from max-wittig

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@andrew-littlebits@max-wittig

[8]ページ先頭

©2009-2025 Movatter.jp