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

GitLab Integration #3327

Merged
merged 43 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ef9c792
Add GitLab repo sync and webhook support
Jan 9, 2016
cf5c47c
oauth: gitlab: use unicode whenever format is used
BenoitKnecht Jun 16, 2016
2356d84
oauth: gitlab: prevent duplicate entries after sync
BenoitKnecht Jun 20, 2016
7113e94
oauth: gitlab: avoid KeyError when owner is missing
BenoitKnecht Jun 20, 2016
5d7d6c1
oauth: gitlab: setup_webhook must return a tuple
BenoitKnecht Jun 20, 2016
f9df35e
oauth: gitlab: set a default avatar if none is returned
BenoitKnecht Jun 20, 2016
e4adb98
oauth: gitlab: use SSH url if repo is private
BenoitKnecht Jun 20, 2016
da7471f
Added tests for the GitLabService
Aug 5, 2016
aec6941
Added some documentation for the Gitlab integration
Aug 5, 2016
9152bb6
Merge pull request #1 from galileo-press/sync-gitlab-repos
saily Aug 5, 2016
299a2b5
Improved url_pattern of the GitLabService to support private reposito…
Aug 5, 2016
8a10848
Fixed linting error
Aug 5, 2016
97a4fb1
Simplified exception handling
Aug 10, 2016
dff4d7d
Use PRODUCTION_DOMAIN as webhook id
Aug 10, 2016
4fbe6bb
Make imports python3 compatible
Aug 10, 2016
50285fe
Use the GitLab project ID, not the PRODUCTION_DOMAIN
Aug 10, 2016
e288bf3
Merge pull request #2 from galileo-press/sync-gitlab-repos
saily Oct 5, 2016
6c8d1c3
Update urls as mentioned in comments
Oct 19, 2016
0cb1ed5
Update webhook docs as mentioned in comments
saily Oct 19, 2016
435e870
Merge branch 'sync-gitlab-repos' of https://github.com/saily/readthed…
humitos Nov 27, 2017
c33b691
Style changes
humitos Nov 27, 2017
be5ccd0
New interface for paginated results
humitos Nov 27, 2017
7e38e70
Improve gitlab integration's code
humitos Nov 27, 2017
90e4ba1
Fix sync orgs and webhook create
humitos Nov 28, 2017
1e8a8a8
Fix webhook URL
humitos Nov 28, 2017
2fa1c51
Update webhook workflow for GitLab
humitos Nov 28, 2017
39c9899
Merge branch 'master' of github.com:rtfd/readthedocs.org into humitos…
humitos Nov 28, 2017
c2f16d6
Better yapf setting to fulfill PEP257 D202
humitos Nov 28, 2017
e77efa4
Lint fix
humitos Nov 28, 2017
b1ff48c
Remove default avatars for GitLab
humitos Nov 28, 2017
4db7339
Do not use REGEX to get owner and repo
humitos Nov 28, 2017
5e5a6c8
Merge branch 'master' of github.com:rtfd/readthedocs.org into humitos…
humitos Nov 28, 2017
b8e1b25
Fix GitLab tests
humitos Nov 28, 2017
ad6ba74
Mock `is_owned_by` properly
humitos Nov 28, 2017
66f8ea2
Added button to Import Project dashboard
humitos Nov 28, 2017
237531c
Feedback on docs
humitos Nov 28, 2017
4e6f4a6
Fix isort settings
humitos Nov 28, 2017
0ce1702
Fix lint
humitos Nov 29, 2017
1e668e1
Styles / Linting
humitos Dec 4, 2017
4eec51e
Context for GitLab on templates
humitos Dec 4, 2017
1e5200e
Merge branch 'master' of github.com:rtfd/readthedocs.org into humitos…
humitos Dec 4, 2017
12eae4b
More style
humitos Dec 5, 2017
3d276dd
Test for get_gitlab_url
humitos Dec 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore = E125,D100,D101,D102,D105,D200,D211,P101,FI15,FI16,FI12,FI11,FI17,FI50,FI53,FI54
ignore = E125,D100,D101,D102,D103,D105,D107,D200,D202,D211,P101,FI15,FI16,FI12,FI11,FI17,FI50,FI53,FI54,MQ101,T000
max-line-length = 80
4 changes: 1 addition & 3 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ line_length=80
indent=' '
multi_line_output=4
default_section=FIRSTPARTY
known_readthedocs=readthedocs
known_readthedocsinc=readthedocsinc
known_third_party=celery,stripe,requests,pytz,builtins,django,annoying
known_third_party=celery,stripe,requests,pytz,builtins,django,annoying,mock,allauth,oauthlib,requests_oauthlib
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
add_imports=from __future__ import division, from __future__ import print_function, from __future__ import unicode_literals
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repos:
'flake8-string-format',
'flake8-tidy-imports',
'flake8-todo']
exclude: 'test_oauth.py'
Copy link
Member Author

Choose a reason for hiding this comment

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

This file has a lot of long lines that I don't want to fix now :)

- id: trailing-whitespace

- repo: [email protected]:pre-commit/mirrors-yapf.git
Expand Down
2 changes: 1 addition & 1 deletion docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ More information can be found in the :doc:`vcs` page.
Auto-updating
-------------

The :doc:`webhooks` page talks about the different ways you can ping RTD to let us know your project has been updated. We have official support for GitHub, and anywhere else we have a generic post-commit hook that allows you to POST to a URL to get your documentation built.
The :doc:`webhooks` page talks about the different ways you can ping RTD to let us know your project has been updated. We have official support for GitHub, Bitbucket and GitLab, and anywhere else we have a generic post-commit hook that allows you to POST to a URL to get your documentation built.
Copy link
Member

Choose a reason for hiding this comment

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

<3 doc updates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Credits to @saily, the original author :)


Internationalization
--------------------
Expand Down
9 changes: 5 additions & 4 deletions docs/webhooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ receive a webhook notification, we determine if the change is related to an
active version for your project, and if it is, a build is triggered for that
version.

.. _integration-detail:
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to keep this anchor.

GitHub
------
Copy link
Contributor

Choose a reason for hiding this comment

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

No heading here, this is under "Webhook Integrations"


Webhook Integrations
--------------------
Expand Down Expand Up @@ -51,7 +52,7 @@ GitHub
.. note:: The webhook secret is not yet respected

Bitbucket
~~~~~~~~~
Copy link
Contributor

Choose a reason for hiding this comment

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

This alters the nesting negatively. We want to keep this as it was to keep Bitbucket under Webhook Integrations

---------

* Go to the **Settings** page for your project
* Click **Webhooks** and then **Add webhook**
Expand All @@ -61,13 +62,13 @@ Bitbucket
* Finish by clicking **Save**

GitLab
~~~~~~
------
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, revert to ~~~


* Go to the **Settings** page for your project
* Click **Integrations**
* For **URL**, use the URL of the integration on Read the Docs, found on the
:ref:`integration detail page <integration-detail>` page
* Leave the default **Push events** selected
* Leave the default **Push events** selected and mark **Tag push events** also
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, but I think we need the Tag push events here also...

Copy link
Member

Choose a reason for hiding this comment

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

Seems like we'd want them. +1

* Finish by clicking **Add Webhook**

Using the generic API integration
Expand Down
80 changes: 43 additions & 37 deletions media/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ p.build-failure { font-size: .8em; color: #dc1020; margin: 0 0 3px; }
p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; }

.navigable .profile_image { position:relative; left:-8px; top:-1px; width:184px; overflow:hidden; }
.navigable .profile_image img { border-radius:5px; }
.navigable .profile_image img { border-radius:5px; }

