gh-issues #4

Merged
merged 14 commits into from Mar 17, 2012

Projects

None yet

2 participants

Contributor
kidd commented Mar 12, 2012

That's a first minimal support for github issues. it allows creation, listing and updating of issues.
For the moment, there's no support for milestones, labels, nor assignees.

Feel free to rename variables, or add caching. I messed a bit with caching, without any success, so I left it out for the moment.

Comments are really appreciated.

@sigma sigma commented on an outdated diff Mar 13, 2012
+(require 'gh-common)
+
+(require 'gh-repos)
+
+(defclass gh-issues-api (gh-api-v3)
+ ((req-cls :allocation :class :initform gh-issues-issue))
+ "Github Issues api")
+
+(defclass gh-issues-issue (gh-object)
+ ((url :initarg :url)
+ (html-url :initarg :html-url)
+ (number :initarg :number)
+ (state :initarg :state)
+ (title :initarg :title)
+ (body :initarg :body)
+ (user :initarg :user :initform gh-user)
sigma
sigma Mar 13, 2012 Owner

you should use separate slots for the user object, and for the class that's used to read it
hence
(user :initarg :user)
...
(user-cls :initarg :user-cls :initform gh-user)

@sigma sigma commented on an outdated diff Mar 13, 2012
+(require 'gh-repos)
+
+(defclass gh-issues-api (gh-api-v3)
+ ((req-cls :allocation :class :initform gh-issues-issue))
+ "Github Issues api")
+
+(defclass gh-issues-issue (gh-object)
+ ((url :initarg :url)
+ (html-url :initarg :html-url)
+ (number :initarg :number)
+ (state :initarg :state)
+ (title :initarg :title)
+ (body :initarg :body)
+ (user :initarg :user :initform gh-user)
+ (labels :initarg :labels :initform nil)
+ (assignee :initarg :assignee :initform gh-user)
sigma
sigma Mar 13, 2012 Owner

same here

@sigma sigma commented on an outdated diff Mar 13, 2012
+
+(defclass gh-issues-api (gh-api-v3)
+ ((req-cls :allocation :class :initform gh-issues-issue))
+ "Github Issues api")
+
+(defclass gh-issues-issue (gh-object)
+ ((url :initarg :url)
+ (html-url :initarg :html-url)
+ (number :initarg :number)
+ (state :initarg :state)
+ (title :initarg :title)
+ (body :initarg :body)
+ (user :initarg :user :initform gh-user)
+ (labels :initarg :labels :initform nil)
+ (assignee :initarg :assignee :initform gh-user)
+ (milestone :initarg :milestone :initform gh-milestone)
sigma
sigma Mar 13, 2012 Owner

same here

@sigma sigma commented on an outdated diff Mar 13, 2012
+ (created_at :initarg :created_at)
+ (due_on :initarg :due_on))
+ "issues request")
+
+(defclass gh-issues-label (gh-object)
+ ((url :initarg :url)
+ (name :initarg :name)
+ (color :initarg :color)))
+
+(defclass gh-milestone (gh-object)
+ ((url :initarg :url)
+ (number :initarg :number)
+ (state :initarg :state)
+ (title :initarg :title)
+ (description :initarg :description)
+ (creator :initarg :creator :initform gh-user)
sigma
sigma Mar 13, 2012 Owner

same here

@sigma sigma commented on an outdated diff Mar 13, 2012
+ "github milestone")
+
+(defmethod gh-object-read-into ((issue gh-issues-issue) data)
+ (call-next-method)
+ (with-slots (url html-url number state title body
+ user labels assignee milestone open_issues
+ closed_issues created_at due_on)
+ issue
+ (setq url (gh-read data 'url)
+ url (gh-read data 'url)
+ html-url (gh-read data 'html-url)
+ number (gh-read data 'number)
+ state (gh-read data 'state)
+ title (gh-read data 'title)
+ body (gh-read data 'body)
+ user (gh-object-read (oref issue :user) (gh-read data 'user))
sigma
sigma Mar 13, 2012 Owner

this and further occurrences need to be refactored after previous comments applied

@sigma sigma commented on an outdated diff Mar 13, 2012
+ (user :initarg :user :initform gh-user)
+ (labels :initarg :labels :initform nil)
+ (assignee :initarg :assignee :initform gh-user)
+ (milestone :initarg :milestone :initform gh-milestone)
+ (open_issues :initarg :open_issues)
+ (closed_issues :initarg :closed_issues)
+ (created_at :initarg :created_at)
+ (due_on :initarg :due_on))
+ "issues request")
+
+(defclass gh-issues-label (gh-object)
+ ((url :initarg :url)
+ (name :initarg :name)
+ (color :initarg :color)))
+
+(defclass gh-milestone (gh-object)
sigma
sigma Mar 13, 2012 Owner

should be named gh-issues-milestone

Owner

labels aren't implemented yet

Owner

These method is ugly because I try to protect assigning nil values on update

Owner

There's a problem with this current implementation. when creating a new milestone without some optional field, when doing
(oref milestone description) without it being initialized it doesn't return nil but throws an error. Is there any idiom for that? or just initialize these values in the constructor to nil?

Again, the method looks ugly to protect assigning nil on non-present values (when updating). Would it make sense to add a helper like gh-api-form-encode, that discards tuples where value == nil?

@sigma sigma merged commit 4d5a482 into sigma:master Mar 17, 2012
Owner
sigma commented Mar 17, 2012

thanks, I merged it and made a couple of modifications

Contributor
kidd commented Mar 18, 2012

Great! There are still some rough edges here and there, and support for comments on issues. I hope I'll have time for them this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment