[WIP] GitLab addon#5929
Conversation
f20f58e to
bb6542c
Compare
51beba5 to
5f601e6
Compare
mfraezz
left a comment
There was a problem hiding this comment.
A quick set of drive-by comments. Looking pretty good, but I have a few questions about whether or not everything copied from GitHub code is applicable to GitLab.
Please also get the TCI build passing.
Pass complete ![]()
website/addons/gitlab/__init__.py
Outdated
|
|
||
| # Note: Even though GitLab supports file sizes over 1 MB, uploads and | ||
| # downloads through their API are capped at 1 MB. | ||
| MAX_FILE_SIZE = 100 |
There was a problem hiding this comment.
If the above is correct, this should be 1, not 100
website/addons/gitlab/api.py
Outdated
| def user_repos(self, user): | ||
| return self.gitlab.getprojectsowned() | ||
|
|
||
| def my_org_repos(self, permissions=None): |
There was a problem hiding this comment.
Other than being mocked in tests, is this intended to be used anywhere?
website/addons/gitlab/api.py
Outdated
|
|
||
| :param str repo_id: GitLab repository id | ||
| :return: Dict of repo information | ||
| See #TODO: link gitlab docs |
| user if omitted | ||
| :return dict: GitLab API response | ||
| """ | ||
| return self.gitlab.currentuser() |
There was a problem hiding this comment.
Here and elsewhere, if this outgoing request fails (e.g, due to invalid credentials), are any errors being handled gracefully?
website/addons/gitlab/api.py
Outdated
| :return: List of branch dicts | ||
| http://developer.github.com/v3/repos/#list-branches | ||
| """ | ||
| # TODO |
|
|
||
| <h4 class="addon-title"> | ||
| <img class="addon-icon" src=${addon_icon_url}> | ||
| <span data-bind="text: properName"></span> <!-- TODO: Can we use mako addon_full_name as some other addons do? --> |
There was a problem hiding this comment.
TODO: Can we use mako addon_full_name
Probably, yes.
|
|
||
|
|
||
| # TODO: Test remaining CRUD methods | ||
| # TODO: Test exception handling |
website/addons/gitlab/tests/utils.py
Outdated
| settings.repo = 'abc' | ||
| settings.user = 'octo-cat' | ||
|
|
||
| # TODO: allow changing the repo name |
| self.node_settings.owner.is_registration = True | ||
| assert_false(check_permissions(self.node_settings, self.consolidated_auth, connection, 'master')) | ||
|
|
||
| def check_hook_urls(self, urls, node, path, sha): |
There was a problem hiding this comment.
This probably won't be found by nosetests because the function name doesn't begin with test_
There was a problem hiding this comment.
it is used by tests on https://github.com/CenterForOpenScience/osf.io/pull/5929/files/1fbc939831c5994ea0088cd0303b11ce45868563#diff-7bf832417d62003700f5f44838fc208aR289 and https://github.com/CenterForOpenScience/osf.io/pull/5929/files/1fbc939831c5994ea0088cd0303b11ce45868563#diff-7bf832417d62003700f5f44838fc208aR316
website/addons/gitlab/views.py
Outdated
| urls = {} | ||
|
|
||
| if include_urls: | ||
| # TODO: Move to helper function |
There was a problem hiding this comment.
Is this necessary? It looks like the only other place it's happening is in a test, so I'd probably say it's not.
felliott
left a comment
There was a problem hiding this comment.
Hey @danielneis and @rafaeldelucena!
I'm sending this back for another pass. I hit a few issues trying to run it locally, most of which I think were caused by the Fangorn GitLab root object not having a .data.extra field. I've also made a note of which pieces can be removed in order to target a read-only provider first. We can add that back in after the read-only version is released. The other bit that will need updating when going read-only is the file editor that is constructed when viewing a file on the OSF. See this line from my Bitbucket PR.
Cheers,
@felliott
website/addons/gitlab/model.py
Outdated
| repo_id = fields.StringField() | ||
| hook_id = fields.StringField() | ||
| hook_secret = fields.StringField() | ||
| registration_data = fields.DictionaryField() |
There was a problem hiding this comment.
While working on the Bitbucket addon (also based off GitHub) I noticed this field registration_data and some code below that didn't make sense. It turns out this is code from a loooooooong, long time ago that doesn't do anything anymore and can be removed.
website/addons/gitlab/model.py
Outdated
| self.repo_id = None | ||
| self.hook_id = None | ||
| self.hook_secret = None | ||
| self.registration_data = None |
There was a problem hiding this comment.
See above. This can be deleted.
| var m = require('mithril'); | ||
| var $ = require('jquery'); | ||
| var URI = require('URIjs'); | ||
| var Fangorn = require('js/fangorn'); |
There was a problem hiding this comment.
When you bring this up-to-date with develop-backup, you'll need to change this to var Fangorn = require('js/fangorn').Fangorn;
| var buttons = []; | ||
| function _downloadEvent(event, item, col) { | ||
| event.stopPropagation(); | ||
| var branch = tem.data.extra.ref || item.data.extra.fileSha; |
There was a problem hiding this comment.
typo: tem.data.extra.ref => item.data.extra.ref
There was a problem hiding this comment.
If item is the root folder, it won't necessarily have a data.extra field. You'll need to check if it exists first. If it doesn't you can fallback to item.data.default_branch.
| @@ -0,0 +1,10 @@ | |||
| { | |||
| "gitlab_file_added" : "${user} added file ${path} to GitLab repo ${repo} in ${node}", | |||
There was a problem hiding this comment.
| // Cross browser key codes for the Command key | ||
| var commandKeys = [224, 17, 91, 93]; | ||
|
|
||
| function _uploadUrl(item, file) { |
| return waterbutler.buildTreeBeardUpload(item, file, {branch: branch }); | ||
| } | ||
|
|
||
| function _removeEvent (event, items) { |
| } | ||
| if (tb.options.placement !== 'fileview') { | ||
| // If File and FileRead are not defined dropzone is not supported and neither is uploads | ||
| if (window.File && window.FileReader && item.data.permissions && item.data.permissions.edit) { |
There was a problem hiding this comment.
The 'Upload', 'Create Folder', and 'Delete' buttons can be removed from the read-only addon.
| }, 'View')); | ||
| } | ||
| if (item.data.permissions && item.data.permissions.edit) { | ||
| buttons.push( |
There was a problem hiding this comment.
This button can be removed from the read-only provider.
| } | ||
| } | ||
|
|
||
| if(item.data.provider && !item.data.isAddonRoot && item.data.permissions && item.data.permissions.edit && tb.options.placement !== 'fileview') { |
There was a problem hiding this comment.
'Rename' can be removed from the read-only provider.
10aca21 to
963e9e0
Compare
|
Closing in favor of #7418 , consider this merged. Thanks for all your hard work, @danielneis , @luismulinari , and @rafaeldelucena . |
Purpose
Implement the GitLab addon according to the GitLab Integration Grant Spec at https://gist.github.com/felliott/cc3d48a492c174545b7f
Changes
"This add-on will allow users to specify a GitLab instance to communicate with, and then connect their GitLab account to their OSF account via an OAuth token. Users may then connect a project for which they have admin rights to one of their GitLab-hosted repositories. Users should also be able to change which repository is linked to a given project at any time and revoke permissions from any or all projects as desired."
Side effects
Roadmap