Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

support renaming of repos #3

Closed
wants to merge 2 commits into from

2 participants

@tarsius

By the way, why are some settings changed by changing the gh-repos-repo-stub object, while has_* directly using CAPS? Maybe because github doesn't return these when GETting /repos/:user/:repo? Shouldn't the repo classes have these slots anyway?

I think it would be better if homepage, description and public would behave the same way name does after my changes: use the value from CAPS (which then should be renamed) or if that is not set the value from the repo object.

Uh uh, just noticed a second related bug - patch and description follows.

@tarsius

Okay maybe not a bug but at least for me unexpected behaviour.

I did not run into this but when one wants to e.g. change just the :description but want to leaves :homepage and :private untouched simply using a gh-repos-repo-stub object and setting :name and :description won't do. :homepage and :private also have to be set or they will be unset when calling gh-repos-repo-update.

I fixed this by ignoring unbound slots. Another solution would be to first request an gh-repos-repo object and just change the :description there. But that would be two requests and also makes me wonder what the purpose of gh-repos-repo-stub is anyway.

@tarsius

Don't know if that would lead to inconsistencies but as far as gh-repos-repo-update is concerned gh-repos-repo-stub is not necessary if REPO-STUB could be just a string (the repo name).

And for methods that need two values from the repo object you could just add a second definition:

 (defmethod gh-repos-repo-languages ((api gh-repos-api) repo)...)
 (defmethod gh-repos-repo-languages ((api gh-repos-api) owner name)...)

Unfortunately eieio dispatches on the first argument only so in case of gh-repos-repo-update you would have to handle the different argument types internally - but that might be easier anyway, certainly less code.

@sigma
Owner

Sorry for the long delay.

So about rename, I think I'll make it a separate operation, as it has the unwelcome effect of invalidating basically every repository object you have (since the name is part of the id), so the end user should be well aware of what he's doing. The same would be true for repository transfer, when it's implemented

You're right about the unbound slots. The intended use was to reuse an existing (and correct) stub, but one can very well create a new one by hand.

@sigma sigma closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 21, 2011
  1. @tarsius

    support renaming of repos

    tarsius authored
  2. @tarsius
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 8 deletions.
  1. +12 −8 gh-repos.el
View
20 gh-repos.el
@@ -42,9 +42,9 @@
;;;###autoload
(defclass gh-repos-repo-stub (gh-object)
((name :initarg :name)
- (description :initarg :description :initform nil)
- (homepage :initarg :homepage :initform nil)
- (private :initarg :private :initform nil))
+ (description :initarg :description)
+ (homepage :initarg :homepage)
+ (private :initarg :private))
"Class for user-created repository objects")
(defmethod gh-object-read-into ((stub gh-repos-repo-stub) data)
@@ -137,13 +137,17 @@
(defmethod gh-repos-repo-to-obj ((repo gh-repos-repo-stub)
&rest caps)
- (let ((has_issues (plist-member caps :issues))
+ (let ((name (plist-get caps :name))
+ (has_issues (plist-member caps :issues))
(has_wiki (plist-member caps :wiki))
(has_downloads (plist-member caps :downloads)))
- `(("name" . ,(oref repo :name))
- ("homepage" . ,(oref repo :homepage))
- ("description" . ,(oref repo :description))
- ("public" . ,(not (oref repo :private)))
+ `(("name" . ,(or name (oref repo :name)))
+ ,@(when (slot-boundp repo :homepage)
+ (list (cons "homepage" (oref repo :homepage))))
+ ,@(when (slot-boundp repo :description)
+ (list (cons "description" (oref repo :description))))
+ ,@(when (slot-boundp repo :private)
+ (list (cons "public" (not (oref repo :private)))))
,@(when has_issues
(list (cons "has_issues" (plist-get caps :issues))))
,@(when has_wiki
Something went wrong with that request. Please try again.