diff options
| author | Nick Merwin <[email protected]> | 2016-09-15 10:07:20 -0700 |
|---|---|---|
| committer | Nick Merwin <[email protected]> | 2016-09-15 10:07:20 -0700 |
| commit | b92746cd71fd1b0e7cb65dbca7f64270db62eed6 (patch) | |
| tree | 6ef6d9b4459068a4ef192f48a35b6f8c26a07c4d | |
| parent | 9a3d84c7cf7a881d8872f43b7203ab2f79eb133b (diff) | |
| parent | 4084b24c096df22a02659b194abbcf74950268c1 (diff) | |
| download | node-coveralls-b92746cd71fd1b0e7cb65dbca7f64270db62eed6.tar.xz node-coveralls-b92746cd71fd1b0e7cb65dbca7f64270db62eed6.zip | |
Merge branch 'master' of github.com:nickmerwin/node-coveralls
| -rw-r--r-- | lib/getOptions.js | 14 | ||||
| -rw-r--r-- | test/getOptions.js | 32 |
2 files changed, 42 insertions, 4 deletions
diff --git a/lib/getOptions.js b/lib/getOptions.js index e579eee..bb4248d 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -9,6 +9,7 @@ var getBaseOptions = function(cb){ var options = {}; var git_commit = process.env.COVERALLS_GIT_COMMIT; var git_branch = process.env.COVERALLS_GIT_BRANCH; + var git_committer_name, git_committer_email, git_message; var match = (process.env.CI_PULL_REQUEST || "").match(/(\d+)$/); @@ -57,6 +58,9 @@ var getBaseOptions = function(cb){ options.service_job_id = process.env.CI_BUILD_NUMBER; git_commit = process.env.CI_COMMIT_ID; git_branch = process.env.CI_BRANCH; + git_committer_name = process.env.CI_COMMITTER_NAME; + git_committer_email = process.env.CI_COMMITTER_EMAIL; + git_message = process.env.CI_COMMIT_MESSAGE; } if (process.env.WERCKER){ @@ -80,6 +84,11 @@ var getBaseOptions = function(cb){ git_commit = process.env.APPVEYOR_REPO_COMMIT; git_branch = process.env.APPVEYOR_REPO_BRANCH; } + if(process.env.SURF_SHA1){ + options.service_name = 'surf'; + git_commit = process.env.SURF_SHA1; + git_branch = process.env.SURF_REF; + } options.run_at = process.env.COVERALLS_RUN_AT || JSON.stringify(new Date()).slice(1, -1); if (process.env.COVERALLS_SERVICE_NAME){ options.service_name = process.env.COVERALLS_SERVICE_NAME; @@ -123,7 +132,10 @@ var getBaseOptions = function(cb){ if (git_commit){ fetchGitData({ head: { - id: git_commit + id: git_commit, + committer_name: git_committer_name, + committer_email: git_committer_email, + message: git_message }, branch: git_branch }, function(err, git){ diff --git a/test/getOptions.js b/test/getOptions.js index 98c0ea5..bd38b7c 100644 --- a/test/getOptions.js +++ b/test/getOptions.js @@ -144,6 +144,9 @@ describe("getOptions", function(){ it ("should set service_name and service_job_id if it's running on Gitlab", function(done){ testGitlab(getOptions, done); }); + it ("should set service_name and service_job_id if it's running via Surf", function(done){ + testSurf(getOptions, done); + }); it ("should override set options with user options", function(done){ var userOptions = {service_name: 'OVERRIDDEN_SERVICE_NAME'}; process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME"; @@ -338,6 +341,9 @@ var testCodeship = function(sut, done) { process.env.CI_BUILD_NUMBER = '1234'; process.env.CI_COMMIT_ID = "e3e3e3e3e3e3e3e3e"; process.env.CI_BRANCH = "master"; + process.env.CI_COMMITTER_NAME = "John Doe"; + process.env.CI_COMMITTER_EMAIL = "[email protected]"; + process.env.CI_COMMIT_MESSAGE = "adadadadadadadadadad"; sut(function(err, options){ options.service_name.should.equal("codeship"); options.service_job_id.should.equal("1234"); @@ -345,9 +351,9 @@ var testCodeship = function(sut, done) { { id: 'e3e3e3e3e3e3e3e3e', author_name: 'Unknown Author', author_email: '', - committer_name: 'Unknown Committer', - committer_email: '', - message: 'Unknown Commit Message' }, + committer_name: 'John Doe', + committer_email: '[email protected]', + message: 'adadadadadadadadadad' }, branch: 'master', remotes: [] }); done(); @@ -418,6 +424,26 @@ var testGitlab = function(sut, done) { }); }; +var testSurf = function(sut, done) { + process.env.CI_NAME = 'surf'; + process.env.SURF_SHA1 = "e3e3e3e3e3e3e3e3e"; + process.env.SURF_REF = "feature"; + sut(function(err, options){ + options.service_name.should.equal("surf"); + options.git.should.eql({ head: + { id: 'e3e3e3e3e3e3e3e3e', + author_name: 'Unknown Author', + author_email: '', + committer_name: 'Unknown Committer', + committer_email: '', + message: 'Unknown Commit Message' }, + branch: 'feature', + remotes: [] }); + done(); + }); +}; + + function ensureLocalGitContext(options) { var path = require('path'); var fs = require('fs'); |
