#!/usr/bin/env python3
import os
import sys

expected = [os.path.realpath("/tmp"), ["show", "-s", "test_revision"]]
actual = [os.getcwd(), sys.argv[1:-1]]
if expected != actual:
    print(f"ERROR\nExpect: {expected}\nActual: {actual}")
    sys.exit(1)

last_arg = sys.argv[len(sys.argv) - 1]
if not last_arg.startswith("--format="):
    print("ERROR\nbad format argument")
    sys.exit(1)

if last_arg == "--format=%H":
    print("some-commit-hash")
elif last_arg == "--format=%an":
    print("Some Author")
elif last_arg == "--format=%ae":
    print("author@example.com")
elif last_arg == "--format=%s":
    print("Some message subject")
elif last_arg == "--format=%b":
    print("Message body\n  with multiple lines")
else:
    print("ERROR\nbad format argument")
    sys.exit(1)
