[Pkg-javascript-commits] [node-coveralls] 210/332: Pass CI_PULL_REQUEST through to coveralls if it is set

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:54:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 4344c189726451016e86627a0c11620ce420cdaf
Author: Ethan Langevin <ejl6266 at gmail.com>
Date:   Tue Jul 14 17:29:33 2015 -0400

    Pass CI_PULL_REQUEST through to coveralls if it is set
---
 lib/convertLcovToCoveralls.js  |  3 +++
 lib/getOptions.js              |  6 ++++++
 test/convertLcovToCoveralls.js |  2 ++
 test/getOptions.js             | 11 +++++++++++
 4 files changed, 22 insertions(+)

diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 3f604e1..8b89f26 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -51,6 +51,9 @@ var convertLcovToCoveralls = function(input, options, cb){
     if (options.repo_token) {
       postJson.repo_token = options.repo_token;
     }
+    if (options.service_pull_request) {
+      postJson.service_pull_request = options.service_pull_request;
+    }
     parsed.forEach(function(file){
       postJson.source_files.push(convertLcovFileObject(file, filepath));
     });
diff --git a/lib/getOptions.js b/lib/getOptions.js
index eab67f4..42a3de1 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -9,6 +9,12 @@ var getBaseOptions = function(cb){
   var git_commit = process.env.COVERALLS_GIT_COMMIT;
   var git_branch = process.env.COVERALLS_GIT_BRANCH;
 
+  var match = (process.env.CI_PULL_REQUEST || "").match(/(\d+)$/);
+
+  if (match) {
+    options.service_pull_request = match[1];
+  }
+
   if (process.env.TRAVIS){
     options.service_name = 'travis-ci';
     options.service_job_id = process.env.TRAVIS_JOB_ID;
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js
index 6a64eda..24fa6c8 100644
--- a/test/convertLcovToCoveralls.js
+++ b/test/convertLcovToCoveralls.js
@@ -29,6 +29,7 @@ describe("convertLcovToCoveralls", function(){
     process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME";
     process.env.COVERALLS_SERVICE_JOB_ID = "SERVICE_JOB_ID";
     process.env.COVERALLS_REPO_TOKEN = "REPO_TOKEN";
+    process.env.CI_PULL_REQUEST = "https://github.com/fake/fake/pulls/123";
     
     getOptions(function(err, options){
       var lcovpath = __dirname + "/../fixtures/onefile.lcov";
@@ -37,6 +38,7 @@ describe("convertLcovToCoveralls", function(){
       options.filepath = libpath;
       convertLcovToCoveralls(input, options, function(err, output){
         should.not.exist(err);
+        output.service_pull_request.should.equal("123");
         //output.git.should.equal("GIT_HASH");
         done();
       });
diff --git a/test/getOptions.js b/test/getOptions.js
index 8a77708..356fb96 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -115,6 +115,9 @@ describe("getOptions", function(){
   it ("should set service_name if it exists", function(done){
     testServiceName(getOptions, done);
   });
+  it("should set service_pull_request if it exists", function(done){
+    testServicePullRequest(getOptions, done);
+  });
   it ("should set service_name and service_job_id if it's running on travis-ci", function(done){
     testTravisCi(getOptions, done);
   });
@@ -246,6 +249,14 @@ var testServiceName = function(sut, done){
   });
 };
 
+var testServicePullRequest = function(sut, done){
+  process.env.CI_PULL_REQUEST = "https://github.com/fake/fake/pulls/123";
+  sut(function(err, options){
+    options.service_pull_request.should.equal("123");
+    done();
+  });
+};
+
 var testTravisCi = function(sut, done){
   process.env.TRAVIS = "TRUE";
   process.env.TRAVIS_JOB_ID = "1234";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list