diff --git a/README.md b/README.md index 682e1bb1..b8029be1 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ There are a lot of pieces of the GitHub API to cover. Here are the ones that nee - [ ] [Pages]() - [ ] [Projects]() - [x] [PubSubHubbub](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PubSubHubbub.html) -- [ ] [PullRequests]() +- [x] [PullRequests](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PullRequests.html) - [x] [RateLimit](https://octokit-cr.github.io/octokit.cr/Octokit/Client/RateLimit.html) - [ ] [Reactions]() - [ ] [Refs]() diff --git a/shard.yml b/shard.yml index 6e921d6a..d5cae59c 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: octokit -version: 0.2.5 +version: 0.3.0 authors: - Grant Birkinbine diff --git a/spec/acceptance/acceptance.cr b/spec/acceptance/acceptance.cr index ca08987a..83cf34ac 100644 --- a/spec/acceptance/acceptance.cr +++ b/spec/acceptance/acceptance.cr @@ -4,6 +4,8 @@ require "spec" describe Octokit do github = Octokit.client + github.auto_paginate = true + github.per_page = 100 describe ".get" do context "when fetching info about the octokit.cr repo" do @@ -23,4 +25,94 @@ describe Octokit do end end end + + describe "pull requests" do + context "fetches closed pull requests" do + pulls = github.pull_requests("octokit-cr/octokit.cr", state: "closed").records + + it "should find at least one closed pull request" do + pulls.size.should be > 0 + end + + it "should fetch the title of the first closed pull request" do + pulls.first.title.should_not be_nil + end + end + + context "fetches pull request comments" do + comments = github.pull_request_comments("octokit-cr/octokit.cr", 15).records + + it "should find at least one comment" do + comments.size.should be > 0 + end + + it "should fetch the body of the first comment" do + comments.first.body.should_not be_nil + end + + it "should fetch the diff_hunk of the first comment" do + comments.first.diff_hunk.should_not be_nil + end + + it "should fetch the path of the first comment" do + comments.first.path.should_not be_nil + end + + it "should fetch the position of the first comment" do + comments.first.position.should_not be_nil + end + + it "should fetch the ID of the first comment" do + comments.first.id.should_not be_nil + end + end + + context "fetches pull request files" do + files = github.pull_request_files("octokit-cr/octokit.cr", 15).records + + it "should find at least one file" do + files.size.should be > 0 + end + + it "should fetch the filename of the first file" do + files.first.filename.should_not be_nil + end + + it "should fetch the sha of the first file" do + files.first.sha.should_not be_nil + end + + it "should fetch the status of the first file" do + files.first.status.should_not be_nil + end + + it "should fetch the additions of the first file" do + files.first.additions.should_not be_nil + end + + it "should fetch the deletions of the first file" do + files.first.deletions.should_not be_nil + end + + it "should fetch the contents_url of the first file" do + files.first.contents_url.should_not be_nil + end + + it "should fetch the patch of the first file" do + files.first.patch.should_not be_nil + end + + it "should fetch the sha of the second file" do + files[1].sha.should_not be_nil + end + end + + context "merged pull request" do + pull = github.pull_merged?("octokit-cr/octokit.cr", 15) + + it "checks if the pull request is merged and finds that it is" do + pull.should eq true + end + end + end end diff --git a/src/octokit/client.cr b/src/octokit/client.cr index 21b31698..ce68c142 100644 --- a/src/octokit/client.cr +++ b/src/octokit/client.cr @@ -110,6 +110,7 @@ module Octokit include Octokit::Client::Issues include Octokit::Client::Markdown include Octokit::Client::PubSubHubbub + include Octokit::Client::PullRequests include Octokit::Client::Users include Octokit::Client::RateLimit include Octokit::Client::Repositories diff --git a/src/octokit/client/pull_requests.cr b/src/octokit/client/pull_requests.cr index e69de29b..039f00ab 100644 --- a/src/octokit/client/pull_requests.cr +++ b/src/octokit/client/pull_requests.cr @@ -0,0 +1,411 @@ +require "uri" +require "../models/repos" +require "../models/pulls" +require "../models/commits" +require "../models/pull_comments" +require "../models/repo_commits" + +module Octokit + class Client + # Methods for the Pull Requests API + # + # All "repo" params are constructed in the format of `/` + # + # **See Also:** + # - [https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28) + + module PullRequests + # :nodoc: + alias Repository = Models::Repository + # :nodoc: + alias PullRequest = Octokit::Models::PullRequest + # :nodoc: + alias Commit = Octokit::Models::Commit + # :nodoc: + alias PullRequestComment = Octokit::Models::PullRequestComment + # :nodoc: + alias CommitFile = Octokit::Models::CommitFile + + # Valid filters for PullRequests + FILTERS = ["all", "assigned", "created", "mentioned", "subscribed"] + + # Valid states for PullRequests + STATES = ["all", "open", "closed"] + + # Valid sort for PullRequests + SORTS = ["created", "updated", "comments"] + + # Valid directions in which to sort PullRequests + DIRECTIONS = ["asc", "desc"] + + # The default options for listing pull requests + DEFAULTS = { + state: "open", + sort: "created", + direction: "desc", + } + + # List pull requests for a repository + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#list-pull-requests](https://developer.github.com/v3/pulls/#list-pull-requests) + # + # **Examples:** + # + # ``` + # Octokit.pull_requests("crystal-lang/crystal") + # Octokit.pull_requests("crystal-lang/crystal", state: "closed") + # ``` + def pull_requests(repo : String, **options) : Paginator(PullRequest) + validate_options(options) + paginate( + PullRequest, + "#{Repository.path(repo)}/pulls", + options: {params: DEFAULTS.merge(options)} + ) + end + + alias_method :pull_requests, :pulls + + # Create a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#create-a-pull-request](https://developer.github.com/v3/pulls/#create-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.create_pull_request("crystal-lang/crystal", "master", "new-branch", "Title", "Body") + # ``` + def create_pull_request(repo : String, base : String, head : String, title : String, body : String, **options) + options = {base: base, head: head, title: title, body: body}.merge(options) + post "#{Repository.path repo}/pulls", {json: options} + end + + # Create a pull request for an issue + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#create-a-pull-request](https://developer.github.com/v3/pulls/#create-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.create_pull_request_for_issue("crystal-lang/crystal", "master", "new-branch", 123) + # ``` + def create_pull_request_for_issue(repo : String, base : String, head : String, issue : Int32, **options) + options = {base: base, head: head, issue: issue}.merge(options) + post "#{Repository.path repo}/pulls", {json: options} + end + + # Update a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#update-a-pull-request](https://developer.github.com/v3/pulls/#update-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.update_pull_request("crystal-lang/crystal", 123, title: "New Title", body: "New Body") + # ``` + def update_pull_request(repo : String, number : Int64, **options) + patch "#{Repository.path repo}/pulls/#{number}", {json: options} + end + + # Close a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#update-a-pull-request](https://developer.github.com/v3/pulls/#update-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.close_pull_request("crystal-lang/crystal", 123) + # ``` + def close_pull_request(repo : String, number : Int64, **options) + options = {state: "closed"}.merge(options) + patch "#{Repository.path repo}/pulls/#{number}", {json: options} + end + + # List commits on a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request](https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.pull_request_commits("crystal-lang/crystal", 123) + # ``` + def pull_request_commits(repo : String, number : Int64, **options) : Paginator(Commit) + paginate( + Commit, + "#{Repository.path(repo)}/pulls/#{number}/commits", + options: {params: options} + ) + end + + alias_method :pull_request_commits, :pull_commits + + # List review comments on a pull request + # + # This method applies to pull request review comments. Pull request review comments are NOT the same as standard comments left on PRs - those are issue comments. + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request](https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.pull_requests_comments("crystal-lang/crystal", 123) + # ``` + def pull_requests_comments(repo : String, number : Int64, **options) : Paginator(PullRequestComment) + paginate( + PullRequestComment, + "#{Repository.path(repo)}/pulls/#{number}/comments", + options: {params: options} + ) + end + + alias_method :pull_requests_comments, :reviews_comments + + # List comments on a pull request + # + # This method applies to pull request review comments. Pull request review comments are NOT the same as standard comments left on PRs - those are issue comments. + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request](https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.pull_request_comments("crystal-lang/crystal", 123) + # ``` + def pull_request_comments(repo : String, number : Int64, **options) : Paginator(PullRequestComment) + paginate( + PullRequestComment, + "#{Repository.path(repo)}/pulls/#{number}/comments", + options: {params: options} + ) + end + + alias_method :pull_request_comments, :pull_comments + alias_method :pull_request_comments, :review_comments + + # Get a single comment on a pull request + # + # This method applies to pull request review comments. Pull request review comments are NOT the same as standard comments left on PRs - those are issue comments. + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#get-a-single-comment](https://developer.github.com/v3/pulls/comments/#get-a-single-comment) + # + # **Examples:** + # + # ``` + # Octokit.pull_request_comment("crystal-lang/crystal", 456) + # ``` + def pull_request_comment(repo : String, comment_id : Int64, **options) + get "#{Repository.path(repo)}/pulls/comments/#{comment_id}", {params: options} + end + + alias_method :pull_request_comment, :pull_comment + alias_method :pull_request_comment, :review_comment + + # Create a comment on a pull request + # + # This method applies to pull request review comments. Pull request review comments are NOT the same as standard comments left on PRs - those are issue comments. + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#create-a-comment](https://developer.github.com/v3/pulls/comments/#create-a-comment) + # + # - repo (String) — A GitHub repository + # - number (Integer) — Pull request number + # - body (String) — Comment content + # - commit_id (String) — Sha of the commit to comment on + # - path (String) — Relative path of the file to comment on + # - line (Integer) — Line number in the diff to comment on + # - side (String) — Side of the diff that the comment applies to (LEFT or RIGHT) + # - start_line (Integer) — Start line for multi-line comments + # - start_side (String) — Start side for multi-line comments (LEFT or RIGHT) + # - in_reply_to (Integer) — ID of the review comment to reply to + # - subject_type (String) — Level at which the comment is targeted (line or file) + # + # **Examples:** + # + # ``` + # Octokit.create_pull_request_comment("crystal-lang/crystal", 123, "Comment body", "commit_id", "path/to/file.txt", 1, side: "RIGHT") + # ``` + def create_pull_request_comment( + repo : String, + number : Int64, + body : String, + commit_id : String, + path : String, + line : Int32, + **options + ) + options = { + body: body, + commit_id: commit_id, + path: path, + line: line, + }.merge(options) + post "#{Repository.path repo}/pulls/#{number}/comments", {json: options} + end + + alias_method :create_pull_request_comment, :create_pull_comment + alias_method :create_pull_request_comment, :create_review_comment + + # Create a reply to a comment on a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#create-a-reply-to-a-comment](https://developer.github.com/v3/pulls/comments/#create-a-reply-to-a-comment) + # + # **Examples:** + # + # ``` + # Octokit.create_pull_request_comment_reply("crystal-lang/crystal", 123, "Comment body", 456) + # ``` + def create_pull_request_comment_reply(repo : String, number : Int64, body : String, in_reply_to : Int64, **options) + options = {body: body, in_reply_to: in_reply_to}.merge(options) + post "#{Repository.path repo}/pulls/#{number}/comments", {json: options} + end + + alias_method :create_pull_request_comment_reply, :create_pull_reply + alias_method :create_pull_request_comment_reply, :create_review_reply + + # Update a comment on a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#update-a-comment](https://developer.github.com/v3/pulls/comments/#update-a-comment) + # + # **Examples:** + # + # ``` + # Octokit.update_pull_request_comment("crystal-lang/crystal", 456, "New comment body") + # ``` + def update_pull_request_comment(repo : String, comment_id : Int64, body : String, **options) + options = {body: body}.merge(options) + patch "#{Repository.path repo}/pulls/comments/#{comment_id}", {json: options} + end + + alias_method :update_pull_request_comment, :update_pull_comment + alias_method :update_pull_request_comment, :update_review_comment + + # Delete a comment on a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/comments/#delete-a-comment](https://developer.github.com/v3/pulls/comments/#delete-a-comment) + # + # **Examples:** + # + # ``` + # Octokit.delete_pull_request_comment("crystal-lang/crystal", 456) + # ``` + def delete_pull_request_comment(repo : String, comment_id : Int64, **options) + delete "#{Repository.path repo}/pulls/comments/#{comment_id}", {params: options} + end + + alias_method :delete_pull_request_comment, :delete_pull_comment + alias_method :delete_pull_request_comment, :delete_review_comment + + # List files on a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#list-pull-requests-files](https://developer.github.com/v3/pulls/#list-pull-requests-files) + # + # **Examples:** + # + # ``` + # Octokit.pull_request_files("crystal-lang/crystal", 123) + # ``` + def pull_request_files(repo : String, number : Int64, **options) : Paginator(CommitFile) + paginate( + CommitFile, + "#{Repository.path(repo)}/pulls/#{number}/files", + options: {params: options} + ) + end + + alias_method :pull_request_files, :pull_files + + # Update a pull request branch + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#update-a-pull-request-branch](https://developer.github.com/v3/pulls/#update-a-pull-request-branch) + # + # **Examples:** + # ``` + # Octokit.update_pull_request_branch("crystal-lang/crystal", 123) + # ``` + def update_pull_request_branch(repo : String, number : Int64, **options) : Bool + boolean_from_response( + :put, + "#{Repository.path(repo)}/pulls/#{number}/update-branch" + ) + end + + # Merge a pull request + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#merge-a-pull-request](https://developer.github.com/v3/pulls/#merge-a-pull-request) + # + # **Examples:** + # + # ``` + # Octokit.merge_pull_request("crystal-lang/crystal", 123, "Commit message") + # ``` + def merge_pull_request(repo : String, number : Int64, commit_message : String, **options) + options = {commit_message: commit_message}.merge(options) + put "#{Repository.path repo}/pulls/#{number}/merge", {json: options} + end + + # Check if a pull request has been merged + # + # **See Also:** + # - [https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged](https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged) + # + # **Examples:** + # + # ``` + # Octokit.pull_merged?("crystal-lang/crystal", 123) + # ``` + def pull_merged?(repo : String, number : Int64, **options) : Bool + boolean_from_response( + :get, + "#{Repository.path(repo)}/pulls/#{number}/merge", + options: {params: options} + ) + end + + alias_method :pull_merged?, :pull_request_merged? + + # Validate options for filtering issues and log a warning if an incorrect + # filter is used. + protected def validate_options(options) + if filter = options[:filter]? + unless FILTERS.includes?(filter.to_s) + octokit_warn "'#{filter}' is not a valid Issue filter. Valid values are: #{FILTERS}" + end + end + + if state = options[:state]? + unless STATES.includes?(state.to_s) + octokit_warn "'#{state}' is not a valid Issue state. Valid values are: #{STATES}" + end + end + + if sort = options[:sort]? + unless SORTS.includes?(sort.to_s) + octokit_warn "'#{sort}' is not a valid Issue sort. Valid values are: #{SORTS}" + end + end + + if direction = options[:direction]? + unless DIRECTIONS.includes(direction.to_s) + octokit_warn "'#{direction}' is not a valid Issue sort direction. Valid values are: #{DIRECTIONS}" + end + end + end + end + end +end diff --git a/src/octokit/connection.cr b/src/octokit/connection.cr index b0d6fac7..e9aed413 100644 --- a/src/octokit/connection.cr +++ b/src/octokit/connection.cr @@ -16,6 +16,9 @@ module Octokit # Header keys that can be passed in options hash to {#get},{#head} CONVENIENCE_HEADERS = Set{"accept", "content_type"} + # Successful status codes from PUT/POST/PATCH requests + SUCCESSFUL_STATUSES = [201, 202, 204] + # Make a HTTP GET request def get(url, options = nil) request "get", url, make_options(options) @@ -114,7 +117,7 @@ module Octokit @agent = nil end - protected def request(method, path, options = nil) + protected def request(method : Symbol | String, path : String, options = nil) path = File.join(endpoint, path) unless path.nil? || path.starts_with?("http") options = options ? @connection_options.merge(options) : @connection_options @last_response = response = agent.request(verb: method.to_s, uri: path, options: options) @@ -122,7 +125,7 @@ module Octokit response.body end - protected def request(method, path, options = nil, &) + protected def request(method : Symbol | String, path : String, options = nil, &) path = File.join(endpoint, path) unless path.nil? || path.starts_with?("http") options = options ? @connection_options.merge(options) : @connection_options @last_response = response = agent.request(verb: method, uri: path, options: options) @@ -132,9 +135,9 @@ module Octokit end # Executes the request, checking if it was successful - protected def boolean_from_response(method, path, options = nil) - request(method, path, options) - @last_response.not_nil!.status_code == 204 + protected def boolean_from_response(method : Symbol, path : String, options : NamedTuple | Nil = nil) : Bool + request(method, path, make_options(options)) + @last_response.not_nil!.status_code.in?(SUCCESSFUL_STATUSES) rescue Error::NotFound false end @@ -146,7 +149,7 @@ module Octokit end end - protected def make_options(options) + protected def make_options(options) : Halite::Options? return if options.nil? options.is_a?(Halite::Options) ? options : Halite::Options.new(**options) end @@ -331,28 +334,30 @@ module Octokit # pages.fetch_all # pages.last? # => Bool # ``` - def last? + def last? : Bool @current_page == @total_pages end # Checks if the paginator is empty. - def empty? + def empty? : Bool @records.empty? end # Utility method to set the `@total_pages` variable. private def set_total_pages! - return 0 if @client.last_response.nil? + return @total_pages = 0 if @client.last_response.nil? if links = @client.last_response.try(&.links) - return 0 unless links["last"]? + unless links["last"]? + @total_pages = 1 + return + end if target = links["last"].target if match = target.match(/page=([0-9]+)/) @total_pages = match[1].to_i end - else end else - 0 + @total_pages = 1 end end end diff --git a/src/octokit/default.cr b/src/octokit/default.cr index 16fc2785..b18b80d2 100644 --- a/src/octokit/default.cr +++ b/src/octokit/default.cr @@ -36,7 +36,7 @@ module Octokit end # Default access token from ENV - def access_token + def access_token : String? ENV["OCTOKIT_ACCESS_TOKEN"]? end @@ -76,7 +76,7 @@ module Octokit end # Default options for `Halite::Options` - def connection_options + def connection_options : Halite::Options Halite::Options.new( headers: { accept: default_media_type, @@ -90,7 +90,7 @@ module Octokit end # Default GitHub username for Basic Auth from ENV - def login + def login : String? ENV["OCTOKIT_LOGIN"]? end @@ -100,12 +100,12 @@ module Octokit end # Default GitHub password for Basic Auth from ENV - def password + def password : String? ENV["OCTOKIT_PASSWORD"]? end # Default pagination page size from ENV - def per_page + def per_page : Int32? page_size = ENV["OCTOKIT_PER_PAGE"]? page_size.to_i if page_size end @@ -117,7 +117,7 @@ module Octokit end # Default SSL verify mode from ENV - def ssl_verify_mode + def ssl_verify_mode : Int32 # 0 is OpenSSL::SSL::NONE # 1 is OpenSSL::SSL::PEER # the standard default for SSL is PEER which requires a server certificate check on the client @@ -125,18 +125,19 @@ module Octokit end # Default User-Agent header string from ENV or `USER_AGENT` - def user_agent + def user_agent : String ENV["OCTOKIT_USER_AGENT"]? || USER_AGENT end # Default web endpoint from ENV or `WEB_ENDPOINT` - def web_endpoint + def web_endpoint : String ENV["OCTOKIT_WEB_ENDPOINT"]? || WEB_ENDPOINT end # Default logger def logger - Log.setup(:warn) + log_level = ENV["OCTOKIT_LOG_LEVEL"]?.to_s.upcase || "INFO".to_s.upcase + Log.setup(log_level) ::Log.for(self) end end diff --git a/src/octokit/models/commits.cr b/src/octokit/models/commits.cr index ba5d5690..743752ec 100644 --- a/src/octokit/models/commits.cr +++ b/src/octokit/models/commits.cr @@ -12,24 +12,24 @@ module Octokit struct Commit Octokit.rest_model( sha: String, - author: CommitAuthor, - committer: CommitAuthor, - message: String, - tree: Tree, - parents: Array(Commit), - stats: CommitStats, + author: CommitAuthor?, + committer: CommitAuthor?, + message: String?, + tree: Tree?, + parents: Array(Commit)?, + stats: CommitStats?, html_url: String, url: String, - verification: SignatureVerification, - node_id: String + verification: SignatureVerification?, + node_id: String? ) end struct CommitAuthor Octokit.rest_model( - date: String, - name: String, - email: String, + date: String?, + name: String?, + email: String?, login: String ) diff --git a/src/octokit/models/pull_comments.cr b/src/octokit/models/pull_comments.cr index bbb639cf..b71615c0 100644 --- a/src/octokit/models/pull_comments.cr +++ b/src/octokit/models/pull_comments.cr @@ -4,7 +4,7 @@ module Octokit Octokit.rest_model( id: Int64, node_id: String, - in_reply_to: Int64, + in_reply_to: Int64?, body: String, path: String, diff_hunk: String, diff --git a/src/octokit/models/pulls.cr b/src/octokit/models/pulls.cr index 32b86360..0e698318 100644 --- a/src/octokit/models/pulls.cr +++ b/src/octokit/models/pulls.cr @@ -1,3 +1,6 @@ +require "../core_ext/time" +require "./issue_labels" + module Octokit module Models struct PullRequest @@ -6,24 +9,24 @@ module Octokit number: Int32, state: String, title: String, - body: String, + body: String?, created_at: {type: Time, converter: Time::ISO8601Converter}, updated_at: {type: Time, converter: Time::ISO8601Converter}, - closed_at: String, - merged_at: String, - labels: Array(Label), + closed_at: String?, + merged_at: String?, + labels: Array(Label)?, user: User, draft: Bool, - merged: Bool, - mergeable: Bool, - mergeable_state: String, - merged_by: String, + merged: Bool?, + mergeable: Bool?, + mergeable_state: String?, + merged_by: String?, merge_commit_sha: String, - comments: Int32, - commits: Int32, - additions: Int32, - deletions: Int32, - changed_files: Int32, + comments: Int32?, + commits: Int32?, + additions: Int32?, + deletions: Int32?, + changed_files: Int32?, url: String, html_url: String, issue_url: String, @@ -33,22 +36,22 @@ module Octokit commits_url: String, comments_url: String, review_comment_url: String, - review_comments: Int32, - assignee: User, - assignees: Array(User), - milestone: Milestone, - maintainer_can_modify: Bool, + review_comments: Int32?, + assignee: User?, + assignees: Array(User)?, + milestone: Milestone?, + maintainer_can_modify: Bool?, author_association: String, node_id: String, requested_reviewers: Array(User), requested_teams: Array(Team), - links: PRLinks, + links: PRLinks?, head: PullRequestBranch, base: PullRequestBranch, - active_lock_reason: String + active_lock_reason: String? ) end @@ -76,7 +79,7 @@ module Octokit label: String, ref: String, sha: String, - repo: Repository, + repo: Repository?, user: User ) end diff --git a/src/octokit/models/repo_commits.cr b/src/octokit/models/repo_commits.cr index a457e67d..b7719997 100644 --- a/src/octokit/models/repo_commits.cr +++ b/src/octokit/models/repo_commits.cr @@ -33,11 +33,11 @@ module Octokit deletions: Int32, changes: Int32, status: String, - patch: String, + patch: String?, blob_url: String, raw_url: String, contents_url: String, - previous_filename: String + previous_filename: String? ) end diff --git a/src/octokit/version.cr b/src/octokit/version.cr index f00d8126..db2becd1 100644 --- a/src/octokit/version.cr +++ b/src/octokit/version.cr @@ -1,3 +1,3 @@ module Octokit - VERSION = "0.2.5" + VERSION = "0.3.0" end diff --git a/src/octokit/warnable.cr b/src/octokit/warnable.cr index c8f5c203..db829c9f 100644 --- a/src/octokit/warnable.cr +++ b/src/octokit/warnable.cr @@ -5,7 +5,7 @@ module Octokit # OCTOKIT_SILENT is set to true. def octokit_warn(message) unless !!ENV["OCTOKIT_SILENT"]? - Octokit.logger.warn(message) + @logger.warn { message } end end end