From 30fc01ae008bfc146ffd35b9f0f50aa5460953a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Fern=C3=A1ndez?= Date: Mon, 25 Jan 2016 19:41:21 +0100 Subject: [PATCH 1/3] Improved error message when user lacks admin rights. --- lib/api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 6a99f68..694e1d9 100644 --- a/lib/api.js +++ b/lib/api.js @@ -50,8 +50,14 @@ function createHooks(reponame, url, secret, token, callback) { .end(function (err, res) { if (err) return callback(err); + var badStatusErr; + if (res.statusCode === 404) { + badStatusErr = new Error('Cannot create webhooks; are you sure you have admin rights?'); + badStatusErr.statusCode = res.statusCode; + return callback(badStatusErr); + } if (res.statusCode !== 201) { - var badStatusErr = new Error('Bad status code: ' + res.statusCode); + badStatusErr = new Error('Bad status code: ' + res.statusCode); badStatusErr.statusCode = res.statusCode; return callback(badStatusErr); } From 1006573412ddc36cedb7982ebec4652d2b79ff93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Fern=C3=A1ndez?= Date: Mon, 25 Jan 2016 19:42:49 +0100 Subject: [PATCH 2/3] Document when user has no admin rights. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f1aa5a5..d9745a5 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,5 @@ of the following are set. On GitHub Enterprise, log in to the profile you are tr - Make sure your github profile has a public email set * Go to https://github.com/settings/profile and select an email under "Public email". +- Make sure you have admin rights on the projects before adding them, +since strider will need to create webhooks for the integration to work. From a93098fb83ab1042f0efea2a250e14111140ba26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Fern=C3=A1ndez?= Date: Mon, 25 Jan 2016 21:47:12 +0100 Subject: [PATCH 3/3] Added else. --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 694e1d9..03a1843 100644 --- a/lib/api.js +++ b/lib/api.js @@ -56,7 +56,7 @@ function createHooks(reponame, url, secret, token, callback) { badStatusErr.statusCode = res.statusCode; return callback(badStatusErr); } - if (res.statusCode !== 201) { + else if (res.statusCode !== 201) { badStatusErr = new Error('Bad status code: ' + res.statusCode); badStatusErr.statusCode = res.statusCode; return callback(badStatusErr);