Skip to content

Commit

Permalink
Move the review attributes for the review DSL into the root of the gi…
Browse files Browse the repository at this point in the history
…thub DSL
  • Loading branch information
orta committed Mar 12, 2017
1 parent 9088ca6 commit 123cb9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
19 changes: 5 additions & 14 deletions source/dsl/GitHubDSL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export interface GitHubDSL {
pr: GitHubPRDSL,
/** The github commit metadata for a code review session */
commits: Array<GitHubCommit>
/** The reviews left on this pull request */
reviews: Array<GitHubReview>
/** The people requested to review this PR */
requestedReviewers: Array<GitHubUser>
}

/**
Expand Down Expand Up @@ -149,19 +153,6 @@ export interface GitHubPRDSL {
*/
assignees: Array<GitHubUser>

/**
* The people requested to review this PR
* @type {GitHubReview}
*/
requestedReviewers: Array<GitHubUser>

/**
* The reviews left on this pull request
* @type {Array<GitHubReview>}
* @memberOf GitHubPRDSL
*/
reviews: Array<GitHubReview>

/**
* Has the PR been merged yet
* @type {boolean}
Expand Down Expand Up @@ -305,7 +296,7 @@ export interface GitHubRepo {

export interface GitHubMergeRef {
/**
* The human display name for the merge reference, e.g. "artsy:master"
* The human di 0 . 0splay name for the merge reference, e.g. "artsy:master"
* @type {string}
*/
label: string
Expand Down
14 changes: 7 additions & 7 deletions source/platforms/GitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ export class GitHub {
*/
async getReviewInfo(): Promise<GitHubPRDSL> {
const deets = await this.api.getPullRequestInfo()

return {
...await deets.json(),
reviews: await this.api.getReviews(),
requestedReviewers: await this.api.getReviewerRequests(),
}
return await deets.json()
}

/**
Expand Down Expand Up @@ -93,10 +88,15 @@ export class GitHub {
const issue = await this.getIssue()
const pr = await this.getReviewInfo()
const commits = await this.api.getPullRequestCommits()
const reviews = await this.api.getReviews()
const requestedReviewers = await this.api.getReviewerRequests()

return {
issue,
pr,
commits
commits,
reviews,
requestedReviewers
}
}

Expand Down
8 changes: 4 additions & 4 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class GitHubAPI {
return {}
}

private api(path: string, headers: any = {}, body: any = {}, method: string): Promise<any> {
private api(path: string, headers: any = {}, body: any = {}, method: string) {
if (this.token !== undefined) {
headers["Authorization"] = `token ${this.token}`
}
Expand All @@ -175,15 +175,15 @@ export class GitHubAPI {
})
}

get(path: string, headers: any = {}, body: any = {}): Promise<any> {
get(path: string, headers: any = {}, body: any = {}) {
return this.api(path, headers, body, "GET")
}

post(path: string, headers: any = {}, body: any = {}): Promise<any> {
post(path: string, headers: any = {}, body: any = {}) {
return this.api(path, headers, JSON.stringify(body), "POST")
}

patch(path: string, headers: any = {}, body: any = {}): Promise<any> {
patch(path: string, headers: any = {}, body: any = {}) {
return this.api(path, headers, JSON.stringify(body), "PATCH")
}
}

0 comments on commit 123cb9d

Please sign in to comment.