Giter Club home page Giter Club logo

emacs-gitlab's Introduction

emacs-gitlab

License GPL 3 Coverage Status

Master :

  • MELPA Stable
  • Circle CI

Develop:

  • Melpa Status
  • Circle CI

Package gitlab provides a REST client to the Gitlab API.

Installation

Installation via package.el

package.el is the built-in package manager in Emacs.

emacs-gitlab is available on the two major community maintained repositories - MELPA STABLE, MELPA.

You can install gitlab with the following commnad:

M-x package-install [RET] gitlab [RET]

or by adding this bit of Emacs Lisp code to your Emacs initialization file (.emacs or init.el):

(unless (package-installed-p 'gitlab)
  (package-install 'gitlab))

If the installation doesn't work try refreshing the package list:

M-x package-refresh-contents [RET]

Keep in mind that MELPA packages are built automatically from the master branch, meaning bugs might creep in there from time to time. Never-the-less, installing from MELPA is the recommended way of obtaining emacs-gitlab, as the master branch is normally quite stable and "stable" (tagged) builds are released somewhat infrequently.

With the most recent builds of Emacs, you can pin emacs-gitlab to always use MELPA Stable by adding this to your Emacs initialization:

(add-to-list 'package-pinned-packages '(gitlab . "melpa-stable") t)

Via el-get

el-get is another popular package manager for Emacs. If you're an el-get user just do M-x el-get-install [RET] gitlab [RET].

Manual

You can install emacs-gitlab manually by placing it on your load-path and require ing it. Many people favour the folder ~/.emacs.d/vendor.

(add-to-list 'load-path "~/.emacs.d/vendor/")
(require 'gitlab)

Usage

  • Setup your Gitlab configurations :

      $ (setq gitlab-host "https://gitlab.com"
              gitlab-token-id "foo")
    
  • Show user's projects with helm interface:

      $ M-x helm-gitlab-projects
    

projects

  • Show user's issues with helm interface:

      $ M-x helm-gitlab-issues
    
  • Open current issue:

      $ M-x gitlab-open-issue
      $ o
    
  • Close current issue:

      $ M-x gitlab-close-issue
      $ c
    

Development

Cask

gitlab use Cask for dependencies management. Install it and retrieve dependencies :

$ curl -fsSkL https://raw.github.com/cask/cask/master/go | python
$ export PATH="$HOME/.cask/bin:$PATH"
$ cask

Tests

  • Setup your Gitlab informations :

      $ cat $HOME/.emacs-gitlab.rc
      #!/bin/bash
      export GITLAB_HOST="https://gitlab.com"
      export GITLAB_TOKEN_ID="yourtokenid"
      export GITLAB_PROJECT_ID=111222
      export GITLAB_PROJECT_NAME="myproject"
      export GITLAB_PROJECT_DESCRIPTION="a project description"
      export GITLAB_ISSUE_ID=145645
      export GITLAB_ISSUE_TITLE="the issue title"
    
  • Launch unit tests :

      $ . $HOME/.emacs-gitlab.rc
      $ make clean test
    

Support / Contribute

See here

Changelog

A changelog is available here.

License

See LICENSE.

Contact

Nicolas Lamirault [email protected]

emacs-gitlab's People

Contributors

chrycheng avatar drym3r avatar marcinant avatar nlamirault avatar purcell avatar stephenwithav avatar tangxinfa avatar tarsius avatar vindarel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emacs-gitlab's Issues

CI build output

Ok, this might be a little bit of a pie in the sky wishlist, but...

I was just iterating over some code in emacs, using magit to push my code, then having to switch to my browser to go to my gitlab instance, to go to the CI pipelines page, then click on the job and watch the build output. I was having to do this over and over, when I thought... wouldn't it be nice if I could just push via magit, and a little minibuffer window would pop up in emacs with the build output of my gitlab CI job, updating in real-time?

Yes, that would be cool.

So I searched around to see if someone had already done this, but I didn't find anything, just your nice work here which I am excited to use, but it doesn't seem to have CI output functionality, so I thought I'd fire this issue off to see if christmas might come early :)

POST /session moved permanently gitlab.com

Hey,
it's official I can't get my session token. With gitlab.com I get a "301 moved permanently error".

Do you confirm the doc of the readme is working ?

the line

$ curl http://yourgitlabhost/api/v3/session/ --data-urlencode 'login=yourUserName' --data-urlencode 'password=yourPassword'

looks wrong to me because gitlab wants a POST (so without urlencode I guess). But a command like

curl -X POST http://www.gitlab.com/api/v3/session --data "login=me" --data "password=xxx"

gives the same error.

Am I doing something wrong ? Thanks !

Wrong package name

This package is available on MELPA as 'gitlab' and not 'emacs-gitlab' as described in README.

Do not signal lisp error on http error

Currently emacs-gitlab signals error when status-code is not equal to expected one.

Problem is that it stops lisp execution. So, if we loop repositories and some repo is not available for some reason (ie. server down) then lisp stops on first error.

IMHO this is wrong and I'm going to send PR with code to change this behaviour.

Mocking `request` in the tests

There is no mocking in the tests currently. One would need to set up a GitLab account and set up the expected data order to be able to run all of the tests successfully. Mocking request would allow us to uncouple the tests from an actual GitLab instance. We will only need to verify that the correct arguments are passed to request and to ensure that the expected values are returned. We would need to migrate the tests to emacs-buttercup. It's the only Emacs test framework I'm aware of that has mocking capabilities. Here is how test-list-issues would look like, for example:

(describe "Issues API"

  :var (expected-response)

  (before-each
    (setq gitlab-host "GitLab host"
          gitlab-token-id "GitLab token ID"
          expected-response (make-request-response))
    (setf (request-response-status-code expected-response) 200)
    (spy-on 'request :and-return-value expected-response))

  (it "lists issues"
    (setf (request-response-data expected-response) '(((project_id . 1)
                                                       (title . "issue 1"))
                                                      ((project_id . 2)
                                                       (title . "issue 2"))))
    (let* ((page 1)
           (per-page 20)
           (issues (gitlab-list-issues page per-page)))
      (expect (length issues) :to-equal-or-exceed 0)
      (mapcar (lambda (i)
                (expect (assoc-default 'title i) :not :to-equal "")
                (expect (assoc-default 'project_id i) :to-be-a-number)
                (message "Issue: %s" (assoc-default 'title i)))
              issues)
      (expect 'request
              :to-have-been-called-with
              (concat gitlab-host "/api/v4/issues")
              :type "GET"
              :headers `(("PRIVATE-TOKEN" . ,gitlab-token-id)
                         ("connection" . "close"))
              :sync t
              :params `((page . ,(number-to-string page))
                        (per_page . ,(number-to-string per-page)))
              :parser 'json-read))))

What do you think?

login with gitlab.com

Hi,

I just installed emacs-gitlab and configured my login/password, but when I do M-x gitlab-login, I get:

REQUEST [error] Error (error) while connecting to http://gitlab.com/api/v3/session.
gitlab-login: HTTP Error: 401, nil

Indeed, if I browse that URL, it appears empty

Support gitlabs link headers to fetch all results

The gitlab api has a http header named Link ( http://www.w3.org/wiki/LinkHeader ) which looks like this for a first result page:

<http://gitlab.../api/v3/issues?page=2&per_page=0>; rel="next", <http://gitlab.../api/v3/issues?page=1&per_page=0>; rel="first", <http://gitlab.../api/v3/issues?page=12&per_page=0>; rel="last"

If alot of requests might be required to reach a full result list emacs-gitlab should probably be converted to async/lexical scope first so that emacs doesn't freeze up while reqests are being fetched.

404 on login

I have the following in my config.org, When I run gitlab-login I get a 404 error.

(setq gitlab-host "https://gitcrate.org"
      gitlab-username "gregf"
      gitlab-passowrd "super_secure")
(use-package gitlab
  :ensure t)

Getting Request [ERROR] when getting issues or projects

I originally tested this on a local gitlab instance, but after that failed I tried it on the official server and i'm seeing the same thing.

REQUEST [error] Error (error) while connecting to https://gitlab.com/api/v4/issues
gitlab-list-issues: Wrong type argument: number-or-marker-p, nil

I can browse that url fine and it's able to access the data, so i'm not real sure what the problem is. I've tested on emacs 25.3 and 26.1

open to PR adding functionality?

hi, i have an emacs package that i would like to merge into emacs-gitlab.

https://github.com/bryanwb/emacs-glop provides a function to open the file at point in gitlab or to copy the url to the kill-ring. This is a bit different than the functionality that emacs-gitlab currently provides. Would you be open to a PR that adds this additional functionality?

[ TODO] Support gitlab webhooks to receive events from gitlab server

As in topic.

Create network process in Emacs an listen for webhooks.

Some initial code base:

       (defvar listen-port 10000
           "port of the server")

       (defun listen-start nil
           "starts an emacs tcp client listener"
           (interactive)
           (make-network-process :name "listen"
                                 :buffer "*listen*"
                                 :family 'ipv4
                                 :service listen-port
                                 :sentinel 'listen-sentinel
                                 :filter 'listen-filter
                                 :server 't))

       (defun listen-stop nil
         "stop an emacs tcp listener"
         (interactive)
         (delete-process "listen"))

       (defun listen-filter (proc string)
         (message string))

       (defun listen-sentinel (proc msg)
         (when (string= msg "connection broken by remote peer\n")
           (message (format "client %s has quit" proc))))

With this code we can establish bidirectional synchronization with Gitlab server. We can send events via API and receive events via network-process.

List opened issues

Hi !
So I'm making my way around this package.
But I'm lacking a way to list all opened issues of a project, or I'm lacking a way to set custom query arguments to an api call.

For example, in gitlab-list-project-issues, the code calls the /issues endpoint when we should add /api?state=opened. The function only has page and per-page arguments.

Looks like we need to effectively pass as argument to the function params that is defined in the function body.

Feature request: Ivy support

Hi,

is there any chance this package will support other completion mechanisms? In particular, I'm talking about Ivy.

Just asking. :)

Please add a prefix to test-helper.el to avoid conflicts with 68 other packages

There exist at least 69 packages that contain a file named test-helper.el that also provides the feature test-helper.

This leads to issues for users who have at least two of these packages installed. It is unlikely that such a user would be able to run the tests of all of those packages. If the primary test file of one of those packages does (require 'test-helper), then it is undefined which of the various test-helper.el files gets loaded. Which it is, depends on the order of the load-path.

To avoid this conflicts, you should rename your test-helper.el to <your-package>-test-helper.el and adjust the feature accordingly.

Also don't forget to update the require form in your primary test file and/or update references to the library/feature elsewhere. Also, if your primary test file is named something like test.el, then please consider renaming that too (same for any other utility elisp files your repositoroy may contain).

Thanks!

PS: This issue is a bit generic because I had to open 69 issues.

When installed from ELPA, fails unless I manually install 'f' package

I've done this:

(unless (package-installed-p 'gitlab)
  (package-install 'gitlab))

and the

(require 'gitlab)

dies with an error from the bowels where basically

(require 'f)

fails as f package is not installed.

My fix was to add

;; its a bug in my opinion
(unless (package-installed-p 'f)
  (package-install 'f))

to my init file. Seems like a bug somewhere, but with a simple workaround

Fetch project issues when we don't know the project id (and more doc)

Hi,
I installed the latest melpa version (20151202.38) and used some functions with success. Awesome !

I don't really understand what are the use cases. Please provide more doc ! Specifically, how to use helm-gitlab-issues in the commit message ? Appart from this method not working for me, I didn't get it.

Most of all I want to fetch the issues of a given project. I found out how to call gitlab-list-projects, search manually for the project id I'm interested in and then (gitlab-list-project-issues the-id). So how can one get automatically the project id ? I didn't see a method for that, is there one ? I'd think there's one, because in the package helm-gitlab there's the method helm-gitlab-project-issues which is supposed to list the issues of a given project I suppose (don't know, it isn't working, just returning a void list).

And can we get the project issues with only one server call ? Gitlab's api doesn't look very convenient to work with if it requires IDs.

Thanks !
Regards

ps: you forgot to tell in the readme that we should install another package, helm-gitlab.

Do not signal lisp error on http error

emacs-gitlab signals error when status-code is not equal to expected one.

Problem is that it stops lisp execution. So, if we loop repositories and some repo is not available for some reason (ie. server down) then lisp stops on first error.

IMHO this is wrong and I'm going to send PR with code to change this behaviour.

gitlab-show-projects crashes if owner column is nil

I do not currently know why its nil.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-width(nil)
  tabulated-list-print-col(1 nil 28)
  tabulated-list-print-entry("311" ["somethingdocker-drone" nil "docker-containers" "Docker configuration for https://drone.something.se"])
  apply(tabulated-list-print-entry ("311" ["somethingdocker-drone" nil "docker-containers" "Docker configuration for https://drone.something.se"]))
  tabulated-list-print(t)
  gitlab-show-projects()
  call-interactively(gitlab-show-projects record nil)
  command-execute(gitlab-show-projects record)
  execute-extended-command(nil "gitlab-show-projects")
  ...

Package not present nor available with el-get

I would like to say thank you firstly for providing this integration of gitlab with emacs.

However, I simply would like to point out that the instructions for installing the extension with package or with el-get are not working. The package is simply not available.

I use emacs from the git repo, 25.2.50.1

Perhaps a commit needs to be made to the recipe list for el-get? There is banner showing MELPA compliance but it is not showing up with M-x package-list-packages

If this could be fixed it would make the extension available to a wider audience.

Various language

My emacs with your extension is not able to display an any text. This is a issue on russian language:
image

Thanks!

Caching ?

Hi,

Do you plan to do some caching of the api results, and if so how would you implement it ?

all tests fail when running cask

Hi! when i run make clean test all test fail w/ the following error.

All tests pass if I copy request.el into the same directory as the gitlab-*.el files

Adding (depends-on "cask") to the Cask file does not solve the problem

I could probably easily fix this if I knew more about cask :(

[gitlab] Cleanup path
Suppression path /Users/hitman/.emacs.d/vendor/emacs-gitlab
[gitlab] Load library from /Users/hitman/.emacs.d/vendor/emacs-gitlab/gitlab.el
FTest test-open-session backtrace:

  require(gitlab-http)
  eval-buffer(#<killed buffer> nil "/Users/hitman/.emacs.d/vendor/emac
  load-with-code-conversion("/Users/hitman/.emacs.d/vendor/emacs-gitla
  require(gitlab "/Users/hitman/.emacs.d/vendor/emacs-gitlab/gitlab.el
  (let ((path (s-concat gitlab-source-dir file))) (message (ansi-yello
  load-library("/gitlab.el")
  (let ((default-directory gitlab-source-dir)) (cleanup-load-path) (lo
  (condition-case nil (let ((default-directory gitlab-source-dir)) (cl
  (unwind-protect (condition-case nil (let ((default-directory gitlab-
  (lambda nil (unwind-protect (condition-case nil (let ((default-direc
  #[0 "\306\307!r\211q\210\310\311\312\313\314\315��!\316\"\317\320%DC
  funcall(#[0 "\306\307!r\211q\210\310\311\312\313\314\315��!\316\"\31
  ert--run-test-internal([cl-struct-ert--test-execution-info [cl-struc
  #[0 "r\304 q\210\305 )\306\307\310\311\312\313��!\314\"\315\316%DC\2
  funcall(#[0 "r\304 q\210\305 )\306\307\310\311\312\313��!\314\"\315\
  ert-run-test([cl-struct-ert-test test-open-session nil (lambda nil (
  ert-run-or-rerun-test([cl-struct-ert--stats (and t) [[cl-struct-ert-
  ert-run-tests((and t) (lambda (event-type &rest event-args) (cond ((
  ert-runner/run-tests-batch((and t))
  (let ((stats (ert-runner/run-tests-batch selector))) (kill-emacs (if
  ert-runner/run-tests-batch-and-exit((and t))
  (if ert-runner-verbose (ert-runner/run-tests-batch-and-exit ert-runn
  (let ((test-files (ert-runner--test-files tests)) (test-helper (f-ex
  ert-runner/run()

 apply(ert-runner/run nil)
  commander--handle-command(nil)
  commander-parse(nil)
  (if commander-parsing-done nil (commander-parse (or commander-args (
  (progn (setq commander-default-config nil) (setq commander-options n
  eval-buffer(#<buffer  *load*> nil "/Users/hitman/.emacs.d/vendor/ema
  load-with-code-conversion("/Users/hitman/.emacs.d/vendor/emacs-gitla
  load("/Users/hitman/.emacs.d/vendor/emacs-gitlab/.cask/24.5.1/elpa/e
  command-line-1(("-scriptload" "/Users/hitman/.emacs.d/vendor/emacs-g
  command-line()
  normal-top-level()

Test test-open-session condition:

    (file-error "Cannot open load file" "No such file or directory" "request")

Purpose / workflows

After installing it, I get a list of projects with helm-gitlab-projects and selecting one opens it in a browser, same for issues. Is that the purpose of the project or am I missing something?

I think it would be great to describe in the readme how to use the tools and for what purpose.

Please support authinfo for login

Hello,

it would be awesome to protect our login information inside a GPG protected file like the .authinfo.gpg file.

Thank you.
Xavier

gitlab-list-all-project-issues can not be used interactively

(defun gitlab-list-all-project-issues (project-id &optional page per-page)
"Get a list of all PROJECT-ID issues.
PROJECT-ID : The ID of a project
PAGE: current page number
PER-PAGE: number of items on page max 100"
(interactive)

This function is declared interactive, but trying to invoke it fails because the interactive decl doesn't provide the mandatory argument.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.