Skip to content

Commit

Permalink
Merge pull request #19 from stephenmathieson/default-to-master-branch
Browse files Browse the repository at this point in the history
index: Default to `master` when there are no tags
  • Loading branch information
yields committed Feb 1, 2015
2 parents 3d5aa04 + 531e866 commit 5e7a416
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ function remote(name, token) {
*/

function satisfy(refs, version){
var master;
for (var i = 0, ref; ref = refs[i++];) {
if ('master' == ref.name) master = ref;
if (equal(ref.name, version)) return ref;
}
};
return master;
}

/**
* Arrange the refs
Expand Down
8 changes: 8 additions & 0 deletions test/gh-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ describe('resolve()', function(){
});
})

it('should use master when there are no tags', function(done){
resolve('mnmly/slider', function(err, ref){
if (err) return done(err);
assert('master' == ref.name);
done();
})
})

it('should provide better errors for invalid repos', function(done) {
resolve('sweet/repo@amazing/version', function(err, ref){
assert(err);
Expand Down

0 comments on commit 5e7a416

Please sign in to comment.