-
Notifications
You must be signed in to change notification settings - Fork 30
/
gitlab-milestones.el
135 lines (108 loc) · 5.01 KB
/
gitlab-milestones.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;;; gitlab-milestones.el --- Gitlab Milestones API
;; Copyright (C) 2015, 2016 Marcin Antczak <[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 the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301, USA.
;;; Commentary:
;; See API doc :
;; https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/milestones.md
;;; Code:
(require 's)
(require 'gitlab-http)
(defun gitlab-list-project-milestones (project-id)
"Get a list of project milestones.
PROJECT-ID : The ID of a project"
(perform-gitlab-request "GET"
(s-concat "projects/"
(url-hexify-string
(format "%s" project-id))
"/milestones"
)
nil
200))
(defun gitlab--get-milestone-uri (project-id milestone-id)
"Create milestone uri for PROJECT-ID identified by MILESTONE-ID."
(s-concat "projects/"
(url-hexify-string
(format "%s" project-id))
"/milestones/"
(number-to-string milestone-id)))
(defun gitlab-get-milestone (project-id milestone-id)
"Gets a single project milestone.
PROJECT-ID : The ID of a project
MILESTONE-ID : The ID of a project milestone"
(perform-gitlab-request "GET"
(gitlab--get-milestone-uri
(url-hexify-string
(format "%s" project-id))
milestone-id)
nil
200))
(defun gitlab-get-milestone-issues (project-id milestone-id)
"Gets a single project milestone.
PROJECT-ID : The ID of a project
MILESTONE-ID : The ID of a project milestone"
(perform-gitlab-request "GET"
(s-concat
(gitlab--get-milestone-uri
(url-hexify-string
(format "%s" project-id))
milestone-id)
"/issues")
nil
200)
;; (lwarn '(gitlab) :debug "URL: %s "(s-concat
;; (gitlab--get-milestone-uri
;; (url-hexify-string
;; (format "%s" project-id))
;; milestone-id)
;; "/issues"))
)
(defun gitlab-create-milestone (project-id milestone-title milestone-deadline milestone-description)
"Create a project milestone.
PROJECT-ID: The ID or NAMESPACE%2FPROJECT_NAME of a project
MILESTONE-TITLE: Title of milestone"
(perform-gitlab-request "POST"
(format "projects/%s/milestones"
(url-hexify-string
(format "%s" project-id)))
(format "title=%s&due_date=%s&description=%s"
milestone-title
milestone-deadline
milestone-description)
201))
(defun gitlab-edit-milestone (project-id milestone-id &optional title description due-date state-event)
"Edit milestone.
PROJECT-ID: the ID or NAMESPACE%2FPROJECT_NAME of a project
MILESTONE-ID: the ID office milestone
TITLE: title of milestone
DESCRIPTION: description of milestone
DUE-DATE: deadline
STATE-EVENT: activate or close milestone"
(perform-gitlab-request "PUT"
(format "projects/%s/milestones/%s"
(url-hexify-string
(format "%s" project-id))
milestone-id)
(format "%s"
(concat
(when title
(format "&title=%s" title))
(when description
(format "&description=%s" description))
(when due-date
(format "&due_date=%s" due-date))
(when state-event
(format "&state_event=%s" state-event))))
200))
(provide 'gitlab-milestones)
;;; gitlab-milestones.el ends here