Skip to content
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

Merged
merged 10 commits into from
Jun 23, 2017
Merged

Add trees API support #103

merged 10 commits into from
Jun 23, 2017

Conversation

srvance
Copy link
Collaborator

@srvance srvance commented Jun 4, 2017

@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 referenced tree or blob. 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.

@srvance srvance self-assigned this Jun 4, 2017
@srvance srvance requested a review from elwayman02 June 4, 2017 23:55
…tests. They need it because of the common base class.

Fix a reference to the wrong entity in the tree test.
Fix a typo.
sha: resourceHash.sha,
url: resourceHash.url,
files: resourceHash.tree
.filter(item => item.type === 'blob')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.filterBy('type', 'blob')

Copy link
Collaborator Author

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.

return files;
}, {}),
directories: resourceHash.tree
.filter(item => item.type === 'tree')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filterBy('type', 'tree')

Copy link
Collaborator Author

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.

.filter(item => item.type === 'blob')
.map(blob => blob.url),
trees: resourceHash.tree
.filter(item => item.type === 'tree')
Copy link
Owner

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Owner

@elwayman02 elwayman02 left a 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.

sha: resourceHash.sha,
url: resourceHash.url,
files: blobItems
.reduce((files, blob) => {
Copy link
Owner

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)

Copy link
Owner

@elwayman02 elwayman02 left a 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

@srvance srvance merged commit 4db2d6a into elwayman02:master Jun 23, 2017
@srvance srvance deleted the add-trees branch June 23, 2017 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants