diff options
| author | Gabe Hayes <[email protected]> | 2013-07-27 11:17:58 -0700 |
|---|---|---|
| committer | Gabe Hayes <[email protected]> | 2013-07-27 11:17:58 -0700 |
| commit | 6e8f7eb88a365894df8352caa826f2c3d8ff700d (patch) | |
| tree | 81e999b0792fdb8f8db71e02b0e261e24363fd99 /lib/fetchGitData.js | |
| parent | bc464dc1d8c9a0ecfac4aefb8f12dd24347b5732 (diff) | |
| download | node-coveralls-6e8f7eb88a365894df8352caa826f2c3d8ff700d.tar.xz node-coveralls-6e8f7eb88a365894df8352caa826f2c3d8ff700d.zip | |
tests for fetchGitData
Diffstat (limited to 'lib/fetchGitData.js')
| -rw-r--r-- | lib/fetchGitData.js | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/lib/fetchGitData.js b/lib/fetchGitData.js index 5f3e582..a5a8eb8 100644 --- a/lib/fetchGitData.js +++ b/lib/fetchGitData.js @@ -2,31 +2,42 @@ var exec = require("exec-sync"); var fetchGitData = function(git) { - var i, - execGit = true, - head = { - "author_name": { - "format": "'%aN'", - "default": "Unknown Author" - }, - "author_email": { - "format": "'%ae'", - "default": "" - }, - "committer_name": { - "format": "'%cN'", - "default": "Unknown Committer" - }, - "committer_email": { - "format": "'%ce'", - "default" :"" - }, - "message": { - "format": "'%s'", - "default": "Unknown Commit Message" - } - }, - remotes = {}; + var i; + var execGit = true; + var head = { + "author_name": { + "format": "'%aN'", + "default": "Unknown Author" + }, + "author_email": { + "format": "'%ae'", + "default": "" + }, + "committer_name": { + "format": "'%cN'", + "default": "Unknown Committer" + }, + "committer_email": { + "format": "'%ce'", + "default" :"" + }, + "message": { + "format": "'%s'", + "default": "Unknown Commit Message" + } + }; + var remotes = {}; + + //-- Throw an error if no data is passed + if ('undefined' === typeof git) { + throw new Error('No options passed'); + + //-- Throw an error if no head or head.id is provided + } else if (!git.hasOwnProperty('head')) { + throw new Error('You must provide the head'); + } else if (!git.head.hasOwnProperty('id')) { + throw new Error('You must provide the head.id'); + } function saveRemote(name, url, push) { var key = name + "-" + url; @@ -87,7 +98,7 @@ var fetchGitData = function(git) { if (execGit) { //-- Branch - if ("" === git.branch.length) { + if ("" === git.branch) { git.branch = exec("git branch").split("\n")[0].replace(/^\*\ /, "").trim(); } |
