-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implements Topics API #1044
Implements Topics API #1044
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.
Two small nits, thanks for taking this on!
@@ -273,6 +273,26 @@ | |||
end | |||
end # .collaborators | |||
|
|||
describe ".topics", :vcr do | |||
it "returns repository topics" do | |||
topics = Octokit.topics("github/linguist", :accept => 'application/vnd.github.mercy-preview+json') |
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.
Instead of using the string, could we use the value from the PREVIEW_TYPES
hash?
https://github.com/octokit/octokit.rb/blob/master/lib/octokit/preview.rb#L19
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.
Sounds good <3
@@ -273,6 +273,26 @@ | |||
end | |||
end # .collaborators | |||
|
|||
describe ".topics", :vcr do |
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.
Could we put these under the with repository
context?
That way if we ever have to re record these cassettes another user can run them with their own data?
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.
Good idea 👍
I am trying (by the way, there are two with repository
contexts) and what test ENVs do I need in order to record cassettes correctly.
It's getting closer to my sleep time. If you could show me how to move topics
spec inside one of the context will be very helpful. I can update the other one tomorrow.
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.
Apologies for not getting back to this, glad you figured it out!
lib/octokit/client/repositories.rb
Outdated
# Requires authenticated client for private repos. | ||
# | ||
# @param repo [Integer, String, Hash, Repository] A GitHub repository. | ||
# @return [Array<Sawyer::Resource>] Hash of array representing topics. |
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.
Do you mean "Array of hashes"?
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. I checked the response is {:names=>["octokit", "github", "github-api"]}
.
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.
Aha, then [Array<Sawyer::Resource>]
is what needs to change.
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 already changed in f927472, thank you.
lib/octokit/client/repositories.rb
Outdated
# Requires authenticated client. | ||
# | ||
# @param repo [Integer, String, Repository, Hash] A Github repository | ||
# @param names [Integer] Number ID of the issue |
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.
names
is not "Number ID of the issue"
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.
Good catch 👍
lib/octokit/client/repositories.rb
Outdated
# | ||
# @param repo [Integer, String, Repository, Hash] A Github repository | ||
# @param names [Integer] Number ID of the issue | ||
# @return [Array<Sawyer::Resource>] A list of the topics currently on the issue |
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.
Wrong docstring for @return
.
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.
That's pretty embarrassing! 👍
@tarebyte I've moved tests into |
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 looks great, thank you.
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.
Sorry, I found one thing after I approved it, that I'd like to get tidied up before we bring this in.
it "replaces all topics for a repository" do | ||
new_topics = ["octocat", "github", "github-api"] | ||
options = { | ||
:accept => "application/vnd.github.mercy-preview+json" |
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 missed this the first time around. Would you please access this through the PREVIEW_TYPES
constant?
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.
Good catch! Thanks!
And use `fetch` instead.
names is array of topics: %w(octokit github github-api)
Thanks @JuanitoFatas!! |
This Pull Request implements Repositories REST API V3 list all topics and replace all topics endpoints.
Response for
topics
:Response for
replace_all_topics
:Closes #978 Closes #933