Ligeng-Zhu/git-commit
069
1import subprocess2import openai3import markdown, re4from PyInquirer import prompt as py_inquirer_prompt, style_from_dict, Token5 6 7def run_command(command):8 process = subprocess.run(command, shell=True, capture_output=True, text=True)9 if process.returncode != 0:10 raise Exception(f"Command {command} failed with exit code {process.returncode}")11 return process.stdout12 13jsonl = [] 14 15init_cid = "cc8cce50fabb5a92e5830bb81b5fa96fb613a698"16 17run_command(f'''cd tvm; git reset --hard {init_cid}''')18 19count = 020while True:21 commit_id = run_command('''cd tvm; git log -1 --format="%H"''')22 commit_msg_short = run_command('''cd tvm; git log -1 --pretty=%s''')23 commit_msg_full = run_command('''cd tvm; git log -1 --pretty=%B''')24 commit_log = run_command('''cd tvm; git log -1''')25 code_diff = run_command('''cd tvm; git diff main main~1''')26 27 from pprint import pprint28 29 msg = {30 commit_id.strip(): {31 "short": commit_msg_short.strip(),32 "full": commit_msg_full.strip(),33 "code_diff": code_diff.strip(),34 "commit_log": commit_log.strip(),35 }36 }37 38 jsonl.append(msg)39 40 with open("tvm_commit.jsonl", "w") as f:41 for line in jsonl:42 f.write(str(line) + "\n")43 # 44 run_command("cd tvm; git reset --hard HEAD~1")45 count += 146 print(count)47 