Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 143
Testing webhooks and node core labels#60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
812b29671dacdd4b6f2b373c6a997042745e2bf71bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const crypto = require('crypto') | ||
| const secret = process.env.GITHUB_WEBHOOK_SECRET || 'hush-hush' | ||
| function sign (data) { | ||
| const buffer = new Buffer(data, 'utf8') | ||
| return 'sha1=' + crypto.createHmac('sha1', secret).update(buffer).digest('hex') | ||
| } | ||
| exports.isValid = function isValid (req) { | ||
| const signature = req.headers['x-hub-signature'] | ||
| return signature && signature === sign(req.raw) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,41 +25,17 @@ function updatePrWithLabels (options, labels) { | ||
| return | ||
| } | ||
| fetchExistingLabels(options, (err, existingLabels) => { | ||
| if (err) { | ||
| return | ||
| } | ||
| const mergedLabels = labels.concat(existingLabels) | ||
| githubClient.issues.edit({ | ||
| user: options.owner, | ||
| repo: options.repo, | ||
| number: options.prId, | ||
| labels: mergedLabels | ||
| }, (err) => { | ||
| if (err) { | ||
| return options.logger.error(err, 'Error while editing issue to add labels') | ||
| } | ||
| options.logger.info(`Added labels: ${labels}`) | ||
| }) | ||
| }) | ||
| } | ||
| function fetchExistingLabels (options, cb) { | ||
| githubClient.issues.getIssueLabels({ | ||
| githubClient.issues.addLabels({ | ||
This comment was marked as off-topic.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| user: options.owner, | ||
| repo: options.repo, | ||
| number: options.prId | ||
| }, (err, res) => { | ||
| number: options.prId, | ||
| body: labels | ||
| }, (err) => { | ||
| if (err) { | ||
| options.logger.error(err, 'Error while fetching existing issue labels') | ||
| return cb(err) | ||
| return options.logger.error(err, 'Error while editing issue to add labels') | ||
| } | ||
| const existingLabels = res.map((labelMeta) => labelMeta.name) | ||
| cb(null, existingLabels) | ||
| options.logger.info(`Added labels: ${labels}`) | ||
| }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -94,7 +94,7 @@ function pollTravisBuildBySha (options, checkNumber = 1) { | ||
| function createGhStatusFn (options) { | ||
| return (state, travisId, message) => { | ||
| githubClient.statuses.create({ | ||
| githubClient.repos.createStatus({ | ||
This comment was marked as off-topic.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| user: options.owner, | ||
| repo: options.repo, | ||
| sha: options.lastCommit.sha, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| { | ||
| "sha": "aae34fdac0caea4e4aa204aeade6a12befe32e73", | ||
| "filename": "lib/timers.js", | ||
| "status": "changed", | ||
| "additions": 103, | ||
| "deletions": 21, | ||
| "changes": 124, | ||
| "blob_url": "https://github.com/nodejs/node/blob/aae34fdac0caea4e4aa204aeade6a12befe32e73/lib/timers.js", | ||
| "raw_url": "https://github.com/nodejs/node/raw/aae34fdac0caea4e4aa204aeade6a12befe32e73/lib/timers.js", | ||
| "contents_url": "https://api.github.com/repos/nodejs/node/contents/lib/timers.js?ref=aae34fdac0caea4e4aa204aeade6a12befe32e73", | ||
| "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test" | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [ | ||
| { | ||
| "url": "https://github.com/nodejs/node/labels/enhancement", | ||
| "name": "enhancement", | ||
| "color": "f29513" | ||
| } | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.