Skip to content

Commit f535718

Browse files
committed
chromium: update.py: Keep the channel order consistent
This makes Git diffs way easier to read. Using sort_keys=True is usually better but with this implementation the output is a bit nicer to read IMO. (cherry picked from commit ceb3acf)
1 parent 8504341 commit f535718

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

  • pkgs/applications/networking/browsers/chromium

pkgs/applications/networking/browsers/chromium/update.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import csv
55
import json
66
import subprocess
7+
import sys
8+
79
from codecs import iterdecode
10+
from collections import OrderedDict
811
from os.path import abspath, dirname
9-
from sys import stderr
1012
from urllib.request import urlopen
1113

1214
HISTORY_URL = 'https://omahaproxy.appspot.com/history?os=linux'
@@ -27,7 +29,7 @@ def nix_prefetch_url(url, algo='sha256'):
2729
channels = {}
2830
last_channels = load_json(JSON_PATH)
2931

30-
print(f'GET {HISTORY_URL}', file=stderr)
32+
print(f'GET {HISTORY_URL}', file=sys.stderr)
3133
with urlopen(HISTORY_URL) as resp:
3234
builds = csv.DictReader(iterdecode(resp, 'utf-8'))
3335
for build in builds:
@@ -59,5 +61,17 @@ def nix_prefetch_url(url, algo='sha256'):
5961
channels[channel_name] = channel
6062

6163
with open(JSON_PATH, 'w') as out:
62-
json.dump(channels, out, indent=2)
64+
def get_channel_key(item):
65+
channel_name = item[0]
66+
if channel_name == 'stable':
67+
return 0
68+
elif channel_name == 'beta':
69+
return 1
70+
elif channel_name == 'dev':
71+
return 2
72+
else:
73+
print(f'Error: Unexpected channel: {channel_name}', file=sys.stderr)
74+
sys.exit(1)
75+
sorted_channels = OrderedDict(sorted(channels.items(), key=get_channel_key))
76+
json.dump(sorted_channels, out, indent=2)
6377
out.write('\n')

0 commit comments

Comments
 (0)