Skip to content

Commit

Permalink
Merge pull request #11 from nlamirault/develop
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
nlamirault committed May 29, 2015
2 parents 8fe1cc4 + 76fb0f9 commit f28c8d8
Show file tree
Hide file tree
Showing 27 changed files with 667 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ env:
- EMACS=emacs24
- EMACS=emacs-snapshot
script:
- make ci
- make test
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ try to follow these guidelines when you do so.

* Read [how to properly contribute to open source projects on Github][2].
* Use a topic branch to easily amend a pull request later, if necessary.
(based on *develop* branch)
* Write [good commit messages][3].
* Use the same coding conventions as the rest of the project.
* Verify your Emacs Lisp code with `checkdoc`.
Expand Down
25 changes: 23 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
# emacs-gitlab ChangeLog

# Version 0.2.0 (12/22/2014)
## Version 0.4 (05/29/2015)

- Initial support for Users API (Thanks [marcinant][])
- ``FIX`` unit tests on Issues API
- Support Notes API (Thanks [marcinant][])
- Support Milestone API (Thanks [marcinant][])

## Version 0.3 (04/19/2015)

- ``#8``: Invalid URL for issue project
- Refactoring unit tests (use [ert-runner][] and [overseer][])
- ``#7``: Fixed multiline descriptions breaking tabulated view (Thanks [marcinant][])
- ``#4``: FIX Documentation (Thanks [marcinant][])
- ``#2``: Wrong package name (Thanks [marcinant][])

## Version 0.2.0 (12/22/2014)

- Add issues mode
- Init major mode to display project issues

# Version 0.1.0 (11/06/2014)
## Version 0.1.0 (11/06/2014)

- Helm interface to show issues
- Helm interface to show projects
- Launch unit test to check library version
- Init project


[ert-runner]: https://github.com/rejeep/ert-runner.el
[overseer]: https://github.com/tonini/overseer.el

[marcinant]: https://github.com/marcinant
19 changes: 5 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2014 Nicolas Lamirault <[email protected]>
# Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -58,11 +58,9 @@ elpa:
.PHONY: build
build : elpa $(OBJECTS)

test: build
test: clean build
@echo -e "$(OK_COLOR)[$(APP)] Unit tests$(NO_COLOR)"
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
$(EMACSFLAGS) \
-l test/run-tests
@$(CASK) exec ert-runner

.PHONY: clean
clean :
Expand All @@ -73,24 +71,17 @@ reset : clean
@rm -rf .cask

pkg-file:
$(CASK) pkg-file
@$(CASK) pkg-file

pkg-el: pkg-file
$(CASK) package
@$(CASK) package

package: clean pkg-el
@echo -e "$(OK_COLOR)[$(APP)] Packaging$(NO_COLOR)"
cp dist/$(ARCHIVE) .
gzip $(ARCHIVE)
rm -fr dist

.PHONY: ci
ci : elpa
@echo -e "$(OK_COLOR)[$(APP)] Unit tests with code coverage$(NO_COLOR)"
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
$(EMACSFLAGS) \
-l test/run-tests

%.elc : %.el
@$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
$(EMACSFLAGS) \
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The recommended way to install ``gitlab`` is via [MELPA][]:

or [Cask][]:

(depends-on "emacs-gitlab")
(depends-on "gitlab")


## Usage
Expand All @@ -29,7 +29,8 @@ or [Cask][]:

$ (setq gitlab-host "http://mygitlab.com"
gitlab-username "foo"
gitlab-token-id "...")
gitlab-password "bar"
gitlab-token-id "xxxxxxxxxxxx")

To generate private ``gitlab-token-id`` run:

Expand All @@ -42,10 +43,15 @@ $ curl http://yourgitlabhost/api/v3/session/ --data-urlencode 'login=yourUserNam

$ M-x helm-gitlab-projects

[projects](var/emacs-gitlab-0.3-helm-projects.png)


* Show user's issues with helm interface:

$ M-x helm-gitlab-issues

[issues](var/emacs-gitlab-0.3-helm-issues.png)


## Development

Expand All @@ -66,9 +72,12 @@ management. Install it and retrieve dependencies :
$ export GITLAB_HOST="http://gitlab.foo.com"
$ export GITLAB_USERNAME="foo"
$ export GITLAB_PASSWORD="bar"
$ export GITLAB_PROJECT_ID="11111"
$ export GITLAB_TOKEN_ID="xxxxxxxxxxxxxx"
$ export GITLAB_PROJECT_ID=111222
$ export GITLAB_PROJECT_NAME="myproject"
$ export GITLAB_PROJECT_DESC="a description"
$ export GITLAB_PROJECT_DESCRIPTION="a project description"
$ export GITLAB_ISSUE_ID=145645
$ export GITLAB_ISSUE_TITLE="the issue title"

* Launch unit tests :

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.4.0
12 changes: 9 additions & 3 deletions gitlab-api.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; gitlab-api.el --- Gitlab API settings.

