Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@LukeHalasy
Copy link
Contributor

@LukeHalasy LukeHalasy commented Oct 3, 2023

Solution for #79.

Adds a config option, sort_branch_list_by_commit_date, with a default value of false, that will allow users to sort the branch list on the checkout screen by most recent commit date.

@LukeHalasy
Copy link
Contributor Author

Does a config option make sense for this ?
Or should it be a flag (don't know if we have a notion of flags yet) ?

@LukeHalasy
Copy link
Contributor Author

Will need to think through how to fix the Clippy warning about there being too many boolean values in the Options struct.
Also need to fix the test..

Copy link
Owner

@Piturnah Piturnah left a comment

Choose a reason for hiding this comment

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

Love this idea!

Does a config option make sense for this ?
Or should it be a flag (don't know if we have a notion of flags yet) ?

I think, even if we had a notion of flags, a config option would still be the right choice (and you could override it later with a flag). Flags are not supported yet because I haven't given them enough thought -- there are some problems with the way it's done in Magit (imho) that I would like to see about addressing

Will need to think through how to fix the Clippy warning about there being too many boolean values in the Options struct.

This lint exists because Clippy thinks you might be trying to make a state machine. It's not the case here, so you can ignore the lint. (you can make the lint pass by adding #[allow(clippy::struct_excessive_bools)] to the struct.

Looking at the git documentation, it seems a number of keys can be provided, where the default is refname. How would you feel about making this config field a string instead, where the user can just provide a key for this argment?

E.g.:

sort_branches = "refname"
sort_branches = "-committerdate"

@LukeHalasy
Copy link
Contributor Author

Looking at the git documentation, it seems a number of keys can be provided, where the default is refname. How would you feel about making this config field a string instead, where the user can just provide a key for this argment?

E.g.:

sort_branches = "refname"
sort_branches = "-committerdate"

This makes sense to me. It expands the utility of this PR.

How do we make it clear what the possible values that you can pass to this option are (comment next to the readme entry ? ) ?
What should we do in the case of someone providing an improper value (fall back to no-sort ?) ?

@LukeHalasy
Copy link
Contributor Author

Flags are not supported yet because I haven't given them enough thought -- there are some problems with the way it's done in Magit (imho) that I would like to see about addressing

Would love to hear more about this (would be better to do it in a discussion post).

@Piturnah
Copy link
Owner

Piturnah commented Oct 3, 2023

How do we make it clear what the possible values that you can pass to this option are (comment next to the readme entry ? ) ?

Sounds good. I think it would be enough for now to just link to the git documentation.

What should we do in the case of someone providing an improper value (fall back to no-sort ?) ?

Seems reasonable to me. I would say if the call to git returns non-zero exit code then fallback to refname and propagate stderr to the minibuffer.

Alternatively, you could reject the key at the time the config is parsed. This will mean the error is caught before the branch list is ever opened, but arguably would be less stable in case git changes its API (though I think this is rare)

@LukeHalasy LukeHalasy requested a review from Piturnah October 4, 2023 17:13
if output.status.success() {
output
} else {
MiniBuffer::push_command_output(&output);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will show the error right when someone opens up gex. Also the error message isn't very informative. It just says "unknown field name: {whatever you passed into sort_branches}"

Copy link
Owner

@Piturnah Piturnah left a comment

Choose a reason for hiding this comment

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

Everything looks great! Thanks for your contribution!

@Piturnah Piturnah merged commit 8ea7352 into Piturnah:main Oct 4, 2023
@Piturnah
Copy link
Owner

Released in 0.6.4 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants