File size: 1,364 Bytes
8063620
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)