.profile #content { padding-top:8px; }
/* build page */
Expand Down Expand Up @@ -551,7 +551,7 @@ p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; }
.navigable > ul > li.active:after { content:"•"; position:absolute; right:8px; top:6px; font-size:1.2em; color:#465158; }

.navigable > ul > li > a:hover { background:#E8ECEF; }
.navigable > div { width:600px; float: left; padding-top:4px; }
.navigable > div { width:600px; float: left; padding-top:4px; }

/* autocomplete */

Expand Down Expand Up @@ -696,6 +696,12 @@ a.socialaccount-provider.github:before {
content: "\f09b";
}

div.project-import-remote form.import-connect-gitlab button:before,
a.socialaccount-provider.gitlab:before {
font-family: FontAwesome;
content: "\f1d3";
}

div.project-import-remote form.import-connect-bitbucket button:before,
a.socialaccount-provider.bitbucket:before,
a.socialaccount-provider.bitbucket_oauth2:before {
Expand Down Expand Up @@ -934,7 +940,7 @@ span.build-state.build-state-failing { color: #a55; }

.edit { cursor: pointer; -webkit-user-select: none; overflow:hidden; position:relative; }
.edit { background:url(../images/edit.png) no-repeat; display:block; width:16px; height:16px; background-size:100% 100%; }
.edit > span {text-indent:-9999em; text-direction:ltr; display:block; }
.edit > span {text-indent:-9999em; text-direction:ltr; display:block; }
body .edit-toggle { display: none; }

.edit-input { display: none; }
Expand Down Expand Up @@ -1018,50 +1024,50 @@ select.dropdown { display: none; }
}

/* CHART LISTS */
.chartlist {
float: left;
border-top: 1px solid #EEE;
.chartlist {
float: left;
border-top: 1px solid #EEE;
width: 15em;
}
.chartlist li {
.chartlist li {
position: relative;
display: block;
border-bottom: 1px solid #EEE;
display: block;
border-bottom: 1px solid #EEE;
_zoom: 1;
}
.chartlist li a {
display: block;
.chartlist li a {
display: block;
padding: 0.4em 4.5em 0.4em 0.5em;
position: relative;
z-index: 2;
position: relative;
z-index: 2;
}
.chartlist .count {
display: block;
position: absolute;
top: 0;
right: 0;
margin: 0 0.3em;
text-align: right;
color: #999;
font-weight: bold;
font-size: 0.875em;
line-height: 2em;
z-index: 5;
.chartlist .count {
display: block;
position: absolute;
top: 0;
right: 0;
margin: 0 0.3em;
text-align: right;
color: #999;
font-weight: bold;
font-size: 0.875em;
line-height: 2em;
z-index: 5;
}
.chartlist .index {
display: block;
position: absolute;
top: 0;
left: 0;
height: 100%;
background: #B8E4F5;
text-indent: -9999px;
overflow: hidden;
.chartlist .index {
display: block;
position: absolute;
top: 0;
left: 0;
height: 100%;
background: #B8E4F5;
text-indent: -9999px;
overflow: hidden;
line-height: 2em;
z-index: 1;
z-index: 1;
}
.chartlist li:hover {
background: #EFEFEF;
.chartlist li:hover {
background: #EFEFEF;
}


Expand Down
1 change: 1 addition & 0 deletions media/images/fa-bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions media/images/fa-users.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions readthedocs/builds/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
"""Utilities for the builds app."""

from __future__ import absolute_import
import re
from __future__ import (
absolute_import, division, print_function, unicode_literals)

import re

GH_REGEXS = [
re.compile('github.com/(.+)/(.+)(?:\.git){1}'),
Expand All @@ -16,6 +18,14 @@
re.compile('bitbucket.org:(.+)/(.+)\.git'),
]

# TODO: I think this can be different than `gitlab.com`
# self.adapter.provider_base_url
GL_REGEXS = [
re.compile('gitlab.com/(.+)/(.+)(?:\.git){1}'),
Copy link
Member Author

Choose a reason for hiding this comment

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

Are we going to support private gitlab instalation? How this should looks like?

Copy link
Contributor

Choose a reason for hiding this comment

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

We will, but this integration will be on the .com, we won't put that code here yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. So, I think the TODO note is good for now. I will leave it there

re.compile('gitlab.com/(.+)/(.+)'),
re.compile('gitlab.com:(.+)/(.+)\.git'),
]


def get_github_username_repo(url):
if 'github' in url:
Expand All @@ -33,3 +43,12 @@ def get_bitbucket_username_repo(url=None):
if match:
return match.groups()
return (None, None)


def get_gitlab_username_repo(url=None):
if 'gitlab' in url:
for regex in GL_REGEXS:
match = regex.search(url)
if match:
return match.groups()
return (None, None)
16 changes: 12 additions & 4 deletions readthedocs/oauth/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Conditional classes for OAuth services"""
# -*- coding: utf-8 -*-
"""Conditional classes for OAuth services."""

from __future__ import (
absolute_import, division, print_function, unicode_literals)

from __future__ import absolute_import
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.oauth.services import github, bitbucket
from readthedocs.oauth.services import bitbucket, github, gitlab


class GitHubService(SettingsOverrideObject):
Expand All @@ -15,4 +18,9 @@ class BitbucketService(SettingsOverrideObject):
_override_setting = 'OAUTH_BITBUCKET_SERVICE'


registry = [GitHubService, BitbucketService]
class GitLabService(SettingsOverrideObject):
_default_class = gitlab.GitLabService
_override_setting = 'OAUTH_GITLAB_SERVICE'


registry = [GitHubService, BitbucketService, GitLabService]
Loading