Skip to content

Commit

Permalink
Fix function deprecation of merge(::URI) (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiahpslewis authored Jan 10, 2022
1 parent 8d734e4 commit 80e4093
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 94 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
SodiumSeal = "2133526b-2bfb-4018-ac12-889fb3908a75"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"

[compat]
HTTP = "0.8, 0.9"
HTTP = "0.9"
URIs = "1.1"
JSON = "0.19, 0.20, 0.21"
MbedTLS = "0.6, 0.7, 1"
SodiumSeal = "0.1"
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ GitHub.jl implements a bunch of methods that make REST requests to GitHub's API.
| `create_file(repo, path)` | `Dict` | [create a file at `path` in `repo`](https://developer.github.com/v3/repos/contents/#create-a-file) |
| `update_file(repo, path)` | `Dict` | [update a file at `path` in `repo`](https://developer.github.com/v3/repos/contents/#update-a-file) |
| `delete_file(repo, path)` | `Dict` | [delete a file at `path` in `repo`](https://developer.github.com/v3/repos/contents/#delete-a-file) |
| `permalink(content::Content, commit)` | `HTTP.URI` | [get a permalink for `content` at the SHA specified by `commit`](https://help.github.com/articles/getting-permanent-links-to-files/) |
| `permalink(content::Content, commit)` | `URIs.URI` | [get a permalink for `content` at the SHA specified by `commit`](https://help.github.com/articles/getting-permanent-links-to-files/) |
| `readme(repo)` | `Content` | [get `repo`'s README](https://developer.github.com/v3/repos/contents/#get-the-readme) |
| `create_status(repo, sha)` | `Status` | [create a status for the commit specified by `sha`](https://developer.github.com/v3/repos/statuses/#create-a-status) |
| `statuses(repo, ref)` | `Tuple{Vector{Status}, Dict}` | [get the statuses posted to `ref`](https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref) |
Expand Down Expand Up @@ -397,19 +397,19 @@ The `EventListener` constructor takes the following keyword arguments:
- `secret`: A string used to verify the event source. If the event is from a GitHub Webhook, it's the Webhook's secret. If a secret is not provided, the server won't validate the secret signature of incoming requests.
- `repos`: A vector of `Repo`s (or fully qualified repository names) listing all acceptable repositories. All repositories are whitelisted by default.
- `events`: A vector of [event names](https://developer.github.com/webhooks/#events) listing all acceptable events (e.g. ["commit_comment", "pull_request"]). All events are whitelisted by default.
- `forwards`: A vector of `HTTP.URI`s (or URI strings) to which any incoming requests should be forwarded (after being validated by the listener)
- `forwards`: A vector of `URIs.URI`s (or URI strings) to which any incoming requests should be forwarded (after being validated by the listener)

Here's an example that demonstrates how to construct and run an `EventListener` that does benchmarking on every commit and PR:

```julia
import GitHub

import URIs
# EventListener settings
myauth = GitHub.authenticate(ENV["GITHUB_AUTH"])
mysecret = ENV["MY_SECRET"]
myevents = ["pull_request", "push"]
myrepos = [GitHub.Repo("owner1/repo1"), "owner2/repo2"] # can be Repos or repo names
myforwards = [HTTP.URI("http://myforward1.com"), "http://myforward2.com"] # can be HTTP.URIs or URI strings
myforwards = [URIs.URI("http://myforward1.com"), "http://myforward2.com"] # can be URIs.URIs or URI strings

# Set up Status parameters
pending_params = Dict(
Expand Down Expand Up @@ -550,8 +550,9 @@ Following example shows obtaining repository info `private/Package.jl` on github

```julia
import GitHub
import URIs

api = GitHub.GitHubWebAPI(HTTP.URI("https://git.company.com/api/v3"))
api = GitHub.GitHubWebAPI(URIs.URI("https://git.company.com/api/v3"))
myauth = GitHub.authenticate(api, ENV["GITHUB_AUTH"])
myrepo = GitHub.repo(api, "private/Package.jl", auth=myauth)
```
Expand Down
1 change: 1 addition & 0 deletions src/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using Base64
##########

import HTTP,
URIs,
JSON,
MbedTLS,
Sockets,
Expand Down
2 changes: 1 addition & 1 deletion src/activity/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct EventListener
secret = nothing, events = nothing,
repos = nothing, forwards = nothing)
if !(isa(forwards, Nothing))
forwards = map(HTTP.URI, forwards)
forwards = map(URIs.URI, forwards)
end

if !(isa(repos, Nothing))
Expand Down
2 changes: 1 addition & 1 deletion src/apps/checks/runs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
app::Union{App, Nothing}
pull_requests::Union{Vector{PullRequest}, Nothing}
check_suite::Union{CheckSuite, Nothing}
html_url::Union{HTTP.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
end
namefield(cr::CheckRun) = cr.id

Expand Down
14 changes: 7 additions & 7 deletions src/gists/gist.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@ghdef mutable struct Gist
url::Union{HTTP.URI, Nothing}
forks_url::Union{HTTP.URI, Nothing}
commits_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
forks_url::Union{URIs.URI, Nothing}
commits_url::Union{URIs.URI, Nothing}
id::Union{String, Nothing}
description::Union{String, Nothing}
public::Union{Bool, Nothing}
owner::Union{Owner, Nothing}
user::Union{Owner, Nothing}
truncated::Union{Bool, Nothing}
comments::Union{Int, Nothing}
comments_url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
git_pull_url::Union{HTTP.URI, Nothing}
git_push_url::Union{HTTP.URI, Nothing}
comments_url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
git_pull_url::Union{URIs.URI, Nothing}
git_push_url::Union{URIs.URI, Nothing}
created_at::Union{Dates.DateTime, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
forks::Union{Vector{Gist}, Nothing}
Expand Down
2 changes: 1 addition & 1 deletion src/git/blob.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@ghdef mutable struct Blob
content::Union{String, Nothing}
encoding::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
sha::Union{String, Nothing}
size::Union{Int, Nothing}
end
Expand Down
2 changes: 1 addition & 1 deletion src/git/gitcommit.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ghdef mutable struct GitCommit
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
author::Union{Dict, Nothing}
commiter::Union{Dict, Nothing}
message::Union{String, Nothing}
Expand Down
2 changes: 1 addition & 1 deletion src/git/reference.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ghdef mutable struct Reference
ref::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
object::Union{Dict, Nothing}
end

Expand Down
2 changes: 1 addition & 1 deletion src/git/tag.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@ghdef mutable struct Tag
tag::Union{String, Nothing}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
message::Union{String, Nothing}
tagger::Union{Dict, Nothing}
object::Union{Dict, Nothing}
Expand Down
2 changes: 1 addition & 1 deletion src/git/tree.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ghdef mutable struct Tree
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
tree::Union{Vector, Nothing}
truncated::Union{Bool, Nothing}
end
Expand Down
8 changes: 4 additions & 4 deletions src/issues/comments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
line::Union{Int, Nothing}
created_at::Union{Dates.DateTime, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
issue_url::Union{HTTP.URI, Nothing}
pull_request_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
issue_url::Union{URIs.URI, Nothing}
pull_request_url::Union{URIs.URI, Nothing}
user::Union{Owner, Nothing}
end

Expand Down
10 changes: 5 additions & 5 deletions src/issues/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
labels::Union{Vector{Dict}, Nothing}
milestone::Union{Dict, Nothing}
pull_request::Union{PullRequest, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
labels_url::Union{HTTP.URI, Nothing}
comments_url::Union{HTTP.URI, Nothing}
events_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
labels_url::Union{URIs.URI, Nothing}
comments_url::Union{URIs.URI, Nothing}
events_url::Union{URIs.URI, Nothing}
locked::Union{Bool, Nothing}
end

Expand Down
4 changes: 2 additions & 2 deletions src/issues/pull_requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
updated_at::Union{Dates.DateTime, Nothing}
closed_at::Union{Dates.DateTime, Nothing}
merged_at::Union{Dates.DateTime, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
assignee::Union{Owner, Nothing}
user::Union{Owner, Nothing}
merged_by::Union{Owner, Nothing}
Expand Down
4 changes: 2 additions & 2 deletions src/licenses/license.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
key::Union{String, Nothing}
name::Union{String, Nothing}
spdx_id::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
description::Union{String, Nothing}
permissions::Union{Vector{String}, Nothing}
conditions::Union{Vector{String}, Nothing}
Expand Down
8 changes: 4 additions & 4 deletions src/owners/owners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
bio::Union{String, Nothing}
company::Union{String, Nothing}
location::Union{String, Nothing}
avatar_url::Union{HTTP.URI, Nothing}
avatar_url::Union{URIs.URI, Nothing}
gravatar_id::Union{String, Nothing}
id::Union{Int, Nothing}
public_repos::Union{Int, Nothing}
Expand All @@ -21,9 +21,9 @@
followers::Union{Int, Nothing}
following::Union{Int, Nothing}
collaborators::Union{Int, Nothing}
blog::Union{HTTP.URI, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
blog::Union{URIs.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
created_at::Union{Dates.DateTime, Nothing}
date::Union{Dates.DateTime, Nothing}
Expand Down
12 changes: 6 additions & 6 deletions src/releases/releases.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@ghdef mutable struct Release
url::Union{Nothing, HTTP.URI}
html_url::Union{Nothing, HTTP.URI}
assets_url::Union{Nothing, HTTP.URI}
upload_url::Union{Nothing, HTTP.URI}
tarball_url::Union{Nothing, HTTP.URI}
zipball_url::Union{Nothing, HTTP.URI}
url::Union{Nothing, URIs.URI}
html_url::Union{Nothing, URIs.URI}
assets_url::Union{Nothing, URIs.URI}
upload_url::Union{Nothing, URIs.URI}
tarball_url::Union{Nothing, URIs.URI}
zipball_url::Union{Nothing, URIs.URI}
id::Union{Nothing, Int}
node_id::Union{Nothing, String}
tag_name::Union{Nothing, String}
Expand Down
6 changes: 3 additions & 3 deletions src/repositories/commits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
author::Union{Owner, Nothing}
committer::Union{Owner, Nothing}
commit::Union{Commit, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
comments_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
comments_url::Union{URIs.URI, Nothing}
parents::Union{Vector{Commit}, Nothing}
stats::Union{Dict, Nothing}
files::Union{Vector{Content}, Nothing}
Expand Down
10 changes: 5 additions & 5 deletions src/repositories/contents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
encoding::Union{String, Nothing}
content::Union{String, Nothing}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
git_url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
download_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
git_url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
download_url::Union{URIs.URI, Nothing}
size::Union{Int, Nothing}
license::Union{License, Nothing}
end
Expand Down Expand Up @@ -62,7 +62,7 @@ function permalink(content::Content, commit)
prefix = something(content.typ, "") == "file" ? "blob" : "tree"
rgx = Regex(string("/", prefix, "/.*?/"))
replacement = string("/", prefix, "/", name(commit), "/")
return HTTP.URI(replace(url, rgx => replacement))
return URIs.URI(replace(url, rgx => replacement))
end

###########################
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/deploykeys.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mutable struct DeployKey <: GitHubType
id::Union{Int, Nothing}
key::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
title::Union{String, Nothing}
verified::Union{Bool, Nothing}
created_at::Union{Dates.DateTime, Nothing}
Expand Down Expand Up @@ -29,4 +29,4 @@ end

@api_default function delete_deploykey(api::GitHubAPI, repo, item; options...)
return gh_delete(api, "/repos/$(name(repo))/keys/$(name(item))"; options...)
end
end
10 changes: 5 additions & 5 deletions src/repositories/repositories.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
stargazers_count::Union{Int, Nothing}
watchers_count::Union{Int, Nothing}
open_issues_count::Union{Int, Nothing}
url::Union{HTTP.URI, Nothing}
html_url::Union{HTTP.URI, Nothing}
clone_url::Union{HTTP.URI, Nothing}
ssh_url::Union{HTTP.URI, Nothing}
homepage::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
html_url::Union{URIs.URI, Nothing}
clone_url::Union{URIs.URI, Nothing}
ssh_url::Union{URIs.URI, Nothing}
homepage::Union{URIs.URI, Nothing}
pushed_at::Union{Dates.DateTime, Nothing}
created_at::Union{Dates.DateTime, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/statuses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
description::Union{String, Nothing}
context::Union{String, Nothing}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
target_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
target_url::Union{URIs.URI, Nothing}
created_at::Union{Dates.DateTime, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
creator::Union{Owner, Nothing}
Expand Down
6 changes: 3 additions & 3 deletions src/repositories/webhooks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

@ghdef mutable struct Webhook
id::Union{Int, Nothing}
url::Union{HTTP.URI, Nothing}
test_url::Union{HTTP.URI, Nothing}
ping_url::Union{HTTP.URI, Nothing}
url::Union{URIs.URI, Nothing}
test_url::Union{URIs.URI, Nothing}
ping_url::Union{URIs.URI, Nothing}
name::Union{String, Nothing}
events::Union{Array{String}, Nothing}
active::Union{Bool, Nothing}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/GitHubType.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ end
#############################################

github2json(val) = val
github2json(uri::HTTP.URI) = string(uri)
github2json(uri::URIs.URI) = string(uri)
github2json(dt::Dates.DateTime) = string(dt) * "Z"
github2json(v::Vector) = [github2json(i) for i in v]

Expand Down
6 changes: 3 additions & 3 deletions src/utils/requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ or a mock API for testing purposes
abstract type GitHubAPI end

struct GitHubWebAPI <: GitHubAPI
endpoint::HTTP.URI
endpoint::URIs.URI
end

const DEFAULT_API = GitHubWebAPI(HTTP.URI("https://api.github.com"))
const DEFAULT_API = GitHubWebAPI(URIs.URI("https://api.github.com"))

using Base.Meta

Expand Down Expand Up @@ -45,7 +45,7 @@ end
# Default API URIs #
####################

api_uri(api::GitHubWebAPI, path) = merge(api.endpoint, path = api.endpoint.path * path)
api_uri(api::GitHubWebAPI, path) = URIs.URI(api.endpoint, path = api.endpoint.path * path)
api_uri(api::GitHubAPI, path) = error("URI retrieval not implemented for this API type")

#######################
Expand Down
4 changes: 2 additions & 2 deletions test/event_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end # testset
secret = "secret",
repos = [Repo("JuliaCI/BenchmarkTrackers.jl"), "JuliaWeb/GitHub.jl"],
events = ["commit_comment"],
forwards = ["http://bob.com", HTTP.URI("http://jim.org")])
forwards = ["http://bob.com", URIs.URI("http://jim.org")])
r = listener.handle_request(HTTP.Request())
r.status == 400
end
Expand All @@ -40,7 +40,7 @@ end
listener = CommentListener((x, y) -> true, r"trigger";
secret = "secret",
repos = [Repo("JuliaCI/BenchmarkTrackers.jl"), "JuliaWeb/GitHub.jl"],
forwards = ["http://bob.com", HTTP.URI("http://jim.org")],
forwards = ["http://bob.com", URIs.URI("http://jim.org")],
check_collab = false)
r = listener.listener.handle_request(HTTP.Request())
r.status == 400
Expand Down
Loading

0 comments on commit 80e4093

Please sign in to comment.