| import subprocess |
| import openai |
| import markdown, re |
| from PyInquirer import prompt as py_inquirer_prompt, style_from_dict, Token |
|
|
|
|
| def run_command(command): |
| process = subprocess.run(command, shell=True, capture_output=True, text=True) |
| if process.returncode != 0: |
| raise Exception(f"Command {command} failed with exit code {process.returncode}") |
| return process.stdout |
|
|
| jsonl = [] |
|
|
| init_cid = "cc8cce50fabb5a92e5830bb81b5fa96fb613a698" |
|
|
| run_command(f'''cd tvm; git reset --hard {init_cid}''') |
|
|
| count = 0 |
| while True: |
| commit_id = run_command('''cd tvm; git log -1 --format="%H"''') |
| commit_msg_short = run_command('''cd tvm; git log -1 --pretty=%s''') |
| commit_msg_full = run_command('''cd tvm; git log -1 --pretty=%B''') |
| commit_log = run_command('''cd tvm; git log -1''') |
| code_diff = run_command('''cd tvm; git diff main main~1''') |
|
|
| from pprint import pprint |
|
|
| msg = { |
| commit_id.strip(): { |
| "short": commit_msg_short.strip(), |
| "full": commit_msg_full.strip(), |
| "code_diff": code_diff.strip(), |
| "commit_log": commit_log.strip(), |
| } |
| } |
|
|
| jsonl.append(msg) |
|
|
| with open("tvm_commit.jsonl", "w") as f: |
| for line in jsonl: |
| f.write(str(line) + "\n") |
| |
| run_command("cd tvm; git reset --hard HEAD~1") |
| count += 1 |
| print(count) |
| |