summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d2994bc)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
# The API client allows you to get Github API entities.
#
# ~~~nitish
# The API client allows you to get Github API entities.
#
# ~~~nitish
-# var repo = api.load_repo("nitlang/nit")
+# var repo = api.get_repo("nitlang/nit")
# assert repo != null
# assert repo.name == "nit"
#
# assert repo != null
# assert repo.name == "nit"
#
-# var user = api.load_user("Morriar")
+# var user = api.get_user("Morriar")
# assert user != null
# assert user.login == "Morriar"
# ~~~
# assert user != null
# assert user.login == "Morriar"
# ~~~
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var user = api.load_auth_user
+ # var user = api.get_auth_user
# assert user.login == "Morriar"
# ~~~
# assert user.login == "Morriar"
# ~~~
- fun load_auth_user: nullable User do
+ fun get_auth_user: nullable User do
return get("/user").as(nullable User)
end
return get("/user").as(nullable User)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var user = api.load_user("Morriar")
+ # var user = api.get_user("Morriar")
# print user or else "null"
# assert user.login == "Morriar"
# ~~~
# print user or else "null"
# assert user.login == "Morriar"
# ~~~
- fun load_user(login: String): nullable User do
+ fun get_user(login: String): nullable User do
return get("/users/{login}").as(nullable User)
end
return get("/users/{login}").as(nullable User)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
# assert repo.name == "nit"
# assert repo.owner.login == "nitlang"
# assert repo.default_branch == "master"
# ~~~
# assert repo.name == "nit"
# assert repo.owner.login == "nitlang"
# assert repo.default_branch == "master"
# ~~~
- fun load_repo(full_name: String): nullable Repo do
+ fun get_repo(full_name: String): nullable Repo do
return get("/repos/{full_name}").as(nullable Repo)
end
# List of branches associated with their names.
return get("/repos/{full_name}").as(nullable Repo)
end
# List of branches associated with their names.
- fun load_repo_branches(repo: Repo): Array[Branch] do
+ fun get_repo_branches(repo: Repo): Array[Branch] do
message(1, "Get branches for {repo.full_name}")
var array = get("/repos/{repo.full_name}/branches")
var res = new Array[Branch]
message(1, "Get branches for {repo.full_name}")
var array = get("/repos/{repo.full_name}/branches")
var res = new Array[Branch]
end
# List of issues associated with their ids.
end
# List of issues associated with their ids.
- fun load_repo_issues(repo: Repo): Array[Issue] do
+ fun get_repo_issues(repo: Repo): Array[Issue] do
message(1, "Get issues for {repo.full_name}")
var res = new Array[Issue]
message(1, "Get issues for {repo.full_name}")
var res = new Array[Issue]
- var issue = load_repo_last_issue(repo)
+ var issue = get_repo_last_issue(repo)
if issue == null then return res
res.add issue
while issue != null and issue.number > 1 do
if issue == null then return res
res.add issue
while issue != null and issue.number > 1 do
- issue = load_issue(repo, issue.number - 1)
+ issue = get_issue(repo, issue.number - 1)
if issue == null then continue
res.add issue
end
if issue == null then continue
res.add issue
end
end
# Get the last published issue.
end
# Get the last published issue.
- fun load_repo_last_issue(repo: Repo): nullable Issue do
+ fun get_repo_last_issue(repo: Repo): nullable Issue do
var array = get("/repos/{repo.full_name}/issues")
if not array isa JsonArray then return null
if array.is_empty then return null
var array = get("/repos/{repo.full_name}/issues")
if not array isa JsonArray then return null
if array.is_empty then return null
end
# List of labels associated with their names.
end
# List of labels associated with their names.
- fun load_repo_labels(repo: Repo): Array[Label] do
+ fun get_repo_labels(repo: Repo): Array[Label] do
message(1, "Get labels for {repo.full_name}")
var array = get("repos/{repo.full_name}/labels")
if not array isa JsonArray then return new Array[Label]
message(1, "Get labels for {repo.full_name}")
var array = get("repos/{repo.full_name}/labels")
if not array isa JsonArray then return new Array[Label]
end
# List of milestones associated with their ids.
end
# List of milestones associated with their ids.
- fun load_repo_milestones(repo: Repo): Array[Milestone] do
+ fun get_repo_milestones(repo: Repo): Array[Milestone] do
message(1, "Get milestones for {repo.full_name}")
var array = get("/repos/{repo.full_name}/milestones")
if not array isa JsonArray then return new Array[Milestone]
message(1, "Get milestones for {repo.full_name}")
var array = get("/repos/{repo.full_name}/milestones")
if not array isa JsonArray then return new Array[Milestone]
# Implementation notes: because PR numbers are not consecutive,
# PR are loaded from pages.
# See: https://developer.github.com/v3/pulls/#list-pull-requests
# Implementation notes: because PR numbers are not consecutive,
# PR are loaded from pages.
# See: https://developer.github.com/v3/pulls/#list-pull-requests
- fun load_repo_pulls(repo: Repo): Array[PullRequest] do
+ fun get_repo_pulls(repo: Repo): Array[PullRequest] do
message(1, "Get pulls for {repo.full_name}")
var key = "/repos/{repo.full_name}"
var res = new Array[PullRequest]
message(1, "Get pulls for {repo.full_name}")
var key = "/repos/{repo.full_name}"
var res = new Array[PullRequest]
end
# List of contributor related statistics.
end
# List of contributor related statistics.
- fun load_repo_contrib_stats(repo: Repo): Array[ContributorStats] do
+ fun get_repo_contrib_stats(repo: Repo): Array[ContributorStats] do
message(1, "Get contributor stats for {repo.full_name}")
var res = new Array[ContributorStats]
var array = get("/repos/{repo.full_name}/stats/contributors")
message(1, "Get contributor stats for {repo.full_name}")
var res = new Array[ContributorStats]
var array = get("/repos/{repo.full_name}/stats/contributors")
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var branch = api.load_branch(repo, "master")
+ # var branch = api.get_branch(repo, "master")
# assert branch.name == "master"
# assert branch.commit isa Commit
# ~~~
# assert branch.name == "master"
# assert branch.commit isa Commit
# ~~~
- fun load_branch(repo: Repo, name: String): nullable Branch do
+ fun get_branch(repo: Repo, name: String): nullable Branch do
return get("/repos/{repo.full_name}/branches/{name}").as(nullable Branch)
end
return get("/repos/{repo.full_name}/branches/{name}").as(nullable Branch)
end
#
# This can be long depending on the branch size.
# Commit are returned in an unspecified order.
#
# This can be long depending on the branch size.
# Commit are returned in an unspecified order.
- fun load_branch_commits(branch: Branch): Array[Commit] do
+ fun get_branch_commits(branch: Branch): Array[Commit] do
var res = new Array[Commit]
var done = new HashSet[String]
var todos = new Array[Commit]
var res = new Array[Commit]
var done = new HashSet[String]
var todos = new Array[Commit]
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var commit = api.load_commit(repo, "64ce1f")
+ # var commit = api.get_commit(repo, "64ce1f")
# assert commit isa Commit
# ~~~
# assert commit isa Commit
# ~~~
- fun load_commit(repo: Repo, sha: String): nullable Commit do
+ fun get_commit(repo: Repo, sha: String): nullable Commit do
return get("/repos/{repo.full_name}/commits/{sha}").as(nullable Commit)
end
return get("/repos/{repo.full_name}/commits/{sha}").as(nullable Commit)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var issue = api.load_issue(repo, 1)
+ # var issue = api.get_issue(repo, 1)
# assert issue.title == "Doc"
# ~~~
# assert issue.title == "Doc"
# ~~~
- fun load_issue(repo: Repo, number: Int): nullable Issue do
+ fun get_issue(repo: Repo, number: Int): nullable Issue do
return get("/repos/{repo.full_name}/issues/{number}").as(nullable Issue)
end
# List of event on this issue.
return get("/repos/{repo.full_name}/issues/{number}").as(nullable Issue)
end
# List of event on this issue.
- fun load_issue_comments(repo: Repo, issue: Issue): Array[IssueComment] do
+ fun get_issue_comments(repo: Repo, issue: Issue): Array[IssueComment] do
var res = new Array[IssueComment]
var count = issue.comments or else 0
var page = 1
var res = new Array[IssueComment]
var count = issue.comments or else 0
var page = 1
for obj in array do
if not obj isa JsonObject then continue
var id = obj["id"].as(Int)
for obj in array do
if not obj isa JsonObject then continue
var id = obj["id"].as(Int)
- var comment = load_issue_comment(repo, id)
+ var comment = get_issue_comment(repo, id)
if comment == null then continue
res.add(comment)
end
if comment == null then continue
res.add(comment)
end
end
# List of events on this issue.
end
# List of events on this issue.
- fun load_issue_events(repo: Repo, issue: Issue): Array[IssueEvent] do
+ fun get_issue_events(repo: Repo, issue: Issue): Array[IssueEvent] do
var res = new Array[IssueEvent]
var key = "/repos/{repo.full_name}/issues/{issue.number}"
var page = 1
var res = new Array[IssueEvent]
var key = "/repos/{repo.full_name}/issues/{issue.number}"
var page = 1
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var pull = api.load_pull(repo, 1)
+ # var pull = api.get_pull(repo, 1)
# assert pull.title == "Doc"
# assert pull.user.login == "Morriar"
# ~~~
# assert pull.title == "Doc"
# assert pull.user.login == "Morriar"
# ~~~
- fun load_pull(repo: Repo, number: Int): nullable PullRequest do
+ fun get_pull(repo: Repo, number: Int): nullable PullRequest do
return get("/repos/{repo.full_name}/pulls/{number}").as(nullable PullRequest)
end
return get("/repos/{repo.full_name}/pulls/{number}").as(nullable PullRequest)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var labl = api.load_label(repo, "ok_will_merge")
+ # var labl = api.get_label(repo, "ok_will_merge")
# assert labl != null
# ~~~
# assert labl != null
# ~~~
- fun load_label(repo: Repo, name: String): nullable Label do
+ fun get_label(repo: Repo, name: String): nullable Label do
return get("/repos/{repo.full_name}/labels/{name}").as(nullable Label)
end
return get("/repos/{repo.full_name}/labels/{name}").as(nullable Label)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var stone = api.load_milestone(repo, 4)
+ # var stone = api.get_milestone(repo, 4)
# assert stone.title == "v1.0prealpha"
# ~~~
# assert stone.title == "v1.0prealpha"
# ~~~
- fun load_milestone(repo: Repo, id: Int): nullable Milestone do
+ fun get_milestone(repo: Repo, id: Int): nullable Milestone do
return get("/repos/{repo.full_name}/milestones/{id}").as(nullable Milestone)
end
return get("/repos/{repo.full_name}/milestones/{id}").as(nullable Milestone)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var event = api.load_issue_event(repo, 199674194)
+ # var event = api.get_issue_event(repo, 199674194)
# assert event isa IssueEvent
# assert event.actor.login == "privat"
# assert event.event == "labeled"
# assert event.labl isa Label
# assert event.labl.name == "need_review"
# ~~~
# assert event isa IssueEvent
# assert event.actor.login == "privat"
# assert event.event == "labeled"
# assert event.labl isa Label
# assert event.labl.name == "need_review"
# ~~~
- fun load_issue_event(repo: Repo, id: Int): nullable IssueEvent do
+ fun get_issue_event(repo: Repo, id: Int): nullable IssueEvent do
return get("/repos/{repo.full_name}/issues/events/{id}").as(nullable IssueEvent)
end
return get("/repos/{repo.full_name}/issues/events/{id}").as(nullable IssueEvent)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var comment = api.load_commit_comment(repo, 8982707)
+ # var comment = api.get_commit_comment(repo, 8982707)
# assert comment.user.login == "Morriar"
# assert comment.body == "For testing purposes...\n"
# assert comment.commit_id == "7eacb86d1e24b7e72bc9ac869bf7182c0300ceca"
# ~~~
# assert comment.user.login == "Morriar"
# assert comment.body == "For testing purposes...\n"
# assert comment.commit_id == "7eacb86d1e24b7e72bc9ac869bf7182c0300ceca"
# ~~~
- fun load_commit_comment(repo: Repo, id: Int): nullable CommitComment do
+ fun get_commit_comment(repo: Repo, id: Int): nullable CommitComment do
return get("/repos/{repo.full_name}/comments/{id}").as(nullable CommitComment)
end
return get("/repos/{repo.full_name}/comments/{id}").as(nullable CommitComment)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var comment = api.load_issue_comment(repo, 6020149)
+ # var comment = api.get_issue_comment(repo, 6020149)
# assert comment.user.login == "privat"
# assert comment.created_at.to_s == "2012-05-30T20:16:54Z"
# assert comment.issue_number == 10
# ~~~
# assert comment.user.login == "privat"
# assert comment.created_at.to_s == "2012-05-30T20:16:54Z"
# assert comment.issue_number == 10
# ~~~
- fun load_issue_comment(repo: Repo, id: Int): nullable IssueComment do
+ fun get_issue_comment(repo: Repo, id: Int): nullable IssueComment do
return get("/repos/{repo.full_name}/issues/comments/{id}").as(nullable IssueComment)
end
return get("/repos/{repo.full_name}/issues/comments/{id}").as(nullable IssueComment)
end
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
#
# ~~~nitish
# var api = new GithubAPI(get_github_oauth)
- # var repo = api.load_repo("nitlang/nit")
+ # var repo = api.get_repo("nitlang/nit")
- # var comment = api.load_review_comment(repo, 21010363)
+ # var comment = api.get_review_comment(repo, 21010363)
# assert comment.path == "src/modelize/modelize_property.nit"
# assert comment.original_position == 26
# assert comment.pull_number == 945
# ~~~
# assert comment.path == "src/modelize/modelize_property.nit"
# assert comment.original_position == 26
# assert comment.pull_number == 945
# ~~~
- fun load_review_comment(repo: Repo, id: Int): nullable ReviewComment do
+ fun get_review_comment(repo: Repo, id: Int): nullable ReviewComment do
return get("/repos/{repo.full_name}/pulls/comments/{id}").as(nullable ReviewComment)
end
end
return get("/repos/{repo.full_name}/pulls/comments/{id}").as(nullable ReviewComment)
end
end
# A Github user
#
# Provides access to [Github user data](https://developer.github.com/v3/users/).
# A Github user
#
# Provides access to [Github user data](https://developer.github.com/v3/users/).
-# Should be accessed from `GithubAPI::load_user`.
+# Should be accessed from `GithubAPI::get_user`.
class User
super GitUser
serialize
class User
super GitUser
serialize
# A Github repository.
#
# Provides access to [Github repo data](https://developer.github.com/v3/repos/).
# A Github repository.
#
# Provides access to [Github repo data](https://developer.github.com/v3/repos/).
-# Should be accessed from `GithubAPI::load_repo`.
+# Should be accessed from `GithubAPI::get_repo`.
class Repo
super GithubEntity
serialize
class Repo
super GithubEntity
serialize
-# Should be accessed from `GithubAPI::load_branch`.
+# Should be accessed from `GithubAPI::get_branch`.
#
# See <https://developer.github.com/v3/repos/#list-branches>.
class Branch
#
# See <https://developer.github.com/v3/repos/#list-branches>.
class Branch
-# Should be accessed from `GithubAPI::load_commit`.
+# Should be accessed from `GithubAPI::get_commit`.
#
# See <https://developer.github.com/v3/repos/commits/>.
class Commit
#
# See <https://developer.github.com/v3/repos/commits/>.
class Commit
-# Should be accessed from `GithubAPI::load_issue`.
+# Should be accessed from `GithubAPI::get_issue`.
#
# See <https://developer.github.com/v3/issues/>.
class Issue
#
# See <https://developer.github.com/v3/issues/>.
class Issue
# A Github pull request.
#
# A Github pull request.
#
-# Should be accessed from `GithubAPI::load_pull`.
+# Should be accessed from `GithubAPI::get_pull`.
#
# PullRequest are basically Issues with more data.
# See <https://developer.github.com/v3/pulls/>.
#
# PullRequest are basically Issues with more data.
# See <https://developer.github.com/v3/pulls/>.
-# Should be accessed from `GithubAPI::load_label`.
+# Should be accessed from `GithubAPI::get_label`.
#
# See <https://developer.github.com/v3/issues/labels/>.
class Label
#
# See <https://developer.github.com/v3/issues/labels/>.
class Label
-# Should be accessed from `GithubAPI::load_milestone`.
+# Should be accessed from `GithubAPI::get_milestone`.
#
# See <https://developer.github.com/v3/issues/milestones/>.
class Milestone
#
# See <https://developer.github.com/v3/issues/milestones/>.
class Milestone
# Comments made on Github issue and pull request pages.
#
# Comments made on Github issue and pull request pages.
#
-# Should be accessed from `GithubAPI::load_issue_comment`.
+# Should be accessed from `GithubAPI::get_issue_comment`.
#
# See <https://developer.github.com/v3/issues/comments/>.
class IssueComment
#
# See <https://developer.github.com/v3/issues/comments/>.
class IssueComment
# Comments made on Github pull request diffs.
#
# Comments made on Github pull request diffs.
#
-# Should be accessed from `GithubAPI::load_diff_comment`.
+# Should be accessed from `GithubAPI::get_diff_comment`.
#
# See <https://developer.github.com/v3/pulls/comments/>.
class ReviewComment
#
# See <https://developer.github.com/v3/pulls/comments/>.
class ReviewComment
# An event that occurs on a Github `Issue`.
#
# An event that occurs on a Github `Issue`.
#
-# Should be accessed from `GithubAPI::load_issue_event`.
+# Should be accessed from `GithubAPI::get_issue_event`.
#
# See <https://developer.github.com/v3/issues/events/>.
class IssueEvent
#
# See <https://developer.github.com/v3/issues/events/>.
class IssueEvent
#
# var name = "nitlang/nit"
# assert not api.has_cache(name)
#
# var name = "nitlang/nit"
# assert not api.has_cache(name)
-# var repo = api.load_repo(name) # load from GitHub
+# var repo = api.get_repo(name) # load from GitHub
# #assert api.has_cache(name) FIXME bring back this assert
# #assert api.has_cache(name) FIXME bring back this assert
-# repo = api.load_repo(name) # load from cache
+# repo = api.get_repo(name) # load from cache
#
# api.clear_cache
# assert not api.has_cache(name)
#
# api.clear_cache
# assert not api.has_cache(name)
log.info "Resuming pending job for `{repo_full_name}`"
end
print "Load history for {job}..."
log.info "Resuming pending job for `{repo_full_name}`"
end
print "Load history for {job}..."
- load_branches(job)
- load_issues(job)
+ get_branches(job)
+ get_issues(job)
# Add a new job
fun add_job(repo_full_name: String): LoaderJob do
# Add a new job
fun add_job(repo_full_name: String): LoaderJob do
- var repo = config.wallet.api.load_repo(repo_full_name)
+ var repo = config.wallet.api.get_repo(repo_full_name)
assert repo != null else
error "Repository `{repo_full_name}` not found"
end
assert repo != null else
error "Repository `{repo_full_name}` not found"
end
jobs.remove_by_id(job.id)
end
jobs.remove_by_id(job.id)
end
- fun load_branches(job: LoaderJob) do
+ fun get_branches(job: LoaderJob) do
if config.no_branches then return
var api = config.wallet.api
var repo = job.repo
if config.no_branches then return
var api = config.wallet.api
var repo = job.repo
- for branch in api.load_repo_branches(repo) do
+ for branch in api.get_repo_branches(repo) do
branch.repo = repo
branches.save branch
branch.repo = repo
branches.save branch
- load_commits(job, branch)
+ get_commits(job, branch)
- fun load_commits(job: LoaderJob, branch: Branch) do
+ fun get_commits(job: LoaderJob, branch: Branch) do
if config.no_commits then return
if config.no_commits then return
- load_commit(job, branch.commit.sha)
+ get_commit(job, branch.commit.sha)
- fun load_commit(job: LoaderJob, commit_sha: String) do
+ fun get_commit(job: LoaderJob, commit_sha: String) do
if commits.find_by_id(commit_sha) != null then return
var api = config.wallet.api
if commits.find_by_id(commit_sha) != null then return
var api = config.wallet.api
- var commit = api.load_commit(job.repo, commit_sha)
+ var commit = api.get_commit(job.repo, commit_sha)
# print commit or else "NULL"
if commit == null then return
var message = commit.message or else "no message"
# print commit or else "NULL"
if commit == null then return
var message = commit.message or else "no message"
var parents = commit.parents
if parents == null then return
for parent in parents do
var parents = commit.parents
if parents == null then return
for parent in parents do
- load_commit(job, parent.sha)
+ get_commit(job, parent.sha)
end
end
# Load game for `repo_name`.
end
end
# Load game for `repo_name`.
- fun load_issues(job: LoaderJob) do
+ fun get_issues(job: LoaderJob) do
if config.no_issues then return
var i = job.last_issue
if config.no_issues then return
var i = job.last_issue
- var last_issue = load_last_issue(job)
+ var last_issue = get_last_issue(job)
if last_issue != null then
while i <= last_issue.number do
if last_issue != null then
while i <= last_issue.number do
job.last_issue = i
jobs.save job
i += 1
job.last_issue = i
jobs.save job
i += 1
end
# Load the `repo` last issue or abort.
end
# Load the `repo` last issue or abort.
- private fun load_last_issue(job: LoaderJob): nullable Issue do
+ private fun get_last_issue(job: LoaderJob): nullable Issue do
var api = config.wallet.api
var api = config.wallet.api
- return api.load_repo_last_issue(job.repo)
+ return api.get_repo_last_issue(job.repo)
end
# Load an issue or abort.
end
# Load an issue or abort.
- private fun load_issue(job: LoaderJob, issue_number: Int) do
+ private fun get_issue(job: LoaderJob, issue_number: Int) do
if issues.find_by_id("{job.repo.mongo_id}/{issue_number}") != null then return
var api = config.wallet.api
if issues.find_by_id("{job.repo.mongo_id}/{issue_number}") != null then return
var api = config.wallet.api
- var issue = api.load_issue(job.repo, issue_number)
+ var issue = api.get_issue(job.repo, issue_number)
assert issue != null else
check_error(api, "Issue #{issue_number} not found")
end
if issue.is_pull_request then
assert issue != null else
check_error(api, "Issue #{issue_number} not found")
end
if issue.is_pull_request then
else
log.info "Load issue #{issue.number}: {issue.title.split("\n").first}"
issue.repo = job.repo
issues.save issue
else
log.info "Load issue #{issue.number}: {issue.title.split("\n").first}"
issue.repo = job.repo
issues.save issue
- load_issue_events(job, issue)
+ get_issue_events(job, issue)
- load_issue_comments(job, issue)
+ get_issue_comments(job, issue)
end
# Load issue comments.
end
# Load issue comments.
- private fun load_issue_comments(job: LoaderJob, issue: Issue) do
+ private fun get_issue_comments(job: LoaderJob, issue: Issue) do
if config.no_comments then return
var api = config.wallet.api
if config.no_comments then return
var api = config.wallet.api
- for comment in api.load_issue_comments(job.repo, issue) do
+ for comment in api.get_issue_comments(job.repo, issue) do
comment.repo = job.repo
issue_comments.save comment
end
end
# Load issue events.
comment.repo = job.repo
issue_comments.save comment
end
end
# Load issue events.
- private fun load_issue_events(job: LoaderJob, issue: Issue) do
+ private fun get_issue_events(job: LoaderJob, issue: Issue) do
if config.no_events then return
var api = config.wallet.api
if config.no_events then return
var api = config.wallet.api
- for event in api.load_issue_events(job.repo, issue) do
+ for event in api.get_issue_events(job.repo, issue) do
event.repo = job.repo
issue_events.save event
end
end
# Load a pull request or abort.
event.repo = job.repo
issue_events.save event
end
end
# Load a pull request or abort.
- private fun load_pull(job: LoaderJob, issue: Issue): PullRequest do
+ private fun get_pull(job: LoaderJob, issue: Issue): PullRequest do
var api = config.wallet.api
var api = config.wallet.api
- var pr = api.load_pull(job.repo, issue.number)
+ var pr = api.get_pull(job.repo, issue.number)
assert pr != null else
check_error(api, "Pull request #{issue.number} not found")
end
log.info "Load pull request #{issue.number}: {pr.title.split("\n").first}"
pr.repo = job.repo
pulls.save pr
assert pr != null else
check_error(api, "Pull request #{issue.number} not found")
end
log.info "Load pull request #{issue.number}: {pr.title.split("\n").first}"
pr.repo = job.repo
pulls.save pr
- load_pull_events(job, pr)
+ get_pull_events(job, pr)
return pr
end
# Load pull events.
return pr
end
# Load pull events.
- private fun load_pull_events(job: LoaderJob, pull: PullRequest) do
+ private fun get_pull_events(job: LoaderJob, pull: PullRequest) do
if config.no_events then return
var api = config.wallet.api
if config.no_events then return
var api = config.wallet.api
- for event in api.load_issue_events(job.repo, pull) do
+ for event in api.get_issue_events(job.repo, pull) do
event.repo = job.repo
issue_events.save event
end
event.repo = job.repo
issue_events.save event
end
else
loader.start args.first
else
loader.start args.first
- var repo = loader.config.wallet.api.load_repo(args.first)
+ var repo = loader.config.wallet.api.get_repo(args.first)
if repo == null then return
print "Loaded"
print "* {if loader.repos.find_by_id(args.first) != null then 1 else 0} repos"
if repo == null then return
print "Loaded"
print "* {if loader.repos.find_by_id(args.first) != null then 1 else 0} repos"
# TODO test more error cases
fun test_get_auth_user is test do
# TODO test more error cases
fun test_get_auth_user is test do
- var user = api.load_auth_user
+ var user = api.get_auth_user
assert user isa User
assert user.login == "Morriar"
assert user.avatar_url == "https://avatars2.githubusercontent.com/u/583144?v=4"
assert user isa User
assert user.login == "Morriar"
assert user.avatar_url == "https://avatars2.githubusercontent.com/u/583144?v=4"
end
fun test_get_user is test do
end
fun test_get_user is test do
- var user = api.load_user("Morriar")
+ var user = api.get_user("Morriar")
assert user isa User
assert user.login == "Morriar"
assert user.avatar_url == "https://avatars2.githubusercontent.com/u/583144?v=4"
assert user isa User
assert user.login == "Morriar"
assert user.avatar_url == "https://avatars2.githubusercontent.com/u/583144?v=4"
end
fun test_get_repo is test do
end
fun test_get_repo is test do
- var repo = api.load_repo("nitlang/nit")
+ var repo = api.get_repo("nitlang/nit")
assert repo isa Repo
assert repo.full_name == "nitlang/nit"
assert repo.name == "nit"
assert repo isa Repo
assert repo.full_name == "nitlang/nit"
assert repo.name == "nit"
assert repo.default_branch == "master"
end
assert repo.default_branch == "master"
end
- private var repo: Repo is lazy do return api.load_repo("nitlang/nit").as(not null)
+ private var repo: Repo is lazy do return api.get_repo("nitlang/nit").as(not null)
fun test_get_branches is test do
fun test_get_branches is test do
- var branches = api.load_repo_branches(repo)
+ var branches = api.get_repo_branches(repo)
assert branches.length == 2
assert branches.first.name == "master"
assert branches.last.name == "next"
assert branches.length == 2
assert branches.first.name == "master"
assert branches.last.name == "next"
# TODO contrib_stats
fun test_get_branch is test do
# TODO contrib_stats
fun test_get_branch is test do
- var branch = api.load_branch(repo, "master")
+ var branch = api.get_branch(repo, "master")
assert branch isa Branch
assert branch.name == "master"
end
assert branch isa Branch
assert branch.name == "master"
end
# TODO branch commits
fun test_get_commit is test do
# TODO branch commits
fun test_get_commit is test do
- var commit = api.load_commit(repo, "64ce1f")
+ var commit = api.get_commit(repo, "64ce1f")
assert commit isa Commit
assert commit.sha == "64ce1f587209024f5de46d06c70526a569ff537f"
# TODO other fields
end
fun test_get_issue is test do
assert commit isa Commit
assert commit.sha == "64ce1f587209024f5de46d06c70526a569ff537f"
# TODO other fields
end
fun test_get_issue is test do
- var issue = api.load_issue(repo, 1000)
+ var issue = api.get_issue(repo, 1000)
assert issue isa Issue
assert issue.number == 1000
assert issue.title == "Raise nitc from the dead"
assert issue isa Issue
assert issue.number == 1000
assert issue.title == "Raise nitc from the dead"
# TODO issue events
fun test_get_pull is test do
# TODO issue events
fun test_get_pull is test do
- var pull = api.load_pull(repo, 1000)
+ var pull = api.get_pull(repo, 1000)
assert pull isa Issue
assert pull.number == 1000
assert pull.title == "Raise nitc from the dead"
assert pull isa Issue
assert pull.number == 1000
assert pull.title == "Raise nitc from the dead"
end
fun test_get_label is test do
end
fun test_get_label is test do
- var labl = api.load_label(repo, "ok_will_merge")
+ var labl = api.get_label(repo, "ok_will_merge")
assert labl isa Label
assert labl.name == "ok_will_merge"
end
fun test_get_milestone is test do
assert labl isa Label
assert labl.name == "ok_will_merge"
end
fun test_get_milestone is test do
- var milestone = api.load_milestone(repo, 4)
+ var milestone = api.get_milestone(repo, 4)
assert milestone isa Milestone
assert milestone.title == "v1.0prealpha"
# TODO other fields
end
fun test_get_issue_event is test do
assert milestone isa Milestone
assert milestone.title == "v1.0prealpha"
# TODO other fields
end
fun test_get_issue_event is test do
- var event = api.load_issue_event(repo, 199674194)
+ var event = api.get_issue_event(repo, 199674194)
assert event isa IssueEvent
assert event.actor.login == "privat"
assert event.event == "labeled"
assert event isa IssueEvent
assert event.actor.login == "privat"
assert event.event == "labeled"
end
fun test_get_issue_comment is test do
end
fun test_get_issue_comment is test do
- var comment = api.load_issue_comment(repo, 6020149)
+ var comment = api.get_issue_comment(repo, 6020149)
assert comment isa IssueComment
assert comment.user.login == "privat"
assert comment.created_at.to_s == "2012-05-30T20:16:54Z"
assert comment isa IssueComment
assert comment.user.login == "privat"
assert comment.created_at.to_s == "2012-05-30T20:16:54Z"
end
fun test_get_comment is test do
end
fun test_get_comment is test do
- var comment = api.load_commit_comment(repo, 8982707)
+ var comment = api.get_commit_comment(repo, 8982707)
assert comment isa CommitComment
assert comment.user.login == "Morriar"
assert comment.body == "For testing purposes...\n"
assert comment isa CommitComment
assert comment.user.login == "Morriar"
assert comment.body == "For testing purposes...\n"
end
fun test_get_review_comments is test do
end
fun test_get_review_comments is test do
- var comment = api.load_review_comment(repo, 21010363)
+ var comment = api.get_review_comment(repo, 21010363)
assert comment isa ReviewComment
assert comment.path == "src/modelize/modelize_property.nit"
assert comment.original_position == 26
assert comment isa ReviewComment
assert comment.path == "src/modelize/modelize_property.nit"
assert comment.original_position == 26
fun check_token(token: String): Bool do
message "Try token {token}"
var api = new GithubAPI(token)
fun check_token(token: String): Bool do
message "Try token {token}"
var api = new GithubAPI(token)
- api.load_repo("nitlang/nit")
+ api.get_repo("nitlang/nit")
return not api.was_error
end
return not api.was_error
end
# Load github user
var gh_api = new GithubAPI(access_token)
# Load github user
var gh_api = new GithubAPI(access_token)
- var user = gh_api.load_auth_user
+ var user = gh_api.get_auth_user
if user == null then
res.error 401
return
if user == null then
res.error 401
return