Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ GitHub.jl implements a bunch of methods that make REST requests to GitHub's API.
| `remove_collaborator(repo, user)` | `HTTP.Response` | [remove `user` as a collaborator from `repo`](https://developer.github.com/v3/repos/collaborators/#remove-collaborator) |
| `collaborator_permission(repo, user)` | `HTTP.Response` | [get the `repo` permission of a collaborator](https://developer.github.com/v3/repos/collaborators/#get-repository-permissions-for-a-user) |
| `stats(repo, stat[, attempts = 3])` | `HTTP.Response` | [get information on `stat` (e.g. "contributors", "code_frequency", "commit_activity", etc.)](https://developer.github.com/v3/repos/statistics/) |
| `topics(repo)` | `Vector{String}` | [get the list of topics of a repository.)](https://docs.github.com/en/rest/repos/repos#get-all-repository-topics) |
| `set_topics(repo, topics)` | `Vector{String}` | [set the list of topics of a repository.)](https://docs.github.com/en/rest/repos/repos#replace-all-repository-topics) |
| `commit(repo, sha)` | `Commit` | [get the commit specified by `sha`](https://developer.github.com/v3/repos/commits/#get-a-single-commit) |
| `commits(repo)` | `Tuple{Vector{Commit}, Dict}` | [get `repo`'s commits](https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository) |
| `branch(repo, branch)` | `Branch` | [get the branch specified by `branch`](https://developer.github.com/v3/repos/#get-branch) |
Expand Down
4 changes: 3 additions & 1 deletion src/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export # repositories.jl
add_collaborator,
remove_collaborator,
collaborator_permission,
stats
stats,
topics,
set_topics

export # contents.jl
Content,
Expand Down
14 changes: 14 additions & 0 deletions src/repositories/repositories.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,17 @@ end
end
return r
end

# topics #
#--------#

@api_default function topics(api::GitHubAPI, repo; options...)
results, page_data = gh_get_paged_json(api, "/repos/$(name(repo))/topics"; options...)
return convert(Vector{String}, results["names"]), page_data
end

@api_default function set_topics(api::GitHubAPI, repo, topics; options...)
result = gh_put_json(api, "/repos/$(name(repo))/topics";
params=Dict("names" => topics), options...)
return convert(Vector{String}, result["names"])
end
11 changes: 11 additions & 0 deletions test/read_only_api_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,14 @@ end
@test repo_license_obj.path == "LICENSE.md"
@test repo_license_obj.typ == "file"
end

@testset "Topics" begin
# test GitHub.topics
topics_obj, page_data = topics(ghjl; auth = auth)
@test typeof(topics_obj) == Vector{String}
@test length(topics_obj) == 0

# also test on a repository that _does_ have topics
topics_obj, page_data = topics("JuliaLang/julia"; auth = auth)
@test length(topics_obj) > 0
end