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

Improve and clarify branch sorting. #46

Open
dmitshur opened this issue Apr 17, 2015 · 2 comments
Open

Improve and clarify branch sorting. #46

dmitshur opened this issue Apr 17, 2015 · 2 comments

Comments

@dmitshur
Copy link
Contributor

Minor issue. I've noticed that some implementations of Branches sort the branches before returning:

sort.Sort(vcs.Branches(bs))

While others do not. The interface does not specify any sorting behavior.

We should improve docs to specify some behavior, and make the output consistent (if it's not).

@dmitshur
Copy link
Contributor Author

A data point.

Previously, I thought sorting by name was the only reasonable way to sort branch names.

Recently, I've had the need to sort branches by the date of their latest commit.

This makes me think it may be better not to sort branches and let the user do it based on their needs. We could provide helpers for common sort types:

// Sort by branch name.
sort.Sort(vcs.ByName(branches))

// Sort by author date, most recent first.
sort.Sort(sort.Reverse(vcs.ByAuthorDate(branches)))

On the other hand, sorting branches by name may be a decent and inexpensive "default", so perhaps it's fine to always do that (the user can sort again differently if they need).

@sqs
Copy link
Member

sqs commented Apr 21, 2015

I think it'd be nice to sort them by ahead and behind, with the default branch in the middle.

like

  • a
  • b
  • master
  • c
  • d

where a and b are ahead of master and c and d are behind. Not sure how this works with nonlinear history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants