2 # amend HEAD commit to contain acab in its hash, it does so by repeatedly
3 # amending the commit with a new date.
10 parser = argparse.ArgumentParser()
11 parser.add_argument('--start', type=str, default='commit', help='now or commit')
12 parser.add_argument('--prefix', action='store_true')
13 parser.add_argument('--suffix', action='store_true')
14 parser.add_argument('-q', '--quiet', action='store_true')
15 args = parser.parse_args()
17 if args.start == 'commit':
18 p = subprocess.run(['git', 'show', '--format=format:%at'], capture_output=True)
19 timestamp = int(p.stdout[: p.stdout.index(b'\n')])
20 elif args.start == 'now':
21 timestamp = int(time.time())
23 sys.stderr('unknown value for --start')
31 timestamp += direction
32 if counter % 3600 == 0:
33 # don't move more than one hour in the past, going back to initial time
34 # will give new commit hashes as the commit date (not author date) will
36 direction = - direction
39 '%5d - %s - [%s:%02d]'
42 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)),
43 int((time.time() - t0) // 60),
44 int((time.time() - t0) % 60),
55 '--date=%s' % time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)),
59 p = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True)
60 if args.prefix and not p.stdout.startswith(b'acab'):
62 if args.suffix and not p.stdout.strip().endswith(b'acab'):
64 if b'acab' in p.stdout:
68 print('\ngot %s' % p.stdout.decode().strip())