-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trees API support #103
Conversation
…tests. They need it because of the common base class. Fix a reference to the wrong entity in the tree test. Fix a typo.
addon/serializers/github-tree.js
Outdated
sha: resourceHash.sha, | ||
url: resourceHash.url, | ||
files: resourceHash.tree | ||
.filter(item => item.type === 'blob') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filterBy('type', 'blob')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are js arrays, not Ember arrays.
addon/serializers/github-tree.js
Outdated
return files; | ||
}, {}), | ||
directories: resourceHash.tree | ||
.filter(item => item.type === 'tree') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filterBy('type', 'tree')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are js arrays, not Ember arrays.
addon/serializers/github-tree.js
Outdated
.filter(item => item.type === 'blob') | ||
.map(blob => blob.url), | ||
trees: resourceHash.tree | ||
.filter(item => item.type === 'tree') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're having to do both of these filters twice, maybe it makes sense to alias them at the top of the method and then perform the reduce/map calls on the already filtered arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach seems fine. A few places for cleanup, but otherwise LGTM.
addon/serializers/github-tree.js
Outdated
sha: resourceHash.sha, | ||
url: resourceHash.url, | ||
files: blobItems | ||
.reduce((files, blob) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer this moved up onto the same line now that it's just a variable name, better readability (and below as well for the other 3 calls)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor change, otherwise LGTM
@elwayman02 Do you know of a better way to handle the tree entries? The
path
names are part of the tree, not part of the referencedtree
orblob
. I suspect this allows a single hash to appear in multiple directories or for the hash to remain the same if the file is renamed or moved. The result is that you have a referenced entity that is a superset of the entity's direct representation.