-
-
Notifications
You must be signed in to change notification settings - Fork 468
Use git config values as default author and email #2271
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
Conversation
|
I think this is a cool and clever idea....but I'll just throw this out there to consider, @freakboy3742. There may be somewhat of a "creepy factor" here. When one uses a tool that starts using their personal information without permission or explaining itself, it might feel creepy/invasive. Or it might conjure questions of "what other information is being gathered?" Or "is this information being exfiltrated anywhere?" If there's any agreement this is more of a valid concern rather than paranoia, it may be worthwhile to tell the user these details were simply retrieved from Git's settings when they are shown. Coming from another direction, if the Git data is inaccurate, then the user may just be confused....for instance, what if this is a shared computer and someone else's details get pulled in. |
|
@NMertsch Thanks for the PR; it's currently getting stuck on the towncrier requirement in CI; see the contribution guide for details on how to resolve this.
This feels a little paranoid, but if it's triggered your paranoia filter, then you won't be the only one. If we've used git details, it might be worth adding a "Based on your git configuration, we believe your name is..." comment to the help text where we're using those details. That also helps mitigate the "someone else's computer" problem. |
|
Thank you for the quick feedback!
Good point, I didn't consider this and totally agree about the creepiness. I'll add a note about where the information is coming from (
I know, and I'm also missing most tests, and am uncertain about some design decisions. That's why I marked the PR as Draft and added some questions 🙂 I'll mark it as Ready once I'm done. |
freakboy3742
left a comment
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 looks really good - and it works great in my manual testing.
A couple of cosmetic tweaks to language in the UI and changenote; and some small suggestions for test improvements.
freakboy3742
left a comment
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 all looks great - with one last change to remove the "if no git" section in favor of. test mock for get_git_config_value(), I think this will be ready to land!
freakboy3742
left a comment
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 looks great - thanks for those updates.
The CI failures look to be the semi-regular "OpenSuSE messes up their package repo" bug that we see occasionally; that usually self-resolves with 24 hours. I'll keep an eye on it and push the "retry" button until it works.
Summary
This PR improves the default values for "Author" and "Author's Email" in
briefcase newandbriefcase convertby reading the user's git configuration.Fixes #2269
Why?
Currently, the default values are:
Author: Jane DeveloperAuthor's Email: firstname@domain (e.g.[email protected]from Author "Niklas Mertsch" and domain "org.example")This PR checks for the git config values
user.nameanduser.email. If they are set, they are used instead of the current default values.Details
New method
BaseCommand.get_git_config_value(section: str, option: str) -> str | None/etc/git/config)~/.gitconfig)~/.config/git/config)./.git/config)Updated default values in
NewCommandandConvertCommandself.get_git_config_value("user", "name"/"email")is notNone:ConvertCommandemail handling).Comments for reviewers
BaseCommandreally is the right place forget_git_config_value(). I chose it because it is the base class ofNewCommandandConvertCommand, and because it providesself.tools.gitso we don't have to guard thegitimport in multiple places.get_git_config_value()does what it is doing. The implementation is trivial, and I can't find a way to test it without actually just testing mocks.NewCommandtogether, not in one test for author and one for email. That's because both are set in the same method (NewCommand.build_app_context()), so splitting the tests seemed to add too much code duplication. Splittingbuild_app_context()into smaller methods might be the right approach here, but I didn't want to take that decision for you.Open questions for reviewers
command.tools.gitout of the general test setup, I check for its presence inget_git_config_value(). This check should always be true, so I addedself.console.warning(...)in that case. Is that the right way to handle this?PR Checklist:
git configas optional source for default valuesget_git_config_value()reads correct config filesNewCommanduses git values if presentConvertCommanduses git values if present