Skip to content

Commit

Permalink
create_repo: params should be a keyword argument
Browse files Browse the repository at this point in the history
This patch deprecates `params` as a positional argument and replace it
with a keyword argument (like for all other API functions). I noticed
this when the `params` I passed as keyword argument were overriding the
`params` created with the `name` positional argument.
  • Loading branch information
fredrikekre committed Oct 11, 2023
1 parent f794531 commit 2ef50d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ GitHub.jl implements a bunch of methods that make REST requests to GitHub's API.
| method | return type | documentation |
|----------------------------------------------------------|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `repo(repo)` | `Repo` | [get `repo`](https://developer.github.com/v3/repos/#get) |
| `create_repo(owner, name, params=Dict{String,String}())` | `Repo` | [create a repository of the given `name` in the given `owner`'s account](https://developer.github.com/v3/repos/#create) |
| `create_repo(owner, name)` | `Repo` | [create a repository of the given `name` in the given `owner`'s account](https://developer.github.com/v3/repos/#create) |
| `create_fork(repo)` | `Repo` | [create a fork of `repo`](https://developer.github.com/v3/repos/forks/#create-a-fork) |
| `forks(repo)` | `Tuple{Vector{Repo}, Dict}` | [get `repo`'s forks](https://developer.github.com/v3/repos/forks/#list-forks) |
| `contributors(repo)` | `Dict` | [get `repo`'s contributors](https://developer.github.com/v3/repos/#list-contributors) |
Expand Down
9 changes: 7 additions & 2 deletions src/repositories/repositories.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namefield(repo::Repo) = repo.full_name
return Repo(result)
end

@api_default function create_repo(api::GitHubAPI, owner, repo_name::String, params=Dict{String,Any}(); options...)
params["name"] = repo_name
@api_default function create_repo(api::GitHubAPI, owner, repo_name::String; params=Dict(), options...)
params = merge(params, Dict("name" => repo_name))
if isorg(owner)
result = gh_post_json(api, "/orgs/$(name(owner))/repos"; params=params, options...)
else
Expand All @@ -62,6 +62,11 @@ end
return Repo(result)
end

@api_default function create_repo(api::GitHubAPI, owner, repo_name::String, params; options...)
Base.depwarn("params should be passed as a keyword argument instead of a positional argument", :create_repo)
return create_repo(api, owner, repo_name; params=params, options...)
end

@api_default function delete_repo(api::GitHubAPI, repo; options...)
return gh_delete(api, "/repos/$(name(repo))"; options...)
end
Expand Down

0 comments on commit 2ef50d9

Please sign in to comment.