#! /usr/bin/python3 # amend HEAD commit to contain acab in its hash, it does so by repeatedly # amending the commit with a new date. import argparse import subprocess import sys import time parser = argparse.ArgumentParser() parser.add_argument('--start', type=str, default='commit', help='now or commit') parser.add_argument('--prefix', action='store_true') parser.add_argument('--suffix', action='store_true') parser.add_argument('-q', '--quiet', action='store_true') args = parser.parse_args() if args.start == 'commit': p = subprocess.run(['git', 'show', '--format=format:%at'], capture_output=True) timestamp = int(p.stdout[: p.stdout.index(b'\n')]) elif args.start == 'now': timestamp = int(time.time()) else: sys.stderr('unknown value for --start') sys.exit(1) t0 = time.time() counter = 0 direction = -1 while True: counter += 1 timestamp += direction if counter % 3600 == 0: # don't move more than one hour in the past, going back to initial time # will give new commit hashes as the commit date (not author date) will # be different. direction = - direction if not args.quiet: print( '%5d - %s - [%s:%02d]' % ( counter, time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)), int((time.time() - t0) // 60), int((time.time() - t0) % 60), ), end='\r', ) p = subprocess.run( [ 'git', 'commit', '--no-verify', '--amend', '--no-edit', '--date=%s' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)), ], capture_output=True, ) p = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True) if args.prefix and not p.stdout.startswith(b'acab'): continue if args.suffix and not p.stdout.strip().endswith(b'acab'): continue if b'acab' in p.stdout: break if not args.quiet: print('\ngot %s 🔥🚓' % p.stdout.decode().strip())