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

tag-delta: Allow listing only downgrades or only upgrades #19

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 42 additions & 27 deletions tag_utils/cli/tag_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ def main():
help='Do not use inherit when checking tags')
parser.add_argument('--skip-same', action='store_true', default=False,
help='skip printing entries if they are the same')
parser.add_argument('--skip-downgrades', action='store_true', default=False,
help='skip printing entries if they are downgrades (left > right)')
parser.add_argument('--skip-upgrades', action='store_true', default=False,
help='skip printing entries if they are upgrades (right > left)')

parser.add_argument('left_tag', help='left brew tag for comparison')
parser.add_argument('right_tag', help='right brew tag for comparison')
args = parser.parse_args()

show_new = False
show_removed = False
show_same = True
show_upgrades = True
show_downgrades = True
do_inherit = True

if args.new:
Expand All @@ -46,6 +53,12 @@ def main():
show_removed = True
if args.no_inherit:
do_inherit = False
if args.skip_same:
show_same = False
if args.skip_downgrades:
show_downgrades = False
if args.skip_upgrades:
show_upgrades = False

columns, rows = shutil.get_terminal_size()
fw = str(int((int(columns) - 3) / 3))
Expand All @@ -69,39 +82,41 @@ def main():
print('component,' + lname + ',' + rname + ',status')

# Downgrades (normally bad)
for c in sorted(delta_info['downgrades'].keys()):
lnevr = delta_info['downgrades'][c]['old']
rnevr = delta_info['downgrades'][c]['new']

levr = evr_from_nevr(lnevr)
revr = evr_from_nevr(rnevr)

if sys.stdout.isatty():
f = '%' + fw + 's %s%' + fw + 's %s%' + fw + 's'
print(f % (c, decor.HILIGHT, levr, decor.NORMAL, revr))
else:
if delta_info['downgrades'][c]['rebase']:
print(f'{c},{levr},{revr},rebase')
if show_downgrades:
for c in sorted(delta_info['downgrades'].keys()):
lnevr = delta_info['downgrades'][c]['old']
rnevr = delta_info['downgrades'][c]['new']

levr = evr_from_nevr(lnevr)
revr = evr_from_nevr(rnevr)

if sys.stdout.isatty():
f = '%' + fw + 's %s%' + fw + 's %s%' + fw + 's'
print(f % (c, decor.HILIGHT, levr, decor.NORMAL, revr))
else:
print(f'{c},{levr},{revr},')
if delta_info['downgrades'][c]['rebase']:
print(f'{c},{levr},{revr},rebase')
else:
print(f'{c},{levr},{revr},')
Comment on lines +86 to +100
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff is having a hard time with this. The block is indented one place right to be under the new if show_downgrades: conditional, there's no other changes.


for c in sorted(delta_info['upgrades'].keys()):
lnevr = delta_info['upgrades'][c]['old']
rnevr = delta_info['upgrades'][c]['new']
if show_upgrades:
for c in sorted(delta_info['upgrades'].keys()):
lnevr = delta_info['upgrades'][c]['old']
rnevr = delta_info['upgrades'][c]['new']

levr = evr_from_nevr(lnevr)
revr = evr_from_nevr(rnevr)
levr = evr_from_nevr(lnevr)
revr = evr_from_nevr(rnevr)

if sys.stdout.isatty():
f = '%' + fw + 's %' + fw + 's %s%' + fw + 's%s'
print(f % (c, levr, decor.HILIGHT, revr, decor.NORMAL))
else:
if delta_info['upgrades'][c]['rebase']:
print(f'{c},{levr},{revr},rebase')
if sys.stdout.isatty():
f = '%' + fw + 's %' + fw + 's %s%' + fw + 's%s'
print(f % (c, levr, decor.HILIGHT, revr, decor.NORMAL))
else:
print(f'{c},{levr},{revr},')
if delta_info['upgrades'][c]['rebase']:
print(f'{c},{levr},{revr},rebase')
else:
print(f'{c},{levr},{revr},')
Comment on lines +103 to +117
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above:
The diff is having a hard time with this. The block is indented one place right to be under the new if show_upgrades: conditional, there's no other changes.


if not args.skip_same:
if show_same:
f = '%' + fw + 's %' + fw + 's %' + fw + 's'
for c in sorted(delta_info['common'].keys()):
nevr = delta_info['common'][c]
Expand Down