;; Copyright (C) 2014 Nicolas Lamirault <[email protected]>
;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -55,8 +55,14 @@ Use `gitlab-username' or GITLAB_USERNAME environment variable"
Use `gitlab-password' or GITLAB_PASSWORD environment variable"
(if gitlab-password
gitlab-password
(getenv "GITLAB_PASSWORD")))

(getenv "GITLAB_PASSWORD")))

(defun gitlab--get-token-id ()
"Retrieve the Gitlab token ID.
Use `gitlab-token-id' or GITLAB_TOKEN_ID environment variable"
(if gitlab-token-id
gitlab-token-id
(getenv "GITLAB_TOKEN_ID")))

(provide 'gitlab-api)
;;; gitlab-api.el ends here
8 changes: 5 additions & 3 deletions gitlab-groups.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@
(defun gitlab-list-groups ()
"Get a list of groups.
As user : my groups, as admin : all groups."
(perform-gitlab-request "groups" nil 200))
(perform-gitlab-request "GET" "groups" nil 200))


(defun gitlab-get-group (group-id)
"Get all details of a group.
GROUP-ID is the ID of a group."
(perform-gitlab-request (s-concat "groups/"
(perform-gitlab-request "GET"
(s-concat "groups/"
(number-to-string group-id))
nil
200))

(defun gitlab-list-group-members (group-id)
"Get a list of group members viewable by the authenticated user.
GROUP-ID is the ID of a group."
(perform-gitlab-request (s-concat "groups/"
(perform-gitlab-request "GET"
(s-concat "groups/"
(number-to-string group-id)
"/members")
nil
Expand Down
84 changes: 77 additions & 7 deletions gitlab-issues.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; gitlab-issues.el --- Issues API

;; Copyright (C) 2014 Nicolas Lamirault <[email protected]>
;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -39,21 +39,27 @@ LABELS - Comma-separated list of label names"
;; (add-to-list params (cons "state" state)))
;; (when labels
;; (add-to-list params (cons "labels" labels)))
(perform-gitlab-request "issues" params 200)))
(perform-gitlab-request "GET" "issues" params 200)))


(defun gitlab--get-issue-uri (project-id issue-id)
"Retrieve URI to retrieve an issue.
PROJECT-ID : The ID of a project
ISSUE-ID : The ID of a project issue"
(s-concat "projects/"
(number-to-string project-id)
(url-hexify-string
(format "%s" project-id))
"/issues/"
(number-to-string issue-id)))
issue-id))

(defun gitlab-list-project-issues (project-id)
"Get a list of project issues.
PROJECT-ID : The ID of a project"
(perform-gitlab-request (s-concat "projects/"
(number-to-string project-id)
(perform-gitlab-request "GET"
(s-concat "projects/"
(url-hexify-string
(format "%s" project-id))
"/issues")
nil
200))
Expand All @@ -63,10 +69,74 @@ PROJECT-ID : The ID of a project"
PROJECT-ID : The ID of a project
ISSUE-ID : The ID of a project issue"
(perform-gitlab-request (gitlab--get-issue-uri project-id issue-id)
(perform-gitlab-request "GET"
(gitlab--get-issue-uri
(url-hexify-string
(format "%s" project-id))
(format "%s" issue-id))
nil
200))

(defun gitlab-create-issue (project-id title &optional description assignee milestone labels)
"Create a project issue.
PROJECT-ID the ID or NAMESPACE%2FPROJECT_NAME of a project
TITLE issue title
DESCRIPTION issue description
ASSIGNEE assignee ID
MILESTONE milestone ID
LABELS comma-separated list label names"
(lwarn '(gitlab) :debug "Create ISSUE in project: %s" project-id)
(perform-gitlab-request "POST"
(format "projects/%s/issues"
(url-hexify-string
(format "%s" project-id)))
(format "title=%s%s"
title
(concat
(when description
(format "&description=%s" description))
(when assignee
(format "&assignee_id=%s" assignee))
(when milestone
(format "&milestone_id=%s" milestone))
(when labels
(format "&labels=%s" labels))
))
201))

(defun gitlab-edit-issue (project-id issue-id &optional title description assignee-id milestone-id labels state-event)
"Create a project issue.
PROJECT-ID the ID or NAMESPACE%2FPROJECT_NAME of a project
TITLE issue title
DESCRIPTION issue description
ASSIGNEE assignee ID
MILESTONE milestone ID
LABELS comma-separated list label names"
(lwarn '(gitlab) :debug "UPDATE ISSUE in project: %s\n" project-id)
(perform-gitlab-request "PUT"
(format "projects/%s/issues/%s"
(url-hexify-string
(format "%s" project-id))
issue-id)

(format "%s"
(concat
(when title
(format "&title=%s" title))
(when description
(format "&description=%s" description))
(when assignee-id
(format "&assignee_id=%s" assignee-id))
(when milestone-id
(format "&milestone_id=%s" milestone-id))
(when labels
(format "&labels=%s" labels))
(when state-event
(format "&state_event=%s" state-event))))
200))


(provide 'gitlab-issues)
;;; gitlab-issues.el ends here
Loading

0 comments on commit f28c8d8

Please sign in to comment.