Skip to content

Commit c9ac5cc

Browse files
staticfloatararslan
authored andcommitted
0.7/1.0 compatibility changes. (#113)
Chief among them, move away from `Nullable`, use `Union{Nothing, T}` instead.
1 parent c281025 commit c9ac5cc

32 files changed

+535
-529
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ os:
33
- linux
44
- osx
55
julia:
6-
- 0.6
6+
- 0.7
77
- nightly
88
notifications:
99
email: false

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Here's a table of contents for this rather lengthy README:
2929

3030
GitHub's JSON responses are parsed and returned to the caller as types of the form `G<:GitHub.GitHubType`. Here's some useful information about these types:
3131

32-
- All fields are `Nullable`.
32+
- All fields are `Union{Nothing, T}`.
3333
- Field names generally match the corresponding field in GitHub's JSON representation (the exception is `"type"`, which has the corresponding field name `typ` to avoid the obvious language conflict).
3434
- `GitHubType`s can be passed as arguments to API methods in place of (and in combination with) regular identifying properties. For example, `create_status(repo, commit)` could be called as:
3535

@@ -488,14 +488,14 @@ listener = GitHub.CommentListener(trigger; auth = myauth, secret = mysecret) do
488488
reply_to = event.payload["issue"]["number"]
489489
elseif event.kind == "commit_comment"
490490
comment_kind = :commit
491-
reply_to = get(comment.commit_id)
491+
reply_to = comment.commit_id
492492
elseif event.kind == "pull_request_review_comment"
493493
comment_kind = :review
494494
reply_to = event.payload["pull_request"]["number"]
495495
# load required query params for review comment creation
496-
comment_params["commit_id"] = get(comment.commit_id)
497-
comment_params["path"] = get(comment.path)
498-
comment_params["position"] = get(comment.position)
496+
comment_params["commit_id"] = comment.commit_id
497+
comment_params["path"] = comment.path
498+
comment_params["position"] = comment.position
499499
end
500500

501501
# send the comment creation request to GitHub

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
julia 0.6
1+
julia 0.7.0-rc3
22

33
Compat 0.62
44
JSON
55
MbedTLS
66
HTTP 0.6.3
7-
Nullables
87

appveyor.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: latest
5+
6+
platform:
7+
- x86
8+
- x64
9+
10+
## uncomment the following lines to allow failures on nightly julia
11+
## (tests will run but not make your overall status red)
12+
#matrix:
13+
# allow_failures:
14+
# - julia_version: latest
715

816
branches:
917
only:
@@ -17,19 +25,12 @@ notifications:
1725
on_build_status_changed: false
1826

1927
install:
20-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21-
# Download most recent Julia Windows binary
22-
- ps: (new-object net.webclient).DownloadFile(
23-
$env:JULIA_URL,
24-
"C:\projects\julia-binary.exe")
25-
# Run installer silently, output to C:\projects\julia
26-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
28+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2729

2830
build_script:
29-
# Need to convert from shallow to complete for Pkg.clone to work
30-
- IF EXIST .git\shallow (git fetch --unshallow)
31-
- C:\projects\julia\bin\julia -e "versioninfo();
32-
Pkg.clone(pwd(), \"GitHub\"); Pkg.build(\"GitHub\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3333

3434
test_script:
35-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"GitHub\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

src/GitHub.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module GitHub
44

55
using Compat
66
using Compat.Dates
7-
using Nullables
87

98
if VERSION >= v"0.7.0-DEV.2338"
109
using Base64

src/apps/apps.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
mutable struct App <: GitHubType
2-
id::Nullable{Int}
3-
owner::Nullable{Owner}
4-
name::Nullable{String}
5-
description::Nullable{String}
6-
external_url::Nullable{String}
7-
html_url::Nullable{String}
2+
id::Union{Int, Nothing}
3+
owner::Union{Owner, Nothing}
4+
name::Union{String, Nothing}
5+
description::Union{String, Nothing}
6+
external_url::Union{String, Nothing}
7+
html_url::Union{String, Nothing}
88
end
99

1010
namefield(a::App) = a.id

src/apps/checks/runs.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module Checks
2-
using Nullables
3-
42
export Action, Image, Annotation, Output
53

64
struct Action
@@ -12,7 +10,7 @@ module Checks
1210
struct Image
1311
alt::String
1412
image_url::String
15-
caption::Nullable{String}
13+
caption::Union{String, Nothing}
1614
end
1715

1816
struct Annotation
@@ -22,14 +20,14 @@ module Checks
2220
end_line::Int
2321
warning_level::String
2422
message::String
25-
title::Nullable{String}
26-
raw_details::String # Documented as Nullable{String}, but that errors
23+
title::Union{String, Nothing}
24+
raw_details::String # Documented as Union{String, Nothing}, but that errors
2725
end
2826

2927
struct Output
3028
title::String
3129
summary::String
32-
text::String # Documented as Nullable{String}, but that errors
30+
text::String # Documented as Union{String, Nothing}, but that errors
3331
annotations::Vector{Annotation}
3432
images::Vector{Image}
3533
end
@@ -38,15 +36,15 @@ end
3836
using .Checks
3937

4038
struct CheckRun <: GitHubType
41-
id::Nullable{Int}
42-
head_sha::Nullable{String}
43-
external_id::Nullable{String}
44-
status::Nullable{String}
45-
conclusion::Nullable{String}
46-
started_at::Nullable{DateTime}
47-
completed_at::Nullable{DateTime}
48-
app::Nullable{App}
49-
pull_requests::Nullable{Vector{PullRequest}}
39+
id::Union{Int, Nothing}
40+
head_sha::Union{String, Nothing}
41+
external_id::Union{String, Nothing}
42+
status::Union{String, Nothing}
43+
conclusion::Union{String, Nothing}
44+
started_at::Union{DateTime, Nothing}
45+
completed_at::Union{DateTime, Nothing}
46+
app::Union{App, Nothing}
47+
pull_requests::Union{Vector{PullRequest}, Nothing}
5048
end
5149
CheckRun(data::Dict) = json2github(CheckRun, data)
5250
namefield(cr::CheckRun) = cr.id

src/apps/installations.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
mutable struct Installation <: GitHubType
2-
id::Nullable{Int}
2+
id::Union{Int, Nothing}
33
end
44

55
namefield(i::Installation) = i.id
66

77
Installation(data::Dict) = json2github(Installation, data)
8-
Installation(id::Int) = Installation(Dict("id" => id))
98

109
@api_default function create_access_token(api::GitHubAPI, i::Installation, auth::JWTAuth; headers = Dict(), options...)
1110
headers["Accept"] = "application/vnd.github.machine-man-preview+json"
12-
payload = gh_post_json(api, "/installations/$(get(i.id))/access_tokens", auth = auth,
11+
payload = gh_post_json(api, "/installations/$(i.id)/access_tokens", auth = auth,
1312
headers=headers, options...)
1413
OAuth2(payload["token"])
1514
end

src/gists/gist.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
mutable struct Gist <: GitHubType
2-
url::Nullable{HTTP.URI}
3-
forks_url::Nullable{HTTP.URI}
4-
commits_url::Nullable{HTTP.URI}
5-
id::Nullable{String}
6-
description::Nullable{String}
7-
public::Nullable{Bool}
8-
owner::Nullable{Owner}
9-
user::Nullable{Owner}
10-
truncated::Nullable{Bool}
11-
comments::Nullable{Int}
12-
comments_url::Nullable{HTTP.URI}
13-
html_url::Nullable{HTTP.URI}
14-
git_pull_url::Nullable{HTTP.URI}
15-
git_push_url::Nullable{HTTP.URI}
16-
created_at::Nullable{Dates.DateTime}
17-
updated_at::Nullable{Dates.DateTime}
18-
forks::Nullable{Vector{Gist}}
19-
files::Nullable{Dict}
20-
history::Nullable{Vector{Dict}}
2+
url::Union{HTTP.URI, Nothing}
3+
forks_url::Union{HTTP.URI, Nothing}
4+
commits_url::Union{HTTP.URI, Nothing}
5+
id::Union{String, Nothing}
6+
description::Union{String, Nothing}
7+
public::Union{Bool, Nothing}
8+
owner::Union{Owner, Nothing}
9+
user::Union{Owner, Nothing}
10+
truncated::Union{Bool, Nothing}
11+
comments::Union{Int, Nothing}
12+
comments_url::Union{HTTP.URI, Nothing}
13+
html_url::Union{HTTP.URI, Nothing}
14+
git_pull_url::Union{HTTP.URI, Nothing}
15+
git_push_url::Union{HTTP.URI, Nothing}
16+
created_at::Union{Dates.DateTime, Nothing}
17+
updated_at::Union{Dates.DateTime, Nothing}
18+
forks::Union{Vector{Gist}, Nothing}
19+
files::Union{Dict, Nothing}
20+
history::Union{Vector{Dict}, Nothing}
2121
end
2222

2323
Gist(data::Dict) = json2github(Gist, data)

src/git/blob.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
mutable struct Blob <: GitHubType
2-
content::Nullable{String}
3-
encoding::Nullable{String}
4-
url::Nullable{HTTP.URI}
5-
sha::Nullable{String}
6-
size::Nullable{Int}
2+
content::Union{String, Nothing}
3+
encoding::Union{String, Nothing}
4+
url::Union{HTTP.URI, Nothing}
5+
sha::Union{String, Nothing}
6+
size::Union{Int, Nothing}
77
end
88

99
Blob(data::Dict) = json2github(Blob, data)

0 commit comments

Comments
 (0)