-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding possiblity to get ssh keys #544
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!
Solid work with tests.
A few questions/comments, once those are addressed we can merge.
@@ -36,6 +35,10 @@ | |||
*/ | |||
public class GHUser extends GHPerson { | |||
|
|||
public List<GHKey> listKeys() throws IOException { | |||
return Collections.unmodifiableList(Arrays.asList(root.retrieve().to("/users/"+login+"/keys", GHKey[].class))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible for there to be multiple pages of keys? I know it is unlikely for some one to have more than a page of keys, but if it is possible it might be better to use a PagedIterable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a over kill using PagedIterable
, but it is of course possible. Most people only have a single ssh key and less than 10.
Personally I think it better to return a list and instead read all the keys in listKeys()
. I can of course iterate until all key have been read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arngrimur-seal
I see your point.
Okay, I just did a quick review of the code base. Generally, list*
methods return PagedIterable<T>
. If there is a method that returns a List<T>
or a T[]
it is called get*
.
I think this completely misleading naming, but I'd rather be consistent with the existing naming pattern. So, let's change the name to getKeys()
. Then we're good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand, are we good to merge or do you want me to update the code so we make sure all keys has been rtrieved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a suggestion comment above.
@@ -27,4 +26,27 @@ public void listFollowsAndFollowers() throws IOException { | |||
assertEquals(30, users.size()); | |||
return users; | |||
} | |||
|
|||
@Test | |||
public void getKeys() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great. How was it using this test framework and takeSnapshot
? I just added it and would appreciate any feedback you can offer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took a while before I understood the framework but then it was simple. Deleting and generating the test data has drawbacks since it is easy do forget about that step but the advantage with test taking lots of time and that data is constant is a greater benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, well, if you have any suggestions for how to make it easier (such as improvements to the CONTRIBUTING.md) that would be great.
@@ -36,6 +35,10 @@ | |||
*/ | |||
public class GHUser extends GHPerson { | |||
|
|||
public List<GHKey> listKeys() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public List<GHKey> listKeys() throws IOException { | |
public List<GHKey> getKeys() throws IOException { |
@Test | ||
public void getKeys() throws IOException { | ||
GHUser u = gitHub.getUser("rtyler"); | ||
List<GHKey> ghKeys = new ArrayList<>(u.listKeys()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List<GHKey> ghKeys = new ArrayList<>(u.listKeys()); | |
List<GHKey> ghKeys = new ArrayList<>(u.getKeys()); |
No description provided.