git-bundle-sha
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -27,2 +27,7 @@ var child_process = require('child_process'), | ||
}); | ||
}, | ||
makeSHALengthCallback = function (callback, shaLength) { | ||
return function (err, sha) { | ||
callback(err, (sha || '').slice(0, shaLength)); | ||
}; | ||
}; | ||
@@ -36,12 +41,27 @@ | ||
* the latest commit in which one of the files was modified. | ||
* @param {Boolean} force don't read any values from cache. For performance, some | ||
* @param {Object} options a hash of any of the following options: | ||
* {Boolean} force don't read any values from cache. For performance, some | ||
* data (like known submodule paths) are cached normally. | ||
* default = false | ||
* {Number} length trim the resulting SHA to this many characters (from front) | ||
* default = null (use full SHA) | ||
* @param {Function} callback function that will receive the SHA1 as its first argument | ||
*/ | ||
module.exports = function (/* [files,] [force,] callback */) { | ||
module.exports = function (/* [files,] [options,] callback */) { | ||
var args = Array.prototype.slice.call(arguments), | ||
cb = args.pop(), | ||
files = args.shift() || [], | ||
force = args.shift() || false; | ||
options = args.shift() || {}, | ||
origCallback; | ||
// handle case of options, but no list of files | ||
if (!Array.isArray(files)) { | ||
options = files; | ||
files = []; | ||
} | ||
if (typeof options.length === 'number') { | ||
cb = makeSHALengthCallback(cb, options.length); | ||
} | ||
// just get the latest commit | ||
@@ -52,3 +72,3 @@ if (files.length === 0) { | ||
if (force) { | ||
if (options.force) { | ||
// clear any closure caches | ||
@@ -55,0 +75,0 @@ submodulePromise = null; |
{ | ||
"name": "git-bundle-sha", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Retrieve the git SHA of the commit that most recently touched a list of files.", | ||
"main": "lib/git-sha.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test/test.js" | ||
}, | ||
@@ -17,3 +17,7 @@ "author": { | ||
"bluebird": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^1.21.4", | ||
"sinon": "^1.10.3" | ||
} | ||
} |
# git-bundle-sha | ||
[![Build Status](https://travis-ci.org/diurnalist/git-bundle-sha.svg?branch=master)](https://travis-ci.org/diurnalist/git-bundle-sha) | ||
Retrieve the Git SHA of the latest commit that touched any number of files. | ||
Useful in particular with bundling, when you want to identify a collection of files by | ||
something like a hash, but tied to something more real (like a Git history.) | ||
Useful in particular with bundling, when you want to identify a collection of files by something like a hash, but tied to something more real (like a Git history.) | ||
@@ -39,2 +40,10 @@ ## Usage | ||
### Options | ||
#### `force` | ||
Don't read any values from cache (some things, like the submodule list, are cached for performance.) Default = `false`. | ||
#### `length` | ||
Trim the resulting SHA to a specified length. Default = `null` (no trimming.) | ||
## Notes | ||
@@ -41,0 +50,0 @@ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
8636
8
142
2
58
2
3