Skip to content

Commit

Permalink
Merge 8350890 into c281025
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Aug 8, 2018
2 parents c281025 + 8350890 commit 7de5ecd
Show file tree
Hide file tree
Showing 32 changed files with 535 additions and 529 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
- osx
julia:
- 0.6
- 0.7
- nightly
notifications:
email: false
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Here's a table of contents for this rather lengthy README:

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:

- All fields are `Nullable`.
- All fields are `Union{Nothing, T}`.
- 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).
- `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:

Expand Down Expand Up @@ -488,14 +488,14 @@ listener = GitHub.CommentListener(trigger; auth = myauth, secret = mysecret) do
reply_to = event.payload["issue"]["number"]
elseif event.kind == "commit_comment"
comment_kind = :commit
reply_to = get(comment.commit_id)
reply_to = comment.commit_id
elseif event.kind == "pull_request_review_comment"
comment_kind = :review
reply_to = event.payload["pull_request"]["number"]
# load required query params for review comment creation
comment_params["commit_id"] = get(comment.commit_id)
comment_params["path"] = get(comment.path)
comment_params["position"] = get(comment.position)
comment_params["commit_id"] = comment.commit_id
comment_params["path"] = comment.path
comment_params["position"] = comment.position
end

# send the comment creation request to GitHub
Expand Down
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
julia 0.6
julia 0.7.0-rc3

Compat 0.62
JSON
MbedTLS
HTTP 0.6.3
Nullables

33 changes: 17 additions & 16 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
environment:
matrix:
- 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"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.7
- julia_version: latest

platform:
- x86
- x64

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
#matrix:
# allow_failures:
# - julia_version: latest

branches:
only:
Expand All @@ -17,19 +25,12 @@ notifications:
on_build_status_changed: false

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

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

test_script:
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"GitHub\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
1 change: 0 additions & 1 deletion src/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module GitHub

using Compat
using Compat.Dates
using Nullables

if VERSION >= v"0.7.0-DEV.2338"
using Base64
Expand Down
12 changes: 6 additions & 6 deletions src/apps/apps.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mutable struct App <: GitHubType
id::Nullable{Int}
owner::Nullable{Owner}
name::Nullable{String}
description::Nullable{String}
external_url::Nullable{String}
html_url::Nullable{String}
id::Union{Int, Nothing}
owner::Union{Owner, Nothing}
name::Union{String, Nothing}
description::Union{String, Nothing}
external_url::Union{String, Nothing}
html_url::Union{String, Nothing}
end

namefield(a::App) = a.id
Expand Down
28 changes: 13 additions & 15 deletions src/apps/checks/runs.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module Checks
using Nullables

export Action, Image, Annotation, Output

struct Action
Expand All @@ -12,7 +10,7 @@ module Checks
struct Image
alt::String
image_url::String
caption::Nullable{String}
caption::Union{String, Nothing}
end

struct Annotation
Expand All @@ -22,14 +20,14 @@ module Checks
end_line::Int
warning_level::String
message::String
title::Nullable{String}
raw_details::String # Documented as Nullable{String}, but that errors
title::Union{String, Nothing}
raw_details::String # Documented as Union{String, Nothing}, but that errors
end

struct Output
title::String
summary::String
text::String # Documented as Nullable{String}, but that errors
text::String # Documented as Union{String, Nothing}, but that errors
annotations::Vector{Annotation}
images::Vector{Image}
end
Expand All @@ -38,15 +36,15 @@ end
using .Checks

struct CheckRun <: GitHubType
id::Nullable{Int}
head_sha::Nullable{String}
external_id::Nullable{String}
status::Nullable{String}
conclusion::Nullable{String}
started_at::Nullable{DateTime}
completed_at::Nullable{DateTime}
app::Nullable{App}
pull_requests::Nullable{Vector{PullRequest}}
id::Union{Int, Nothing}
head_sha::Union{String, Nothing}
external_id::Union{String, Nothing}
status::Union{String, Nothing}
conclusion::Union{String, Nothing}
started_at::Union{DateTime, Nothing}
completed_at::Union{DateTime, Nothing}
app::Union{App, Nothing}
pull_requests::Union{Vector{PullRequest}, Nothing}
end
CheckRun(data::Dict) = json2github(CheckRun, data)
namefield(cr::CheckRun) = cr.id
Expand Down
5 changes: 2 additions & 3 deletions src/apps/installations.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
mutable struct Installation <: GitHubType
id::Nullable{Int}
id::Union{Int, Nothing}
end

namefield(i::Installation) = i.id

Installation(data::Dict) = json2github(Installation, data)
Installation(id::Int) = Installation(Dict("id" => id))

@api_default function create_access_token(api::GitHubAPI, i::Installation, auth::JWTAuth; headers = Dict(), options...)
headers["Accept"] = "application/vnd.github.machine-man-preview+json"
payload = gh_post_json(api, "/installations/$(get(i.id))/access_tokens", auth = auth,
payload = gh_post_json(api, "/installations/$(i.id)/access_tokens", auth = auth,
headers=headers, options...)
OAuth2(payload["token"])
end
Expand Down
38 changes: 19 additions & 19 deletions src/gists/gist.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
mutable struct Gist <: GitHubType
url::Nullable{HTTP.URI}
forks_url::Nullable{HTTP.URI}
commits_url::Nullable{HTTP.URI}
id::Nullable{String}
description::Nullable{String}
public::Nullable{Bool}
owner::Nullable{Owner}
user::Nullable{Owner}
truncated::Nullable{Bool}
comments::Nullable{Int}
comments_url::Nullable{HTTP.URI}
html_url::Nullable{HTTP.URI}
git_pull_url::Nullable{HTTP.URI}
git_push_url::Nullable{HTTP.URI}
created_at::Nullable{Dates.DateTime}
updated_at::Nullable{Dates.DateTime}
forks::Nullable{Vector{Gist}}
files::Nullable{Dict}
history::Nullable{Vector{Dict}}
url::Union{HTTP.URI, Nothing}
forks_url::Union{HTTP.URI, Nothing}
commits_url::Union{HTTP.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}
created_at::Union{Dates.DateTime, Nothing}
updated_at::Union{Dates.DateTime, Nothing}
forks::Union{Vector{Gist}, Nothing}
files::Union{Dict, Nothing}
history::Union{Vector{Dict}, Nothing}
end

Gist(data::Dict) = json2github(Gist, data)
Expand Down
10 changes: 5 additions & 5 deletions src/git/blob.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mutable struct Blob <: GitHubType
content::Nullable{String}
encoding::Nullable{String}
url::Nullable{HTTP.URI}
sha::Nullable{String}
size::Nullable{Int}
content::Union{String, Nothing}
encoding::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
sha::Union{String, Nothing}
size::Union{Int, Nothing}
end

Blob(data::Dict) = json2github(Blob, data)
Expand Down
16 changes: 8 additions & 8 deletions src/git/gitcommit.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mutable struct GitCommit <: GitHubType
sha::Nullable{String}
url::Nullable{HTTP.URI}
author::Nullable{Dict}
commiter::Nullable{Dict}
message::Nullable{String}
tree::Nullable{Dict}
parents::Nullable{Vector}
verification::Nullable{Dict}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
author::Union{Dict, Nothing}
commiter::Union{Dict, Nothing}
message::Union{String, Nothing}
tree::Union{Dict, Nothing}
parents::Union{Vector, Nothing}
verification::Union{Dict, Nothing}
end

GitCommit(data::Dict) = json2github(GitCommit, data)
Expand Down
8 changes: 4 additions & 4 deletions src/git/reference.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mutable struct Reference <: GitHubType
ref::Nullable{String}
url::Nullable{HTTP.URI}
object::Nullable{Dict}
ref::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
object::Union{Dict, Nothing}
end

Reference(data::Dict) = json2github(Reference, data)

name(ref::Reference) = String(split(get(ref.ref), "refs/")[2])
name(ref::Reference) = String(split(ref.ref, "refs/")[2])

@api_default function reference(api::GitHubAPI, repo, ref_obj; options...)
result = gh_get_json(api, "/repos/$(name(repo))/git/refs/$(name(ref_obj))"; options...)
Expand Down
14 changes: 7 additions & 7 deletions src/git/tag.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mutable struct Tag <: GitHubType
tag::Nullable{String}
sha::Nullable{String}
url::Nullable{HTTP.URI}
message::Nullable{String}
tagger::Nullable{Dict}
object::Nullable{Dict}
verification::Nullable{Dict}
tag::Union{String, Nothing}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
message::Union{String, Nothing}
tagger::Union{Dict, Nothing}
object::Union{Dict, Nothing}
verification::Union{Dict, Nothing}
end

Tag(data::Dict) = json2github(Tag, data)
Expand Down
8 changes: 4 additions & 4 deletions src/git/tree.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mutable struct Tree <: GitHubType
sha::Nullable{String}
url::Nullable{HTTP.URI}
tree::Nullable{Vector}
truncated::Nullable{Bool}
sha::Union{String, Nothing}
url::Union{HTTP.URI, Nothing}
tree::Union{Vector, Nothing}
truncated::Union{Bool, Nothing}
end

Tree(data::Dict) = json2github(Tree, data)
Expand Down
32 changes: 16 additions & 16 deletions src/issues/comments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
################

mutable struct Comment <: GitHubType
body::Nullable{String}
path::Nullable{String}
diff_hunk::Nullable{String}
original_commit_id::Nullable{String}
commit_id::Nullable{String}
id::Nullable{Int}
original_position::Nullable{Int}
position::Nullable{Int}
line::Nullable{Int}
created_at::Nullable{Dates.DateTime}
updated_at::Nullable{Dates.DateTime}
url::Nullable{HTTP.URI}
html_url::Nullable{HTTP.URI}
issue_url::Nullable{HTTP.URI}
pull_request_url::Nullable{HTTP.URI}
user::Nullable{Owner}
body::Union{String, Nothing}
path::Union{String, Nothing}
diff_hunk::Union{String, Nothing}
original_commit_id::Union{String, Nothing}
commit_id::Union{String, Nothing}
id::Union{Int, Nothing}
original_position::Union{Int, Nothing}
position::Union{Int, Nothing}
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}
user::Union{Owner, Nothing}
end

Comment(data::Dict) = json2github(Comment, data)
Expand Down
Loading

0 comments on commit 7de5ecd

Please sign in to comment.