-
-
Notifications
You must be signed in to change notification settings - Fork 70
Get tree entries per type. [Old: Allow sorting of tree entries] #220
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
Comments
Hello, the sort could be done in userland? Is it really useful to put this in the core? |
The return of this function contains multiple object types, while the key is just the name of the tree/commitRef/blob it does not allow for an easy sort on just that name, something you probably want if you want to use this library to show the tree. So at least an option to split blobs from the rest would be useful. As you probably don't want to change the return type to show this split, you still return the names as key and then the object so you are still not able to sort on that in userland as it still would combine the two. A different solution that I just came up with: This would allow you to sort them based on the key in userland and with the spread operator combine them into a single array very easily |
I liked the second idea more. I wanted to try this one out and made a draft PR of the implementation. |
I have been using my implementation for a while now and it allows for the functionality in userland without the hassle I was running into before |
Fixed by #221 |
To get entries of a tree this library uses
cat-file
.From what I can tell this returns the tree items based on the code point of the file name.
The outcome of this is that trees/commitRefs are combined with blobs.
My suggestion would be to add an additional parameter (either an enum or const) that allows you to pick a sorting algorithm that would be applied to the entries before they are returned.
I am willing to make an implementations for this, but there are a multitude of ways to sort a directory and I would need to know that if this should be implemented how far it should go.
Some sorting suggestions
The text was updated successfully, but these errors were encountered: