aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Merwin <[email protected]>2015-12-10 12:52:55 -0800
committerNick Merwin <[email protected]>2015-12-10 12:52:55 -0800
commitd084add18e87fd1a292315de7c9eb171e8fd4b93 (patch)
treec90578e6a9540b8af75a930dc25d3c07be4efee6 /lib
parent712e6e4bb4d8e1a60f646d954743a6808aa7f13e (diff)
parentd60635885d243abef2cbc5b2a0da7a27d752a14b (diff)
downloadnode-coveralls-d084add18e87fd1a292315de7c9eb171e8fd4b93.tar.xz
node-coveralls-d084add18e87fd1a292315de7c9eb171e8fd4b93.zip
merge conflictspr/96
Diffstat (limited to 'lib')
-rw-r--r--lib/convertLcovToCoveralls.js6
-rw-r--r--lib/detectLocalGit.js2
-rw-r--r--lib/fetchGitData.js2
-rw-r--r--lib/getOptions.js22
-rw-r--r--lib/handleInput.js7
-rw-r--r--lib/sendToCoveralls.js7
6 files changed, 36 insertions, 10 deletions
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 3f604e1..896462e 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -48,9 +48,15 @@ var convertLcovToCoveralls = function(input, options, cb){
if (options.service_job_id){
postJson.service_job_id = options.service_job_id;
}
+ if (options.service_pull_request){
+ postJson.service_pull_request = options.service_pull_request;
+ }
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/detectLocalGit.js b/lib/detectLocalGit.js
index 302cd44..773eb70 100644
--- a/lib/detectLocalGit.js
+++ b/lib/detectLocalGit.js
@@ -3,7 +3,7 @@ var path = require('path');
var REGEX_BRANCH = /^ref: refs\/heads\/(\w+)$/;
-module.exports = function detectLocalGit(knownCommit, knownBranch) {
+module.exports = function detectLocalGit() {
var dir = process.cwd(), gitDir;
while (path.resolve('/') !== dir) {
gitDir = path.join(dir, '.git');
diff --git a/lib/fetchGitData.js b/lib/fetchGitData.js
index 67b6190..0c516d3 100644
--- a/lib/fetchGitData.js
+++ b/lib/fetchGitData.js
@@ -59,7 +59,7 @@ function fetchBranch(git, cb) {
});
}
-var REGEX_COMMIT_DETAILS = /\nauthor (.+?) <(.+?)>.+\ncommitter (.+?) <(.+?)>.+\n?[\S\s]+?\n\n(.*)/m;
+var REGEX_COMMIT_DETAILS = /\nauthor (.+?) <(.+?)>.+\ncommitter (.+?) <(.+?)>.+[\S\s]*?\n\n(.*)/m;
function fetchHeadDetails(git, cb) {
exec('git cat-file -p ' + git.head.id, function(err, response) {
diff --git a/lib/getOptions.js b/lib/getOptions.js
index eab67f4..350af68 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -9,10 +9,16 @@ 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;
- git_commit = process.env.TRAVIS_COMMIT;
+ git_commit = 'HEAD';
git_branch = process.env.TRAVIS_BRANCH;
}
@@ -28,6 +34,7 @@ var getBaseOptions = function(cb){
if (process.env.JENKINS_URL){
options.service_name = 'jenkins';
options.service_job_id = process.env.BUILD_ID;
+ options.service_pull_request = process.env.ghprbPullId;
git_commit = process.env.GIT_COMMIT;
git_branch = process.env.GIT_BRANCH;
}
@@ -62,7 +69,7 @@ var getBaseOptions = function(cb){
}
if (!git_commit || !git_branch) {
- var data = require('./detectLocalGit')(git_commit, git_branch);
+ var data = require('./detectLocalGit')();
if (data) {
git_commit = git_commit || data.git_commit;
git_branch = git_branch || data.git_branch;
@@ -108,11 +115,13 @@ var getBaseOptions = function(cb){
}
};
-var getOptions = function(cb){
+var getOptions = function(cb, _userOptions){
if (!cb){
throw new Error('getOptions requires a callback');
}
+ var userOptions = _userOptions || {};
+
getBaseOptions(function(err, options){
// try to get filepath from the command-line
if (process.argv[2]) {
@@ -124,7 +133,12 @@ var getOptions = function(cb){
options.filepath = process.argv[2];
}
}
- cb(err, options);
+
+ // lodash or else would be better, but no need for the extra dependency
+ for (var option in userOptions) {
+ options[option] = userOptions[option];
+ }
+ cb(err, options);
});
};
diff --git a/lib/handleInput.js b/lib/handleInput.js
index 5f88394..845bfad 100644
--- a/lib/handleInput.js
+++ b/lib/handleInput.js
@@ -1,9 +1,10 @@
var index = require('../index');
var logger = require('./logger')();
-function handleInput(input, cb) {
+function handleInput(input, cb, userOptions) {
logger.debug(input);
- var options = index.getOptions(function(err, options){
+ logger.debug('user options ' + userOptions);
+ index.getOptions(function(err, options){
if (err){
logger.error("error from getOptions");
@@ -33,7 +34,7 @@ function handleInput(input, cb) {
cb(null);
});
});
- });
+ }, userOptions);
}
module.exports = handleInput;
diff --git a/lib/sendToCoveralls.js b/lib/sendToCoveralls.js
index 10e614d..38b37f7 100644
--- a/lib/sendToCoveralls.js
+++ b/lib/sendToCoveralls.js
@@ -1,8 +1,13 @@
var request = require('request');
var sendToCoveralls = function(obj, cb){
+ var urlBase = 'https://coveralls.io';
+ if (process.env.COVERALLS_ENDPOINT) {
+ urlBase = process.env.COVERALLS_ENDPOINT;
+ }
+
var str = JSON.stringify(obj);
- var url = 'https://coveralls.io/api/v1/jobs';
+ var url = urlBase + '/api/v1/jobs';
request.post({url : url, form : { json : str}}, function(err, response, body){
cb(err, response, body);
});