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
5458PROJECT-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
6470PROJECT-ID : The ID of a project
6571ISSUE-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