| |
@@ -885,18 +885,24 @@
|
| |
return (False, 'too many errors')
|
| |
|
| |
def karma_info(karma, colorize=True):
|
| |
- """ Takes a list of various karma values, counts single values and returns
|
| |
- an info string that will be printed out when the info is requested. """
|
| |
+ """Takes a list of various karma values, counts single values and returns
|
| |
+ an info string that will be printed out when the info is requested."""
|
| |
neutral = karma.count(0)
|
| |
negative = karma.count(-1)
|
| |
- neline = color(f"{neutral} neutral", "orange_1", colorize)
|
| |
- ngline = color(f"{negative} negative", "red", colorize)
|
| |
-
|
| |
- # Only return info if there actually is a karma.
|
| |
+ # Create empty strings for both neutral and negative karma
|
| |
+ # and only fill them if any of them is bigger than 0, i.e.
|
| |
+ # there indeed is some karma.
|
| |
+ neline = ngline = connect = info = ""
|
| |
+ if neutral > 0:
|
| |
+ neline = color(f"{neutral} neutral", "orange_1", colorize)
|
| |
+ if negative > 0:
|
| |
+ ngline = color(f"{negative} negative", "red", colorize)
|
| |
+ if neutral > 0 and negative > 0:
|
| |
+ connect = "and "
|
| |
+
|
| |
+ # We now return the note only if there is something.
|
| |
if neutral > 0 or negative > 0:
|
| |
- info = f"\n Note: This update has {neline} and {ngline} karma. Consider a review.\n"
|
| |
- else:
|
| |
- info = ""
|
| |
+ info = f"\n Note: This update has {neline}{connect}{ngline} karma. Consider a review.\n"
|
| |
return info
|
| |
|
| |
def color(text, colorname, colorize=True):
|
| |
This PR changes the behaviour to show the notes. Currently,
the note was shown anytime there was neutral and negative karma,
and it always showed both neutral and negative karma. Therefore,
we had situations with "there is 1 neutral and 0 negative" where
the red negative statement would be misleading to the user.
Now, we only show what is really there, so no negative karma
is mentioned when the note only shows the neutral karma, and
vice-versa.
This PR fixes https://pagure.io/fedora-easy-karma/issue/43.