-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpick_release_name.py
453 lines (437 loc) · 9.08 KB
/
pick_release_name.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#!/usr/bin/env python3
# ruff: noqa: S311
import subprocess
from functools import cache
from pathlib import Path
from random import Random
UNIQUE_ITEM_NAMES = [
"%Cu+ie^_^ki||er",
"/He4rtf;ull Spl0Dge..r",
"12 Pounder",
"1340 Shield",
"3DD1.E",
"88 Fragnum",
"Absolute Zero",
"Ack Ack",
"Actualizer",
"Aequitas",
"Ahab",
"Amigo Sincero",
"Antagonist",
"Antifection",
"Asteroid Belt",
"Avalanche",
"Avenger",
"Baby Boomer",
"Baby Maker",
"Bad Touch",
"Badaboom",
"Bane",
"Bearcat",
"Bekah",
"Berrigan",
"Big Boom Blaster",
"Bigg Thumppr",
"Bitch",
"Black Hole",
"Black Snake",
"Blockade",
"Blockhead",
"Blood of Terramorphous",
"Blood of the Ancients",
"Blood of the Seraphs",
"Blowfly",
"Boganella",
"Bone Shredder",
"Bone of the Ancients",
"Bonus Package",
"Boom Puppy",
"Boomacorn",
"Boss Nova",
"Bouncing Bazza",
"Bouncing Bonny",
"Boxxy Gunn",
"Breath of Terramorphous",
"Breath of the Seraphs",
"Buffalo",
"Bullpup",
"Bunny",
"Butcher",
"CHOPPER",
"Carnage",
"Cat o' Nine Tails",
"Cathartic Oz Kit",
"Celestial Baroness",
"Celestial Doppelganger",
"Celestial Enforcer",
"Celestial Fragtrap",
"Celestial Gladiator",
"Celestial Lawbringer",
"Chain Lightning",
"Cheat Code",
"Chronicler Of Elpis",
"Chulainn",
"Chère-amie",
"Cobra",
"Commerce",
"Company Man",
"Conference Call",
"Contraband Sky Rocket",
"Cracked Sash",
"Creamer",
"Crit",
"Crossfire",
"Cry Baby",
"Cryophobia",
"Cyber Eagle",
"Dahlminator",
"Damned Cowboy",
"Data Scrubber",
"Deadly Bloom",
"Deliverance",
"Deputy's Badge",
"Devastator",
"Dog",
"E-GUN",
"Easy Mode",
"Elephant Gun",
"Emperor",
"Eridian Vanquisher",
"Evil Smasher",
"Evolution",
"Excalibastard",
"Fabled Tortoise",
"Fast Talker",
"Fastball",
"Fatale",
"Fibber",
"Fire Bee",
"Fire Storm",
"Fireball",
"Firestarta",
"Flakker",
"Flame of the Firehawk",
"Flayer",
"Florentine",
"Four Seasons",
"Freedom Oz Kit",
"Fremington's Edge",
"Fridgia",
"Frostfire",
"Fusillade",
"Fuster Cluck",
"Globber",
"Godfinger",
"Good Touch",
"Greed",
"Grog Nozzle",
"Gub",
"Gunerang",
"Gwen's Head",
"Gwen's Other Head",
"Hail",
"Hammer Buster",
"Hammer Buster II",
"Hard Carry",
"Hard Reboot",
"Hawk Eye",
"Haymaker",
"Heart Breaker",
"Heart of the Ancients",
"Hector's Paradise",
"Hellfire",
"Hide of Terramorphous",
"Hive",
"Hoplite",
"Hornet",
"Hot Mama",
"Hydra",
"IVF",
"Ice Scream",
"Impaler",
"Infection",
"Infection Cleaner",
"Infinity",
"Interfacer",
"Invader",
"Invigoration Oz Kit",
"Jack-o'-Cannon",
"Jolly Roger",
"Judge",
"Kala",
"Kaneda's Laser",
"KerBlaster",
"KerBoom",
"Kiss of Death",
"Kitten",
"Lady Fist",
"Landscaper",
"Lascaux",
"Laser Disker",
"Law",
"Lazlo's Freezeasy",
"Lead Storm",
"Leech",
"Legendary Anarchist",
"Legendary Berserker",
"Legendary Binder",
"Legendary Cat",
"Legendary Catalyst",
"Legendary Engineer",
"Legendary Gunzerker",
"Legendary Hoarder",
"Legendary Hunter",
"Legendary Killer",
"Legendary Mechromancer",
"Legendary Ninja",
"Legendary Nurse",
"Legendary Pointman",
"Legendary Psycho",
"Legendary Ranger",
"Legendary Reaper",
"Legendary Roboteer",
"Legendary Sickle",
"Legendary Siren",
"Legendary Sniper",
"Legendary Soldier",
"Legendary Titan",
"Legendary Torch",
"Lightning Bolt",
"Little Evie",
"Logan's Gun",
"Longbow",
"Longest Yard",
"Longnail",
"Love Thumper",
"Luck Cannon",
"Lucrative Opportunity",
"Lyuda",
"M0RQ",
"M2828 Thumpson",
"MINAC's Atonement",
"Madhous!",
"Maggie",
"Magic Missile",
"Magma",
"Major Tom",
"Manly Man Shield",
"Marek's Mouth",
"Meat Grinder",
"Meganade",
"Meteor Shower",
"Midnight Star",
"Might of the Seraphs",
"Min Min Lighter",
"Mining Laser",
"Mongol",
"Monster Trap",
"Moonface",
"Moonlight Saga",
"Moonscaper",
"Morningstar",
"Mouthwash",
"Moxxi's Endowment",
"Mysterious Amulet",
"Nasty Surprise",
"Naught",
"Neogenator",
"Nirvana",
"Norfleet",
"Nukem",
"O-Negative",
"Octo",
"Ogre",
"Ol' Painful",
"Ol' Rosie",
"Omen",
"Omni-Cannon",
"Orc",
"Order",
"Orphan Maker",
"Otto Idol",
"Overcompensator",
"Oxidizer",
"Pandemic",
"Party Line",
"Party Popper",
"Patriot",
"Peak Opener",
"Pimpernel",
"Pitchfork",
"Plunkett",
"Pocket Rocket",
"Pot O' Gold",
"Prismatic Bulwark",
"Probe",
"Proletarian Revolution",
"Pun-chee",
"Pyrophobia",
"Quasar",
"Rapid Release",
"Rapier",
"Razorback",
"Reogenator",
"Rerouter",
"Retainer",
"Retcher",
"Rex",
"Roaster",
"RokSalt",
"Rolling Thunder",
"Rubi",
"SWORDSPLOSION",
"Sand Hawk",
"Sawbar",
"Scorpio",
"Seeker",
"Seraphim",
"Shadow of the Seraphs",
"Sheriff's Badge",
"Shield of Ages",
"Shooterang",
"Shotgun 1340",
"Shredifier",
"Skin of the Ancients",
"Skullmasher",
"Slagga",
"Slammer",
"Slayer Of Terramorphous",
# This is actually in vanilla, Kreig's COM is lowercase, deliberately ignoring it for clarity
# "Slayer of Terramorphous",
"Sledge's Shotgun",
"Sledge's Shotty",
"Sloth",
"Slow Hand",
"Smasher",
"Snowball",
"Sponge",
"Stalker",
"Stinger",
"Stinkpot",
"Stomper",
"Storm",
"Storm Front",
"Striker",
"Sunshine",
"Supernova",
"Support Relay",
"Systems Purge",
"T4s-R",
"Tannis' Laser of Enlightenment",
"Tattler",
"Teapot",
"Teeth of Terramorphous",
"The Afterburner",
"The Bee",
"The Cradle",
"The Electric Chair",
"The Machine",
"The Rough Rider",
"The Sham",
"The Shooting Star",
"The Transformer",
"The ZX-1",
"Thingy",
"Thunderball Fists",
"Thunderfire",
"Tidal Wave",
"Tinderbox",
"Toby's Bright Spadroon",
"Too Scoops",
"Toothpick",
"Torguemada",
"Torrent",
"Trespasser",
"Triquetra",
"Tunguska",
"Twister",
"Unforgiven",
"Unicornsplosion",
"Unkempt Harold",
"Vandergraffen",
"Vault Hunter's Relic",
"Veritas",
"Veruc",
"Vibra-Pulse",
"Viral Marketer",
"Volcano",
"Volt Thrower",
"Wallop",
"Wanderlust",
"Wet Week",
"Whisky Tango Foxtrot",
"Winter is Over",
"Wombat",
"World Burn",
"Yellow Jacket",
"Zappinator",
"Zim",
]
PREVIOUS_RELEASE_NAMES = [
"Sheriff's Badge",
"Omni-Cannon",
"Razorback",
"Naught",
"Luck Cannon",
]
@cache
def get_git_commit_hash(identifier: str | None = None) -> str:
"""
Gets the full commit hash of the current git repo.
Args:
identifier: The identifier of the commit to get, or None to get the latest.
Returns:
The commit hash.
"""
args = ["git", "show", "-s", "--format=%H"]
if identifier is not None:
args.append(identifier)
return subprocess.run(
args,
cwd=Path(__file__).parent,
check=True,
stdout=subprocess.PIPE,
encoding="utf8",
).stdout.strip()
def pick_release_name(commit_hash: str, excludes: list[str] = PREVIOUS_RELEASE_NAMES) -> str:
"""
Picks the name to use for a release.
Args:
commit_hash: The commit hash to pick the name of.
excludes: The list of names to exclude.
Returns:
The release name.
"""
# Think it's better to rely on an int than the string's hash method
rng = Random(int(commit_hash, 16))
while (name := rng.choice(UNIQUE_ITEM_NAMES)) in excludes:
pass
return name
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description="Picks the friendly name to use for the current release.",
)
parser.add_argument(
"hash",
nargs="?",
default=None,
help="The commit hash to base the name off of. If not given, retrieves from git.",
)
parser.add_argument(
"--exclude",
metavar="NAME",
action="append",
default=[],
help="Excludes a name as if it were used in a previous release.",
)
parser.add_argument(
"--ignore-previous-releases",
action="store_true",
help="Ignores all names which have been used in previous releases.",
)
args = parser.parse_args()
commit_hash = get_git_commit_hash(args.hash)
excludes = [] if args.ignore_previous_releases else PREVIOUS_RELEASE_NAMES
excludes += args.exclude
print(pick_release_name(commit_hash, excludes))