Skip to content

Commit 0c32e97

Browse files
committed
provide getHash for component-downloader and shrinkwrapper
1 parent a62e32c commit 0c32e97

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

HISTORY.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.2.0 / 2015-03-14
2+
==================
3+
- provide `getHash()` for component-downloader and shrinkwrapper
4+
15
1.1.11 / 2015-01-22
26
==================
37
- fix [component#621](https://github.com/componentjs/component/issues/621) - not resolving semver in some cases

lib/remotes/bitbucket.js

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ function BitBucket(options) {
2828

2929
BitBucket.prototype.name = 'bitbucket'
3030

31+
BitBucket.prototype.getHash =function* (repo, ref) {
32+
console.log('BitBucket.prototype.getHash not implemented yet');
33+
return null;
34+
};
35+
3136
/**
3237
* DOES NOT SOLVE REDIRECTS!
3338
*

lib/remotes/github.js

+14
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ GitHub.prototype._checkRedirect = function* (repo) {
5050
return null;
5151
}
5252

53+
GitHub.prototype.getHash =function* (repo, ref) {
54+
var uri = 'https://api.github.com/repos/' + repo + '/commits?sha=' + ref;
55+
debug('GET "%s"', uri);
56+
API_COUNTER++;
57+
var hash = null;
58+
var res = yield* this.request(uri, true);
59+
if (res.statusCode === 404) {
60+
debug('could not fetch hash for ' + repo, ref);
61+
} else {
62+
hash = res.body[0].sha;
63+
}
64+
return hash;
65+
};
66+
5367
/**
5468
* @param {String} repo
5569
* @return {Array} references

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "component-remotes",
33
"description": "Normalize remote end points",
4-
"version": "1.1.11",
4+
"version": "1.2.0",
55
"author": {
66
"name": "Jonathan Ong",
77
"email": "[email protected]",

0 commit comments

Comments
 (0)