# assert user.login == "Morriar"
fun load_user(login: String): nullable User do
var user = new User(self, login)
- user.load_from_github
- if was_error then return null
- return user
+ return user.load_from_github
end
# Get the Github repo with `full_name`.
# assert repo.default_branch.name == "master"
fun load_repo(full_name: String): nullable Repo do
var repo = new Repo(self, full_name)
- repo.load_from_github
- if was_error then return null
- return repo
+ return repo.load_from_github
end
# Get the Github branch with `name`.
# assert branch.commit isa Commit
fun load_branch(repo: Repo, name: String): nullable Branch do
var branch = new Branch(self, repo, name)
- branch.load_from_github
- if was_error then return null
- return branch
+ return branch.load_from_github
end
# Get the Github commit with `sha`.
# assert commit isa Commit
fun load_commit(repo: Repo, sha: String): nullable Commit do
var commit = new Commit(self, repo, sha)
- commit.load_from_github
- if was_error then return null
- return commit
+ return commit.load_from_github
end
# Get the Github issue #`number`.
# assert issue.title == "Doc"
fun load_issue(repo: Repo, number: Int): nullable Issue do
var issue = new Issue(self, repo, number)
- issue.load_from_github
- if was_error then return null
- return issue
+ return issue.load_from_github
end
# Get the Github pull request #`number`.
# assert pull.user.login == "Morriar"
fun load_pull(repo: Repo, number: Int): nullable PullRequest do
var pull = new PullRequest(self, repo, number)
- pull.load_from_github
- if was_error then return null
- return pull
+ return pull.load_from_github
end
# Get the Github label with `name`.
# assert labl != null
fun load_label(repo: Repo, name: String): nullable Label do
var labl = new Label(self, repo, name)
- labl.load_from_github
- if was_error then return null
- return labl
+ return labl.load_from_github
end
# Get the Github milestone with `id`.
# assert stone.title == "v1.0prealpha"
fun load_milestone(repo: Repo, id: Int): nullable Milestone do
var milestone = new Milestone(self, repo, id)
- milestone.load_from_github
- if was_error then return null
- return milestone
+ return milestone.load_from_github
end
end
var json: JsonObject is noinit, protected writable
# Load `json` from Github API.
- private fun load_from_github do
+ private fun load_from_github: nullable SELF do
json = api.load_from_github(key)
+ if api.was_error then return null
+ return self
end
redef fun to_s do return json.to_json