From 8d7605e7112fe0cb4e290870604f89225269c448 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 25 Oct 2017 16:45:31 -0400 Subject: [PATCH] drop 0.5 support --- .travis.yml | 1 - REQUIRE | 3 +-- appveyor.yml | 2 -- src/activity/events.jl | 6 +++--- src/apps/apps.jl | 2 +- src/apps/installations.jl | 2 +- src/gists/gist.jl | 2 +- src/issues/comments.jl | 2 +- src/issues/issues.jl | 2 +- src/issues/pull_requests.jl | 2 +- src/issues/reviews.jl | 2 +- src/owners/owners.jl | 2 +- src/owners/teams.jl | 2 +- src/repositories/branches.jl | 2 +- src/repositories/commits.jl | 2 +- src/repositories/contents.jl | 2 +- src/repositories/repositories.jl | 2 +- src/repositories/statuses.jl | 2 +- src/repositories/webhooks.jl | 2 +- src/utils/GitHubType.jl | 14 +++++++------- src/utils/auth.jl | 8 ++++---- src/utils/requests.jl | 4 ++-- test/ghtype_tests.jl | 1 + 23 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf3ce2c..23b7583 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: julia julia: - - 0.5 - 0.6 - nightly notifications: diff --git a/REQUIRE b/REQUIRE index 21b9265..5b5775b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,6 +1,5 @@ -julia 0.5 +julia 0.6 -Compat 0.17 JSON HttpServer MbedTLS diff --git a/appveyor.yml b/appveyor.yml index 692d2ff..00595c2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,5 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" diff --git a/src/activity/events.jl b/src/activity/events.jl index 4d5af01..16d5ca1 100644 --- a/src/activity/events.jl +++ b/src/activity/events.jl @@ -2,7 +2,7 @@ # WebhookEvent Type # ##################### -type WebhookEvent +mutable struct WebhookEvent kind::String payload::Dict repository::Repo @@ -61,7 +61,7 @@ end # EventListener # ################# -immutable EventListener +struct EventListener server::HttpServer.Server function EventListener(handle; auth::Authorization = AnonymousAuth(), secret = nothing, events = nothing, @@ -138,7 +138,7 @@ const COMMENT_EVENTS = ["commit_comment", "issues", "issue_comment"] -immutable CommentListener +struct CommentListener listener::EventListener function CommentListener(handle, trigger::Regex; auth::Authorization = AnonymousAuth(), diff --git a/src/apps/apps.jl b/src/apps/apps.jl index b3bbc7c..fdbb041 100644 --- a/src/apps/apps.jl +++ b/src/apps/apps.jl @@ -1,4 +1,4 @@ -type App <: GitHubType +mutable struct App <: GitHubType id::Nullable{Int} owner::Nullable{Owner} name::Nullable{String} diff --git a/src/apps/installations.jl b/src/apps/installations.jl index 45f18a9..8921bc7 100644 --- a/src/apps/installations.jl +++ b/src/apps/installations.jl @@ -1,4 +1,4 @@ -type Installation <: GitHubType +mutable struct Installation <: GitHubType id::Nullable{Int} end diff --git a/src/gists/gist.jl b/src/gists/gist.jl index 071edc7..08ea460 100644 --- a/src/gists/gist.jl +++ b/src/gists/gist.jl @@ -1,4 +1,4 @@ -type Gist <: GitHubType +mutable struct Gist <: GitHubType url::Nullable{HttpCommon.URI} forks_url::Nullable{HttpCommon.URI} commits_url::Nullable{HttpCommon.URI} diff --git a/src/issues/comments.jl b/src/issues/comments.jl index 58488ec..108ed7f 100644 --- a/src/issues/comments.jl +++ b/src/issues/comments.jl @@ -2,7 +2,7 @@ # Comment Type # ################ -type Comment <: GitHubType +mutable struct Comment <: GitHubType body::Nullable{String} path::Nullable{String} diff_hunk::Nullable{String} diff --git a/src/issues/issues.jl b/src/issues/issues.jl index ef56212..4d2f4ee 100644 --- a/src/issues/issues.jl +++ b/src/issues/issues.jl @@ -2,7 +2,7 @@ # Issue type # ############## -type Issue <: GitHubType +mutable struct Issue <: GitHubType id::Nullable{Int} number::Nullable{Int} comments::Nullable{Int} diff --git a/src/issues/pull_requests.jl b/src/issues/pull_requests.jl index e5b95fb..320fac4 100644 --- a/src/issues/pull_requests.jl +++ b/src/issues/pull_requests.jl @@ -2,7 +2,7 @@ # PullRequest Type # #################### -type PullRequest <: GitHubType +mutable struct PullRequest <: GitHubType base::Nullable{Branch} head::Nullable{Branch} number::Nullable{Int} diff --git a/src/issues/reviews.jl b/src/issues/reviews.jl index 89b43be..00fcf52 100644 --- a/src/issues/reviews.jl +++ b/src/issues/reviews.jl @@ -1,4 +1,4 @@ -type Review <: GitHubType +mutable struct Review <: GitHubType pr::Nullable{PullRequest} id::Nullable{Int} user::Nullable{Owner} diff --git a/src/owners/owners.jl b/src/owners/owners.jl index 767bdf6..0494556 100644 --- a/src/owners/owners.jl +++ b/src/owners/owners.jl @@ -2,7 +2,7 @@ # Owner Type # ############## -type Owner <: GitHubType +mutable struct Owner <: GitHubType typ::Nullable{String} email::Nullable{String} name::Nullable{String} diff --git a/src/owners/teams.jl b/src/owners/teams.jl index abc79bb..1ff226f 100644 --- a/src/owners/teams.jl +++ b/src/owners/teams.jl @@ -1,4 +1,4 @@ -type Team <: GitHubType +mutable struct Team <: GitHubType name::Nullable{String} description::Nullable{String} privacy::Nullable{String} diff --git a/src/repositories/branches.jl b/src/repositories/branches.jl index 52369ac..a7252cf 100644 --- a/src/repositories/branches.jl +++ b/src/repositories/branches.jl @@ -2,7 +2,7 @@ # Branch Type # ############### -type Branch <: GitHubType +mutable struct Branch <: GitHubType name::Nullable{String} label::Nullable{String} ref::Nullable{String} diff --git a/src/repositories/commits.jl b/src/repositories/commits.jl index 2b3c5f2..6fe61a3 100644 --- a/src/repositories/commits.jl +++ b/src/repositories/commits.jl @@ -2,7 +2,7 @@ # Commit Type # ############### -type Commit <: GitHubType +mutable struct Commit <: GitHubType sha::Nullable{String} message::Nullable{String} author::Nullable{Owner} diff --git a/src/repositories/contents.jl b/src/repositories/contents.jl index 612cec4..5667c49 100644 --- a/src/repositories/contents.jl +++ b/src/repositories/contents.jl @@ -2,7 +2,7 @@ # Content Type # ################ -type Content <: GitHubType +mutable struct Content <: GitHubType typ::Nullable{String} filename::Nullable{String} name::Nullable{String} diff --git a/src/repositories/repositories.jl b/src/repositories/repositories.jl index 2839924..218dd2b 100644 --- a/src/repositories/repositories.jl +++ b/src/repositories/repositories.jl @@ -2,7 +2,7 @@ # Repo Type # ############# -type Repo <: GitHubType +mutable struct Repo <: GitHubType name::Nullable{String} full_name::Nullable{String} description::Nullable{String} diff --git a/src/repositories/statuses.jl b/src/repositories/statuses.jl index ba24e47..44c9cdb 100644 --- a/src/repositories/statuses.jl +++ b/src/repositories/statuses.jl @@ -2,7 +2,7 @@ # Status type # ############### -type Status <: GitHubType +mutable struct Status <: GitHubType id::Nullable{Int} total_count::Nullable{Int} state::Nullable{String} diff --git a/src/repositories/webhooks.jl b/src/repositories/webhooks.jl index 8699b4a..0d10309 100644 --- a/src/repositories/webhooks.jl +++ b/src/repositories/webhooks.jl @@ -2,7 +2,7 @@ # Webhook type # ################ -type Webhook <: GitHubType +mutable struct Webhook <: GitHubType id::Nullable{Int} url::Nullable{HttpCommon.URI} test_url::Nullable{HttpCommon.URI} diff --git a/src/utils/GitHubType.jl b/src/utils/GitHubType.jl index 0b38118..a321976 100644 --- a/src/utils/GitHubType.jl +++ b/src/utils/GitHubType.jl @@ -23,7 +23,7 @@ function Base.:(==)(a::GitHubType, b::GitHubType) return false end - for field in fieldnames(a) + for field in fieldnames(typeof(a)) aval, bval = getfield(a, field), getfield(b, field) if isnull(aval) == isnull(bval) if !(isnull(aval)) && get(aval) != get(bval) @@ -46,7 +46,7 @@ name(g::GitHubType) = get(namefield(g)) # Converting JSON Dicts to GitHubTypes # ######################################## -function extract_nullable{T}(data::Dict, key, ::Type{T}) +function extract_nullable(data::Dict, key, ::Type{T}) where {T} if haskey(data, key) val = data[key] if !(isa(val, Void)) @@ -61,7 +61,7 @@ function extract_nullable{T}(data::Dict, key, ::Type{T}) return Nullable{T}() end -prune_github_value{T}(val, ::Type{T}) = T(val) +prune_github_value(val, ::Type{T}) where {T} = T(val) prune_github_value(val::AbstractString, ::Type{Dates.DateTime}) = Dates.DateTime(chopz(val)) # ISO 8601 allows for a trailing 'Z' to indicate that the given time is UTC. @@ -79,7 +79,7 @@ end # dictionary into the type `G` with the expectation that the fieldnames of # `G` are keys of `data`, and the corresponding values can be converted to the # given field types. -@generated function json2github{G<:GitHubType}(::Type{G}, data::Dict) +@generated function json2github(::Type{G}, data::Dict) where {G<:GitHubType} types = G.types fields = fieldnames(G) args = Vector{Expr}(length(fields)) @@ -102,7 +102,7 @@ github2json(v::Vector) = [github2json(i) for i in v] function github2json(g::GitHubType) results = Dict() - for field in fieldnames(g) + for field in fieldnames(typeof(g)) val = getfield(g, field) if !(isnull(val)) key = field == :typ ? "type" : string(field) @@ -112,7 +112,7 @@ function github2json(g::GitHubType) return results end -function github2json{K}(data::Dict{K}) +function github2json(data::Dict{K}) where {K} results = Dict{K,Any}() for (key, val) in data results[key] = github2json(val) @@ -126,7 +126,7 @@ end function Base.show(io::IO, g::GitHubType) print(io, "$(typeof(g)) (all fields are Nullable):") - for field in fieldnames(g) + for field in fieldnames(typeof(g)) val = getfield(g, field) if !(isnull(val)) gotval = get(val) diff --git a/src/utils/auth.jl b/src/utils/auth.jl index d6cbb29..45ba8b6 100644 --- a/src/utils/auth.jl +++ b/src/utils/auth.jl @@ -2,15 +2,15 @@ # Authorization Types # ####################### -@compat abstract type Authorization end +abstract type Authorization end -immutable OAuth2 <: Authorization +struct OAuth2 <: Authorization token::String end -immutable AnonymousAuth <: Authorization end +struct AnonymousAuth <: Authorization end -immutable JWTAuth <: Authorization +struct JWTAuth <: Authorization JWT::String end diff --git a/src/utils/requests.jl b/src/utils/requests.jl index dce0425..4f528e4 100644 --- a/src/utils/requests.jl +++ b/src/utils/requests.jl @@ -6,9 +6,9 @@ Represents the API to interact with, either an actual GitHub instance, or a mock API for testing purposes """ -@compat abstract type GitHubAPI end +abstract type GitHubAPI end -immutable GitHubWebAPI <: GitHubAPI +struct GitHubWebAPI <: GitHubAPI endpoint::HttpCommon.URI end diff --git a/test/ghtype_tests.jl b/test/ghtype_tests.jl index 441bbaa..ffdf709 100644 --- a/test/ghtype_tests.jl +++ b/test/ghtype_tests.jl @@ -1,5 +1,6 @@ import JSON using GitHub, GitHub.name, GitHub.Branch +import HttpCommon using Base.Test # This file tests various GitHubType constructors. To test for proper Nullable