Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Commit

Permalink
tsd.ContentLoader can load from branch-head
Browse files Browse the repository at this point in the history
* before only from commit
* usages problematic with tests
silly typo in version
  • Loading branch information
Bartvds committed Jan 29, 2014
1 parent 1e7b13a commit e28db20
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
13 changes: 9 additions & 4 deletions build/api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion conf/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"days": 1
},
"httpIntervalRef": {
"minutes": 5
"minutes": 1
},
"jobTimeout": {
"seconds": 10
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "tsd",
"version": "0.5.2-alpha.154",
"version": "0.5.2-alpha.15",
"description": "TypeScript Definition manager for DefinitelyTyped.",
"keywords": [
"typescript",
Expand Down
2 changes: 1 addition & 1 deletion src/git/GithubURLs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module git {
this.addTemplate('base', this._base);

this.addTemplate('raw', this._raw);
this.addTemplate('rawFile', this._raw + '/{ref}/{+path}');
this.addTemplate('rawFile', this._raw + '/{+ref}/{+path}');

this.addTemplate('htmlFile', this._base + '/blob/{ref}/{+path}');

Expand Down
25 changes: 15 additions & 10 deletions src/tsd/logic/ContentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module tsd {
promise: DefVersion; with raw .blob loaded
*/
// TODO this should not keep the content in memory
loadContent(file:tsd.DefVersion):Q.Promise<DefVersion> {
loadContent(file:tsd.DefVersion, tryHead:boolean = false):Q.Promise<DefVersion> {
if (file.hasContent()) {
this.track.skip('content_load', file.key);
return Q(file);
Expand All @@ -52,7 +52,12 @@ module tsd {
this.track.promise(d.promise, 'content_load', file.key);

this.core.index.getIndex().progress(d.notify).then((index:tsd.DefIndex) => {
return this.core.repo.raw.getBinary(file.commit.commitSha, file.def.path).progress(d.notify).then((content:NodeBuffer) => {
var ref = file.commit.commitSha;
// re-cycle head
if (tryHead && file.commit.commitSha === file.def.head.commit.commitSha) {
ref = this.core.context.config.ref;
}
return this.core.repo.raw.getBinary(ref, file.def.path).progress(d.notify).then((content:NodeBuffer) => {
if (file.blob) {
// race
if (!file.blob.hasContent()) {
Expand Down Expand Up @@ -88,11 +93,11 @@ module tsd {
this.track.promise(d.promise, 'content_load_bulk');

Q.all(list.map((file:DefVersion) => {
return this.loadContent(file).progress(d.notify);
return this.loadContent(file).progress(d.notify);

})).then((list:tsd.DefVersion[]) => {
d.resolve(list);
}, d.reject);
})).then((list:tsd.DefVersion[]) => {
d.resolve(list);
}, d.reject);

return d.promise;
}
Expand Down Expand Up @@ -131,10 +136,10 @@ module tsd {
list = tsd.DefUtil.uniqueDefs(list);

Q.all(list.map((file:Def) => {
return this.loadHistory(file).progress(d.notify);
})).then((list:DefVersion[]) => {
d.resolve(list);
}, d.reject);
return this.loadHistory(file).progress(d.notify);
})).then((list:DefVersion[]) => {
d.resolve(list);
}, d.reject);

return d.promise;
}
Expand Down
1 change: 0 additions & 1 deletion src/tsd/logic/Installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module tsd {
var Q = require('q');
var path = require('path');
var FS:typeof QioFS = require('q-io/fs');
var pointer = require('json-pointer');

export class Installer extends tsd.SubCore {

Expand Down

0 comments on commit e28db20

Please sign in to comment.