Skip to content
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

Allow import Gitlab repo manually and set a webhook automatically #3934

Merged
merged 3 commits into from
May 3, 2018

Conversation

humitos
Copy link
Member

@humitos humitos commented Apr 10, 2018

When we import a Project manually we don't have a RemoteRepository associated with that Project, so we use the old technique of getting the username and repo names from the URL using get_gitlab_username_repo function.

This case (Manual Import) won't support custom Gitlab installations in the future with this code.

Closes https://github.com/readthedocs/readthedocs-corporate/issues/265

@humitos humitos requested a review from a team April 10, 2018 22:29
@humitos humitos force-pushed the humitos/webhook/manual-import-gitlab branch from 93c0aae to 573120e Compare April 10, 2018 22:32
@agjohnson agjohnson added this to the 2.4 milestone Apr 11, 2018
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks good. I assume GH/BB do similar already?

@humitos
Copy link
Member Author

humitos commented Apr 18, 2018

Looks good. I assume GH/BB do similar already?

Yes. They are working because they always used the get_username_repo function. In gitlab, I didn't write it directly like that since it could be a custom installation of gitlab so having gitlab.com in the regex wasn't good.

Then, because of that decision we found this issue.

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Noted a spot for some more defensive code.

repo_id = '{username}%2F{repo}'.format(
username=username,
repo=repo,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs error handling and probably some tests. In a case where get_gitlab_username_repo doesn't match, it returns (None, None) and we'll search for repo 'None/None'.

humitos added 3 commits April 24, 2018 09:34
When we import a Project manually we don't have a RemoteRepository
associated with that Project, so we use the old technique of getting
the username and repo names from the URL using
`get_gitlab_username_repo` function.

This case (Manual Import) won't support custom Gitlab installations in
the future with this code.
@humitos humitos force-pushed the humitos/webhook/manual-import-gitlab branch from 573120e to 844b6a9 Compare April 24, 2018 14:47
@humitos
Copy link
Member Author

humitos commented Apr 24, 2018

I just added a test case for this and rebased the branch.

@agjohnson
Copy link
Contributor

Changes and test look good!

@agjohnson agjohnson merged commit 5300c90 into master May 3, 2018
@agjohnson agjohnson deleted the humitos/webhook/manual-import-gitlab branch May 3, 2018 22:31
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.

3 participants