return get("/repos/{repo_slug}/commits/{sha}").as(nullable Commit)
end
+ # Get the status of a commit
+ #
+ # The status holds the result of each check ran on a commit like CI, reviews etc.
+ fun get_commit_status(repo_slug: String, sha: String): nullable CommitStatus do
+ return get("/repos/{repo_slug}/commits/{sha}/status").as(nullable CommitStatus)
+ end
+
# Get the Github issue #`number`.
#
# Returns `null` if the issue cannot be found.
var path: nullable String is writable
end
+# Status of a commit
+#
+# Can contain sub-status for reviews, CI etc.
+class CommitStatus
+ serialize
+
+ # Global state of this commit
+ var state: nullable String = null is optional, writable
+
+ # Sha of the commit this status is for
+ var sha: nullable String = null is optional, writable
+
+ # Repository the commit belongs to
+ var repository: nullable Repo = null is optional, writable
+
+ # All sub statuses (one for each check)
+ var statuses = new Array[RepoStatus] is optional, writable
+
+ # Total count of sub statuses
+ var total_count: nullable Int = null is optional, writable
+end
+
+# Sub status of a CommitStatus
+#
+# Represents a check applied to a commit (reviews, CI, ...).
+class RepoStatus
+ serialize
+
+ # State of this check
+ var state: nullable String = null is optional, writable
+
+ # Description of this check
+ var description: nullable String = null is optional, writable
+
+ # External URL
+ var target_url: nullable String = null is optional, writable
+
+ # Context this status is related to
+ #
+ # Used to hold the name of the check applied.
+ var context: nullable String = null is optional, writable
+
+ # Date when this status was created
+ var created_at: nullable String = null is optional, writable
+
+ # Last date this status was updated
+ var updated_at: nullable String = null is optional, writable
+end
+
# Comments made on Github issue and pull request pages.
#
# Should be accessed from `GithubAPI::get_issue_comment`.
map["{pattern_base}/repos/[^/]*/[^/]*/pulls/comments/[0-9]+$".to_re] = "ReviewComment"
map["{pattern_base}/repos/[^/]*/[^/]*/comments/[0-9]+$".to_re] = "CommitComment"
map["{pattern_base}/repos/[^/]*/[^/]*/commits/[a-f0-9]+$".to_re] = "Commit"
+ map["{pattern_base}/repos/[^/]*/[^/]*/commits/[a-f0-9]+/status$".to_re] = "CommitStatus"
+ map["{pattern_base}/repos/[^/]*/[^/]*/statuses/[a-f0-9]+$".to_re] = "RepoStatus"
return map
end
--- /dev/null
+{"state":"failure","statuses":[{"url":"https://api.github.com/repos/nitlang/nit/statuses/4e3c688d2c4b875c00f206eb4c4b6f2c4f34c096","avatar_url":"https://avatars1.githubusercontent.com/u/135828?v=4","id":7133267167,"node_id":"MDEzOlN0YXR1c0NvbnRleHQ3MTMzMjY3MTY3","state":"failure","description":"Merged pipeline on gitlab: failed","target_url":"https://gitlab.com/nit/nit-ci/pipelines/69275842","context":"gitlab-ci","created_at":"2019-07-03T20:28:57Z","updated_at":"2019-07-03T20:28:57Z"}],"sha":"4e3c688d2c4b875c00f206eb4c4b6f2c4f34c096","total_count":1,"repository":{"id":328597,"node_id":"MDEwOlJlcG9zaXRvcnkzMjg1OTc=","name":"nit","full_name":"nitlang/nit","private":false,"owner":{"login":"nitlang","id":5420298,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MjAyOTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5420298?v=4","gravatar_id":"","url":"https://api.github.com/users/nitlang","html_url":"https://github.com/nitlang","followers_url":"https://api.github.com/users/nitlang/followers","following_url":"https://api.github.com/users/nitlang/following{/other_user}","gists_url":"https://api.github.com/users/nitlang/gists{/gist_id}","starred_url":"https://api.github.com/users/nitlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nitlang/subscriptions","organizations_url":"https://api.github.com/users/nitlang/orgs","repos_url":"https://api.github.com/users/nitlang/repos","events_url":"https://api.github.com/users/nitlang/events{/privacy}","received_events_url":"https://api.github.com/users/nitlang/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/nitlang/nit","description":"Nit language","fork":false,"url":"https://api.github.com/repos/nitlang/nit","forks_url":"https://api.github.com/repos/nitlang/nit/forks","keys_url":"https://api.github.com/repos/nitlang/nit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nitlang/nit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nitlang/nit/teams","hooks_url":"https://api.github.com/repos/nitlang/nit/hooks","issue_events_url":"https://api.github.com/repos/nitlang/nit/issues/events{/number}","events_url":"https://api.github.com/repos/nitlang/nit/events","assignees_url":"https://api.github.com/repos/nitlang/nit/assignees{/user}","branches_url":"https://api.github.com/repos/nitlang/nit/branches{/branch}","tags_url":"https://api.github.com/repos/nitlang/nit/tags","blobs_url":"https://api.github.com/repos/nitlang/nit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nitlang/nit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nitlang/nit/git/refs{/sha}","trees_url":"https://api.github.com/repos/nitlang/nit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nitlang/nit/statuses/{sha}","languages_url":"https://api.github.com/repos/nitlang/nit/languages","stargazers_url":"https://api.github.com/repos/nitlang/nit/stargazers","contributors_url":"https://api.github.com/repos/nitlang/nit/contributors","subscribers_url":"https://api.github.com/repos/nitlang/nit/subscribers","subscription_url":"https://api.github.com/repos/nitlang/nit/subscription","commits_url":"https://api.github.com/repos/nitlang/nit/commits{/sha}","git_commits_url":"https://api.github.com/repos/nitlang/nit/git/commits{/sha}","comments_url":"https://api.github.com/repos/nitlang/nit/comments{/number}","issue_comment_url":"https://api.github.com/repos/nitlang/nit/issues/comments{/number}","contents_url":"https://api.github.com/repos/nitlang/nit/contents/{+path}","compare_url":"https://api.github.com/repos/nitlang/nit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nitlang/nit/merges","archive_url":"https://api.github.com/repos/nitlang/nit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nitlang/nit/downloads","issues_url":"https://api.github.com/repos/nitlang/nit/issues{/number}","pulls_url":"https://api.github.com/repos/nitlang/nit/pulls{/number}","milestones_url":"https://api.github.com/repos/nitlang/nit/milestones{/number}","notifications_url":"https://api.github.com/repos/nitlang/nit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nitlang/nit/labels{/name}","releases_url":"https://api.github.com/repos/nitlang/nit/releases{/id}","deployments_url":"https://api.github.com/repos/nitlang/nit/deployments"},"commit_url":"https://api.github.com/repos/nitlang/nit/commits/4e3c688d2c4b875c00f206eb4c4b6f2c4f34c096","url":"https://api.github.com/repos/nitlang/nit/commits/4e3c688d2c4b875c00f206eb4c4b6f2c4f34c096/status"}
\ No newline at end of file
map["/repos/nitlang/nit/pulls?page=1&per_page=3"] = "repo_pulls_nit"
map["/repos/nitlang/nit/pulls/1000"] = "repo_pulls_1000"
map["/repos/nitlang/nit/commits/64ce1f"] = "repo_commits_64ce1f"
+ map["/repos/nitlang/nit/commits/4e3c688d/status"] = "repo_commits_4e3c68_status"
map["/repos/nitlang/nit/comments/8982707"] = "repo_comments_8982707"
map["/repos/nitlang/nit/pulls/comments/21010363"] = "repo_pulls_comment_21010363"
map["/search/issues?q=foo repo:nitlang/nit&page=1&per_page=3"] = "repo_search_issues_nit"
# TODO other fields
end
+ fun test_get_commit_status is test do
+ var status = api.get_commit_status("nitlang/nit", "4e3c688d")
+ assert status isa CommitStatus
+ assert status.state == "failure"
+ assert status.sha == "4e3c688d2c4b875c00f206eb4c4b6f2c4f34c096"
+ assert status.total_count == 1
+
+ var sub = status.statuses.first
+ assert sub.state == "failure"
+ assert sub.description == "Merged pipeline on gitlab: failed"
+ assert sub.context == "gitlab-ci"
+
+ var repo = status.repository
+ assert repo isa Repo
+ assert repo.full_name == "nitlang/nit"
+ end
+
fun test_get_issue is test do
var issue = api.get_issue("nitlang/nit", 1000)
assert issue isa Issue