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 #1

Closed
adamgoose opened this issue Apr 28, 2017 · 5 comments
Closed

GitLab Integration #1

adamgoose opened this issue Apr 28, 2017 · 5 comments

Comments

@adamgoose
Copy link

I see that you have GitLab on your ToDo list, however I have been tracking GitLab integration on a similar Chrome Plugin. Take a peek:

ovity/octotree#265
https://gitlab.com/gitlab-org/gitlab-ce/issues/13723

RepoSplit is a bit different than OctoTree, and would probably be easier to implement since you're not really integrating into the GitLab UI. Your plugin looks great, and I would love to be able to use it with GitLab! Hope it pans out.

@git-toni
Copy link
Owner

Hi Adam,

Agreed, Gitlab inrtegration should be a priority. I will have a look at the API and try to implement the integration asap.
Octotree looks fantastic, and since it's appending a tree to the existing UI, it has the advantage of providing also Issues, PR's, etc indicators. Reposplit's main focus was on code browsing, but I reckon that Issues, PR's, etc can also be pleasantly placed somewhere in the UI eventually.

I'll be sure to link RepoSplit in that Gitlab discussion once integration is finished!

@git-toni
Copy link
Owner

@adamgoose I just had a try at the Gitlab API, I raised a question in their CE issues section. I'll paste it here for you as well, since you've been tinkering with it already.

I'm faced with two issues:

  1. Authentication question

On one hand the main API docs page states:

All API requests require authentication via a session cookie or token. 
There are three types of tokens available: private tokens, OAuth 2 tokens, and personal access tokens.

And on the other hand the API Repositories page reads:

Get a list of repository files and directories in a project. 
This endpoint can be accessed without authentication if the repository is publicly accessible.

Which one is it?

  1. API URL

When accessing a public repo such as buble. How would the API base URL be? I can see in the docs that the endpoint would be /projects/:id/repository/tree, but I can't seem to find the whole URL in the docs, the non-endpoint of the API Request is only refered as https://gitlab.example.com/api/v4.

I tried https://api.gitlab.com/api/v4/projects/:projectid/repository/tree, but no luck. I guess I'm missing something really obvious here :/

@adamgoose
Copy link
Author

Regarding authentication: I'd recommend you ask users to provide a Personal Access Token, and then use it to access the API. Your extension should support multiple PATs, one per GitLab domain (we don't use gitlab.com, rather a self-hosted instance).

The API url is not on a subdomain, rather a path prefix. Thus, the following CURLs demonstrate how to make an API Call using a PAT.

curl --header "PRIVATE-TOKEN: {token_here}" https://gitlab.com/api/v4/projects

OR

curl https://gitlab.com/api/v4/projects?private_token={token_here}

Lastly, GitLab's API uses Project IDs instead of user/repo. I hope you can find a better way to obtain the Project ID off the page, but if not, see the following headers available on the home page of the aforementioned repository:

<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="object" property="og:type">
<meta content="GitLab" property="og:site_name">
<meta content="Rich Harris / buble" property="og:title">
<meta content="The blazing fast, batteries-included ES2015 compiler" property="og:description">
<meta content="https://gitlab.com/uploads/project/avatar/1031540/favicon.png" property="og:image">
<meta content="https://gitlab.com/Rich-Harris/buble" property="og:url">
<meta content="summary" property="twitter:card">
<meta content="Rich Harris / buble" property="twitter:title">
<meta content="The blazing fast, batteries-included ES2015 compiler" property="twitter:description">
<meta content="https://gitlab.com/uploads/project/avatar/1031540/favicon.png" property="twitter:image">

I guess you could pull it out of the avatar URL?

@git-toni
Copy link
Owner

git-toni commented May 1, 2017

Thanks for the reply! I'll give it a try soone :)

@git-toni
Copy link
Owner

Hi @adamgoose,
Reposplit v0.2.0+can now browse Gitlab repositories as well! Albeit only public ones so far.
Please if you have any feedback regarding this let me know

@git-toni git-toni closed this as completed Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants