From 7aebe78f238f9d6a8386781fa4bd978ee018280f Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Wed, 9 Mar 2016 10:49:39 +0800 Subject: [PATCH 01/20] fix eslint not fail issue --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index eb9166d..e313f46 100644 --- a/index.js +++ b/index.js @@ -209,7 +209,7 @@ module.exports = function (options) { } }; - if ((jshint_output.length === 1) && (jscs_output.length === 1)) { + if ((jshint_output.length === 1) && (jscs_output.length === 1) && (eslint_output.length === 1)) { return cb(); } From bc89bb0a46e82f57fcc4af96e36a40857bb1f27d Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Wed, 9 Mar 2016 10:49:51 +0800 Subject: [PATCH 02/20] release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e39e0cb..1dc84b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-github", - "version": "0.3.1", + "version": "0.3.2", "description": "A gulp plugin to pipe contents to github pull request comments.", "author": "Zordius ", "contributors": [ From 87f90e761f58285a834f28cc0afe6726c1af8f80 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Wed, 9 Mar 2016 12:12:05 +0800 Subject: [PATCH 03/20] fix 'eslint issues not be commented into github PR' bug --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index e313f46..7ed65cd 100644 --- a/index.js +++ b/index.js @@ -223,6 +223,10 @@ module.exports = function (options) { commentToPR(jscs_output.join('\n'), opt); gutil.log('[gulp-github]', gutil.colors.bold((jscs_output.length - 1) + ' jscs issues were updated to ' + pr_url)); } + if (eslint_output.length > 1) { + commentToPR(eslint_output.join('\n'), opt); + gutil.log('[gulp-github]', gutil.colors.bold((eslint_output.length - 1) + ' eslint issues were updated to ' + pr_url)); + } } else { console.log('Not a pullrequest or no opts.git_token/opts.git_repo/opts.git_prid'); if (jshint_output.length > 1) { From 34c0ba05fd20f6c85e7758718baef6945bcbb9bd Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Wed, 9 Mar 2016 12:12:19 +0800 Subject: [PATCH 04/20] release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dc84b8..49fccef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-github", - "version": "0.3.2", + "version": "0.3.3", "description": "A gulp plugin to pipe contents to github pull request comments.", "author": "Zordius ", "contributors": [ From c4ac3d03133315d81d0cd1ef182a558ae1147628 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 18 Mar 2016 17:05:50 +0800 Subject: [PATCH 05/20] now failMergedPR() can fail the task. Add document for failMergedPR() --- README.md | 5 +++++ index.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3908bd..8d9ca95 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ github.createStatusToCommit({ context: 'my gulp task', state: 'failure' }, options); + +// Or, create a task to reject PR with merged commits +gulp.task('git_rules', function (cb) { + git.failMergedPR(options, cb); +}); ``` Options diff --git a/index.js b/index.js index 7ed65cd..9cc3422 100644 --- a/index.js +++ b/index.js @@ -64,7 +64,7 @@ var isPullRequest = function (opt) { var isMerge = function (opt, callback) { if (!isPullRequest(opt)) { - return; + return callback(); } getGIT(opt).pullRequests.getCommits({ @@ -110,6 +110,8 @@ var failMergedPR = function (opt, cb) { return; } + err.push(M); + commentToPR('**Do not accept PR with merge, please use rebase always!**\n' + M, opt, done); createStatusToCommit({ From 86b6c555885131ce2472964d61ac9f483009cac2 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 18 Mar 2016 17:06:05 +0800 Subject: [PATCH 06/20] release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49fccef..015ef3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-github", - "version": "0.3.3", + "version": "0.3.4", "description": "A gulp plugin to pipe contents to github pull request comments.", "author": "Zordius ", "contributors": [ From 23d40b2e6b37420fedea6bffb04b60efc4cf0c0c Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 18 Mar 2016 17:07:34 +0800 Subject: [PATCH 07/20] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d9ca95..5c39a25 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ var gulp = require('gulp'), eslint = require('gulp-eslint'), github = require('gulp-github'); -gulp.task('link_report_github', function () { +gulp.task('lint_report_github', function () { return gulp.src('lib/*.js') .pipe(jshint()) .pipe(jscs()).on('error', function (E) { From 199f5d17301a9d27e78ea534bbb46061885f78bb Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 29 Apr 2016 09:49:54 +0800 Subject: [PATCH 08/20] document improvement for #5 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c39a25..954a38f 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,10 @@ Options // when using github enterprise, optional git_option: { - // refer to https://www.npmjs.com/package/github - host: 'github.mycorp.com' + // refer to https://www.npmjs.com/package/github for more options + host: 'github.mycorp.com', + // You may require this when you using Enterprise Github + pathPrefix: '/api/v3' }, // Provide your own jshint reporter, optional From e625c3f535402c3b094f8c347d9c90848f5bac00 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:26:03 +0800 Subject: [PATCH 09/20] update gulpfile --- gulpfile.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 6ebf5ee..2636ee1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,7 @@ var gulp = require('gulp'), github = require('./index'); gulp.task('default', function () { - return gulp.src('*.js') + return gulp.src(['*.js', 'lint_test/*.js']) .pipe(eslint()) .pipe(jshint()) .pipe(jscs()) @@ -21,8 +21,9 @@ gulp.task('default', function () { git_prid: process.env.TRAVIS_PULL_REQUEST, git_sha: process.env.TRAVIS_COMMIT, - jshint_status: 'error', // Set status to error when jshint errors - jscs_status: 'failure' // Set status to failure when jscs errors + jshint_status: 'error', // Set status to error when jshint errors + jscs_status: 'failure', // Set status to failure when jscs errors + eslint_status: 'failure' // Set status to failure when eslint errors })) .pipe(github.failThisTask()); }); From d657c7156f9cf7e24ad1e30a00019f445f7a2bcd Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:26:43 +0800 Subject: [PATCH 10/20] update dependency --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 015ef3a..40a5ef7 100644 --- a/package.json +++ b/package.json @@ -27,14 +27,14 @@ "main": "index.js", "dependencies": { "github": "0.2.4", - "gulp-util": "3.0.6", + "gulp-util": "3.0.7", "through2": "*" }, "devDependencies": { - "gulp": "3.9.0", - "gulp-jshint": "1.11.2", - "gulp-jscs": "2.0.0", - "gulp-eslint": "1.0.0" + "gulp": "3.9.1", + "gulp-jshint": "2.0.0", + "gulp-jscs": "3.0.2", + "gulp-eslint": "2.0.0" }, "engines": { "node": ">=0.8" From de11a32de6778ef840b7b251bfed22fc587a7b7e Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:28:33 +0800 Subject: [PATCH 11/20] support createPR --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 9cc3422..d3230e3 100644 --- a/index.js +++ b/index.js @@ -38,6 +38,17 @@ var closePR = function (opt, cb) { }, cb); }; +var createPR = function (title, head, base, body, opt, cb) { + getGIT(opt).pullRequests.create({ + user: opt.git_repo.split('/')[0], + repo: opt.git_repo.split('/')[1], + title: title, + head: head, + base: base, + body: body + }, cb); +}; + var commentToPR = function (body, opt, cb) { getGIT(opt).issues.createComment({ user: opt.git_repo.split('/')[0], @@ -291,6 +302,7 @@ module.exports = function (options) { }; module.exports.commentToPR = commentToPR; +module.exports.createPR = createPR; module.exports.createStatusToCommit = createStatusToCommit; module.exports.failThisTask = failThisTask; module.exports.failMergedPR = failMergedPR; From 28209b9561f31ec1ffb782b83ddc9513797fa9e2 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:37:55 +0800 Subject: [PATCH 12/20] fix for newer jscs --- index.js | 2 +- lint_test/test1.js | 7 +++++++ package.json | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 lint_test/test1.js diff --git a/index.js b/index.js index d3230e3..3a483e4 100644 --- a/index.js +++ b/index.js @@ -199,7 +199,7 @@ module.exports = function (options) { } if (file.jscs && !file.jscs.success) { - file.jscs.errors.forEach(function (E) { + (file.jscs.errors.getErrorList ? file.jscs.errors.getErrorList() : file.jscs.errors).forEach(function (E) { jscs_output.push(jscs_reporter(E, file)); }); } diff --git a/lint_test/test1.js b/lint_test/test1.js new file mode 100644 index 0000000..c09af3e --- /dev/null +++ b/lint_test/test1.js @@ -0,0 +1,7 @@ +var bad = {}; +var foo = 123; + +if (123) { + foo ++; + foo--; +} diff --git a/package.json b/package.json index 40a5ef7..3764e61 100644 --- a/package.json +++ b/package.json @@ -26,15 +26,15 @@ }, "main": "index.js", "dependencies": { - "github": "0.2.4", + "github": "2.2.0", "gulp-util": "3.0.7", "through2": "*" }, "devDependencies": { "gulp": "3.9.1", - "gulp-jshint": "2.0.0", - "gulp-jscs": "3.0.2", - "gulp-eslint": "2.0.0" + "gulp-jshint": "2.0.1", + "gulp-jscs": "4.0.0", + "gulp-eslint": "3.0.1" }, "engines": { "node": ">=0.8" From 588e22f168166a3b02f04d268bdd499e9cc2c4b8 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:43:36 +0800 Subject: [PATCH 13/20] test on 4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4fc06d2..de1246f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - '0.11' + - '4' script: - npm test sudo: false From 23f93572ef9415122b8bbbfc805b174ab438df77 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 16:54:39 +0800 Subject: [PATCH 14/20] update to new github api interface --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3a483e4..1c7820d 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,7 @@ var commentToPR = function (body, opt, cb) { }; var createStatusToCommit = function (state, opt, cb) { - getGIT(opt).statuses.create({ + getGIT(opt).repos.createStatus({ user: opt.git_repo.split('/')[0], repo: opt.git_repo.split('/')[1], sha: opt.git_sha, From a679eaf46bc6d97748858c493696677f466e0e85 Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 17:02:10 +0800 Subject: [PATCH 15/20] remove failed file --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 2636ee1..157f504 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,7 +5,7 @@ var gulp = require('gulp'), github = require('./index'); gulp.task('default', function () { - return gulp.src(['*.js', 'lint_test/*.js']) + return gulp.src(['*.js']) // , 'lint_test/*.js']) .pipe(eslint()) .pipe(jshint()) .pipe(jscs()) From 22c8c07dd90c48c8b98d6fcc111f492d039fc80f Mon Sep 17 00:00:00 2001 From: Zordius Chen Date: Fri, 15 Jul 2016 17:05:10 +0800 Subject: [PATCH 16/20] release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3764e61..e7dad8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-github", - "version": "0.3.4", + "version": "0.3.5", "description": "A gulp plugin to pipe contents to github pull request comments.", "author": "Zordius ", "contributors": [ From 2986633b6d632a82b4686210441a96e0ba9acffe Mon Sep 17 00:00:00 2001 From: Fabio Elia Date: Mon, 12 Dec 2016 10:39:50 -0500 Subject: [PATCH 17/20] Add eslint reporter --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1c7820d..356d58c 100644 --- a/index.js +++ b/index.js @@ -189,7 +189,9 @@ module.exports = function (options) { eslint_output = ['**Please fix these eslint issues first:**'], opt = options || {}, jshint_reporter = opt.jshint_reporter || jshint_simple_reporter, - jscs_reporter = opt.jscs_reporter || jscs_simple_reporter; + jscs_reporter = opt.jscs_reporter || jscs_simple_reporter, + eslint_reporter = opt.eslint_reporter || eslint_simple_reporter; + return through.obj(function (file, enc, callback) { if (file.jshint && !file.jshint.success && !file.jshint.ignored) { @@ -206,7 +208,7 @@ module.exports = function (options) { if (file.eslint) { file.eslint.messages.forEach(function (E) { - eslint_output.push(eslint_simple_reporter(E, file)); + eslint_output.push(eslint_reporter(E, file)); }); } From 33e1550e71b871d95195d4b6dc4fa868fe09c795 Mon Sep 17 00:00:00 2001 From: "Mike P. Sinn" Date: Mon, 10 Dec 2018 18:13:05 -0600 Subject: [PATCH 18/20] Allow for target_url on statuses --- .gitignore | 1 + index.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3cdc0ad..e5f98f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules coverage artifacts +.idea/ diff --git a/index.js b/index.js index 356d58c..e8124e1 100644 --- a/index.js +++ b/index.js @@ -59,14 +59,16 @@ var commentToPR = function (body, opt, cb) { }; var createStatusToCommit = function (state, opt, cb) { - getGIT(opt).repos.createStatus({ + var statusOptions = { user: opt.git_repo.split('/')[0], repo: opt.git_repo.split('/')[1], sha: opt.git_sha, state: state.state, description: state.description, context: state.context - }, cb); + }; + if(state.target_url){statusOptions.target_url = state.target_url;} + getGIT(opt).repos.createStatus(statusOptions, cb); }; var isPullRequest = function (opt) { From 5d5ec40d17056e0ab86209197ba3e2b79ee2e9d3 Mon Sep 17 00:00:00 2001 From: "Mike P. Sinn" Date: Mon, 10 Dec 2018 18:17:36 -0600 Subject: [PATCH 19/20] Added target_url to README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 954a38f..c940fb9 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ gulp.task('lint_report_github', function () { console.log(E.message); // This handled jscs stream error. }) .pipe(eslint()) - .pipe(github(options)); // Comment issues in github PR! + .pipe(github(options)) // Comment issues in github PR! .pipe(github.failThisTask()); // Fail this task when jscs/jshint/eslint issues found. }); @@ -54,7 +54,8 @@ github.commentToPR('Yes! it works!!', options); github.createStatusToCommit({ description: 'No! 2 failures...', context: 'my gulp task', - state: 'failure' + state: 'failure', + target_url: 'http://www.homerswebpage.com/' }, options); // Or, create a task to reject PR with merged commits From c001aa1cc4bfe83f9a387ef65d941afddd1c1544 Mon Sep 17 00:00:00 2001 From: Zordius Chen <1201409+zordius@users.noreply.github.com> Date: Thu, 13 Dec 2018 10:02:15 +0800 Subject: [PATCH 20/20] release --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7dad8e..686354d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "gulp-github", - "version": "0.3.5", + "version": "0.3.6", "description": "A gulp plugin to pipe contents to github pull request comments.", - "author": "Zordius ", + "author": "Zordius ", "contributors": [ { "name": "Zordius Chen",