-
Notifications
You must be signed in to change notification settings - Fork 164
[RFC] Use color to warn about invalid/untrusted signatures #1025
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
base: master
Are you sure you want to change the base?
Conversation
The commit bd7fc27 for example contains 2 expected failures where I don't understand why the mock.patch doesn't work. |
tests/settings/utils_test.py
Outdated
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.__patchers.append(mock.patch('urwid.AttrSpec', mock.Mock( |
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 is your problem. The mantra you need when using mock is "mock it where you use it", so in this case what you actually want to patch is 'alot.settings.utils.AttrSpec'
.
the long version of this is that python makes a shallow copy to prevent people doing stupid things from affecting other people by doing a shallow copy of imports into your module.
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.
I've definatly hit that before and spent a lot of time scratching my head ;)
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.
Thank you!
I will embrace the mantra 🙏 although I didn't get the technical background yet.
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.
so, when you do an import, you get a shallow copy (a group of pointers basically) back to the original module. That way if someone does something stupid in their packge like:
import os
os.path.join = lambda *a: '/'.join('foo', *a)
then that doesn't propegate out of their module. So even if that module is imported into your module and then you import os
, you'll get a new shallow copy of the canoncial os
module.
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.
Ahh now I get what you mean.
I personally like the idea of using green for trusted, red for invalid, and default for unkown, although letting the theme set the values might be smarter. The thing is, that there are 4 states of gpg signatures:
I don't know what's best. I think I'd be okay with using default for 2 & 3, but I really want to be warned in the case of 4 |
FWIW, my thoughs on this: Hardcoding the colouring is maybe not the greatest idea, although most people will stick to the defaults of green/orange/red, simply because someone might have an awkward colour theme for the terminal (all red?) and will want to change the alot theme accordingly. I'd be happy with a pseudo header, but a possible alternative would be to amend the "summary line" of messages to include some text-tag or so, and theme those summary lines similar to the threadline's in search buffers: For instance, here is part of a theme file:
So, we could use, say options Just a proposition, this might be overkill.. |
bd7fc27
to
4a092d6
Compare
Where are we at with this feature? Do we just need someone to sit down and do a through review? |
@dcbaker I consider this "stalled" currently. I am not very motivated at the moment to push it forward but here are the relevant points I think. We need to
Idea for another PR: If we don't have the key we can try to fetch it in the background and update the ui when it is available. |
4a092d6
to
38e8251
Compare
This is a proof of concept that I hope to develop further if you like the idea. Questions for discussion:
Also I am trying to write tests for this in order to better understand when and what should be indicated but I will come up with some questions about the tests for sure (@dcbaker I am looking at you ;)