gitmover/run.py

38 lines
1.1 KiB
Python
Raw Normal View History

2024-08-31 12:02:52 +08:00
import os
PATH = "../study-area-cn"
SRC = "src/learn_computer_basic"
DIST = "src"
pwd = os.getcwd()
def set_a_commit(commit_id: str, commit_usr: str, commit_email: str, commit_info: str, date: str):
os.system("cp -r "+PATH+" "+".run")
os.system("cd .run;git reset --hard "+commit_id)
os.system("cd .run;git clean -f .")
os.system("cp -r .run"+os.sep+SRC+os.sep+"* "+"output"+os.sep+DIST+os.sep)
os.system(f"cd output;git config user.name \"{commit_usr}\"")
os.system(f"cd output;git config user.email \"{commit_email}\"")
os.system(f"cd output;git add .")
os.system(f"cd output;git commit -m \"{commit_info}\" --date=\"{date}\"")
os.system(f"rm -rf .run")
os.mkdir("output")
os.mkdir("output"+os.sep+DIST)
os.system("cd "+PATH+";git log --pretty=\"%H|%an|%ae|%at|%s\" > " +
pwd+os.sep+"log.txt")
os.system("cd output;git init")
with open("log.txt", "r") as file:
lns = file.readlines()
lns.reverse()
n = 0
for i in lns:
n += 1
print("==> "+str(n)+"/"+str(len(lns)))
arg = i.rstrip(" \n\r").lstrip(" \n\r").split("|")
set_a_commit(arg[0], arg[1], arg[2], arg[4], arg[3])