Skip to content

Commit

Permalink
callGitHubAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
loddit committed Aug 16, 2015
1 parent 67d51c9 commit 1126e61
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions legilimens.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
request = require('request')

GITHUB_API_ROOT = "https://api.github.com/repos/"
GITHUB_REPO_API_ROOT = "https://api.github.com/repos/"
LATEST_RELEASE_PATH = "/releases/latest"
RECENT_CLOSED_PR_PATH = "/pulls?state=closed&sort=updated&direction=desc"

Expand All @@ -9,17 +9,20 @@ password = 'password'
repoOwner = 'repo/owner'
repoName = 'reponame'

repoUrl = "#{GITHUB_API_ROOT}#{repoOwner}/#{repoName}"
repoUrl = "#{GITHUB_REPO_API_ROOT}#{repoOwner}/#{repoName}"

getClosedPullRequestsAfter = (time) ->
callGithubAPI = (url, callback = (error, response, body) -> {}) ->
request
url: repoUrl + RECENT_CLOSED_PR_PATH
url: url
headers:
'User-Agent': 'request'
auth:
user: username
password: password
, (error, response, body) ->
, callback

getClosedPullRequestsAfter = (time) ->
callGithubAPI (repoUrl + RECENT_CLOSED_PR_PATH), (error, response, body) ->
if (!error and response.statusCode isnt 200)
console.log error, body
else
Expand All @@ -28,14 +31,7 @@ getClosedPullRequestsAfter = (time) ->
printPullRequestsReport(pullRequests)

getLastedReleaseTime = (callback) ->
request
url: repoUrl + LATEST_RELEASE_PATH
headers:
'User-Agent': 'request'
auth:
user: username
password: password
, (error, response, body) ->
callGithubAPI (repoUrl + LATEST_RELEASE_PATH), (error, response, body) ->
if (!error and response.statusCode isnt 200)
console.log error, body
else
Expand All @@ -50,5 +46,3 @@ printPullRequestsReport = (pullRequests) ->
index++

getLastedReleaseTime(getClosedPullRequestsAfter)


0 comments on commit 1126e61

Please sign in to comment.