Skip to content

Commit f28c8d8

Browse files
committed
Merge pull request #11 from nlamirault/develop
Release 0.4.0
2 parents 8fe1cc4 + 76fb0f9 commit f28c8d8

27 files changed

+667
-225
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ env:
3232
- EMACS=emacs24
3333
- EMACS=emacs-snapshot
3434
script:
35-
- make ci
35+
- make test

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ try to follow these guidelines when you do so.
1919

2020
* Read [how to properly contribute to open source projects on Github][2].
2121
* Use a topic branch to easily amend a pull request later, if necessary.
22+
(based on *develop* branch)
2223
* Write [good commit messages][3].
2324
* Use the same coding conventions as the rest of the project.
2425
* Verify your Emacs Lisp code with `checkdoc`.

ChangeLog.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
# emacs-gitlab ChangeLog
22

3-
# Version 0.2.0 (12/22/2014)
3+
## Version 0.4 (05/29/2015)
4+
5+
- Initial support for Users API (Thanks [marcinant][])
6+
- ``FIX`` unit tests on Issues API
7+
- Support Notes API (Thanks [marcinant][])
8+
- Support Milestone API (Thanks [marcinant][])
9+
10+
## Version 0.3 (04/19/2015)
11+
12+
- ``#8``: Invalid URL for issue project
13+
- Refactoring unit tests (use [ert-runner][] and [overseer][])
14+
- ``#7``: Fixed multiline descriptions breaking tabulated view (Thanks [marcinant][])
15+
- ``#4``: FIX Documentation (Thanks [marcinant][])
16+
- ``#2``: Wrong package name (Thanks [marcinant][])
17+
18+
## Version 0.2.0 (12/22/2014)
419

520
- Add issues mode
621
- Init major mode to display project issues
722

8-
# Version 0.1.0 (11/06/2014)
23+
## Version 0.1.0 (11/06/2014)
924

1025
- Helm interface to show issues
1126
- Helm interface to show projects
1227
- Launch unit test to check library version
1328
- Init project
29+
30+
31+
[ert-runner]: https://github.com/rejeep/ert-runner.el
32+
[overseer]: https://github.com/tonini/overseer.el
33+
34+
[marcinant]: https://github.com/marcinant

Makefile

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2014 Nicolas Lamirault <[email protected]>
1+
# Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>
22

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

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

6765
.PHONY: clean
6866
clean :
@@ -73,24 +71,17 @@ reset : clean
7371
@rm -rf .cask
7472

7573
pkg-file:
76-
$(CASK) pkg-file
74+
@$(CASK) pkg-file
7775

7876
pkg-el: pkg-file
79-
$(CASK) package
77+
@$(CASK) package
8078

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

87-
.PHONY: ci
88-
ci : elpa
89-
@echo -e "$(OK_COLOR)[$(APP)] Unit tests with code coverage$(NO_COLOR)"
90-
$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
91-
$(EMACSFLAGS) \
92-
-l test/run-tests
93-
9485
%.elc : %.el
9586
@$(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \
9687
$(EMACSFLAGS) \

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The recommended way to install ``gitlab`` is via [MELPA][]:
2020

2121
or [Cask][]:
2222

23-
(depends-on "emacs-gitlab")
23+
(depends-on "gitlab")
2424

2525

2626
## Usage
@@ -29,7 +29,8 @@ or [Cask][]:
2929

3030
$ (setq gitlab-host "http://mygitlab.com"
3131
gitlab-username "foo"
32-
gitlab-token-id "...")
32+
gitlab-password "bar"
33+
gitlab-token-id "xxxxxxxxxxxx")
3334

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

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

4344
$ M-x helm-gitlab-projects
4445

46+
[projects](var/emacs-gitlab-0.3-helm-projects.png)
47+
48+
4549
* Show user's issues with helm interface:
4650

4751
$ M-x helm-gitlab-issues
4852

53+
[issues](var/emacs-gitlab-0.3-helm-issues.png)
54+
4955

5056
## Development
5157

@@ -66,9 +72,12 @@ management. Install it and retrieve dependencies :
6672
$ export GITLAB_HOST="http://gitlab.foo.com"
6773
$ export GITLAB_USERNAME="foo"
6874
$ export GITLAB_PASSWORD="bar"
69-
$ export GITLAB_PROJECT_ID="11111"
75+
$ export GITLAB_TOKEN_ID="xxxxxxxxxxxxxx"
76+
$ export GITLAB_PROJECT_ID=111222
7077
$ export GITLAB_PROJECT_NAME="myproject"
71-
$ export GITLAB_PROJECT_DESC="a description"
78+
$ export GITLAB_PROJECT_DESCRIPTION="a project description"
79+
$ export GITLAB_ISSUE_ID=145645
80+
$ export GITLAB_ISSUE_TITLE="the issue title"
7281

7382
* Launch unit tests :
7483

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.4.0

gitlab-api.el

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; gitlab-api.el --- Gitlab API settings.
22

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

55
;; This program is free software; you can redistribute it and/or
66
;; modify it under the terms of the GNU General Public License
@@ -55,8 +55,14 @@ Use `gitlab-username' or GITLAB_USERNAME environment variable"
5555
Use `gitlab-password' or GITLAB_PASSWORD environment variable"
5656
(if gitlab-password
5757
gitlab-password
58-
(getenv "GITLAB_PASSWORD")))
59-
58+
(getenv "GITLAB_PASSWORD")))
59+
60+
(defun gitlab--get-token-id ()
61+
"Retrieve the Gitlab token ID.
62+
Use `gitlab-token-id' or GITLAB_TOKEN_ID environment variable"
63+
(if gitlab-token-id
64+
gitlab-token-id
65+
(getenv "GITLAB_TOKEN_ID")))
6066

6167
(provide 'gitlab-api)
6268
;;; gitlab-api.el ends here

gitlab-groups.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,23 @@
4141
(defun gitlab-list-groups ()
4242
"Get a list of groups.
4343
As user : my groups, as admin : all groups."
44-
(perform-gitlab-request "groups" nil 200))
44+
(perform-gitlab-request "GET" "groups" nil 200))
4545

4646

4747
(defun gitlab-get-group (group-id)
4848
"Get all details of a group.
4949
GROUP-ID is the ID of a group."
50-
(perform-gitlab-request (s-concat "groups/"
50+
(perform-gitlab-request "GET"
51+
(s-concat "groups/"
5152
(number-to-string group-id))
5253
nil
5354
200))
5455

5556
(defun gitlab-list-group-members (group-id)
5657
"Get a list of group members viewable by the authenticated user.
5758
GROUP-ID is the ID of a group."
58-
(perform-gitlab-request (s-concat "groups/"
59+
(perform-gitlab-request "GET"
60+
(s-concat "groups/"
5961
(number-to-string group-id)
6062
"/members")
6163
nil

gitlab-issues.el

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; gitlab-issues.el --- Issues API
22

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

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

4444

4545
(defun gitlab--get-issue-uri (project-id issue-id)
46+
"Retrieve URI to retrieve an issue.
47+
PROJECT-ID : The ID of a project
48+
ISSUE-ID : The ID of a project issue"
4649
(s-concat "projects/"
47-
(number-to-string project-id)
50+
(url-hexify-string
51+
(format "%s" project-id))
4852
"/issues/"
49-
(number-to-string issue-id)))
53+
issue-id))
5054

5155
(defun gitlab-list-project-issues (project-id)
5256
"Get a list of project issues.
5357
5458
PROJECT-ID : The ID of a project"
55-
(perform-gitlab-request (s-concat "projects/"
56-
(number-to-string project-id)
59+
(perform-gitlab-request "GET"
60+
(s-concat "projects/"
61+
(url-hexify-string
62+
(format "%s" project-id))
5763
"/issues")
5864
nil
5965
200))
@@ -63,10 +69,74 @@ PROJECT-ID : The ID of a project"
6369
6470
PROJECT-ID : The ID of a project
6571
ISSUE-ID : The ID of a project issue"
66-
(perform-gitlab-request (gitlab--get-issue-uri project-id issue-id)
72+
(perform-gitlab-request "GET"
73+
(gitlab--get-issue-uri
74+
(url-hexify-string
75+
(format "%s" project-id))
76+
(format "%s" issue-id))
6777
nil
6878
200))
6979

80+
(defun gitlab-create-issue (project-id title &optional description assignee milestone labels)
81+
"Create a project issue.
82+
83+
PROJECT-ID the ID or NAMESPACE%2FPROJECT_NAME of a project
84+
TITLE issue title
85+
DESCRIPTION issue description
86+
ASSIGNEE assignee ID
87+
MILESTONE milestone ID
88+
LABELS comma-separated list label names"
89+
(lwarn '(gitlab) :debug "Create ISSUE in project: %s" project-id)
90+
(perform-gitlab-request "POST"
91+
(format "projects/%s/issues"
92+
(url-hexify-string
93+
(format "%s" project-id)))
94+
(format "title=%s%s"
95+
title
96+
(concat
97+
(when description
98+
(format "&description=%s" description))
99+
(when assignee
100+
(format "&assignee_id=%s" assignee))
101+
(when milestone
102+
(format "&milestone_id=%s" milestone))
103+
(when labels
104+
(format "&labels=%s" labels))
105+
))
106+
201))
107+
108+
(defun gitlab-edit-issue (project-id issue-id &optional title description assignee-id milestone-id labels state-event)
109+
"Create a project issue.
110+
111+
PROJECT-ID the ID or NAMESPACE%2FPROJECT_NAME of a project
112+
TITLE issue title
113+
DESCRIPTION issue description
114+
ASSIGNEE assignee ID
115+
MILESTONE milestone ID
116+
LABELS comma-separated list label names"
117+
(lwarn '(gitlab) :debug "UPDATE ISSUE in project: %s\n" project-id)
118+
(perform-gitlab-request "PUT"
119+
(format "projects/%s/issues/%s"
120+
(url-hexify-string
121+
(format "%s" project-id))
122+
issue-id)
123+
124+
(format "%s"
125+
(concat
126+
(when title
127+
(format "&title=%s" title))
128+
(when description
129+
(format "&description=%s" description))
130+
(when assignee-id
131+
(format "&assignee_id=%s" assignee-id))
132+
(when milestone-id
133+
(format "&milestone_id=%s" milestone-id))
134+
(when labels
135+
(format "&labels=%s" labels))
136+
(when state-event
137+
(format "&state_event=%s" state-event))))
138+
200))
139+
70140

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

0 commit comments

Comments
 (0)