-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommiter.py
59 lines (45 loc) · 1.63 KB
/
commiter.py
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
48
49
50
51
52
53
54
55
56
57
58
import subprocess
import os
import datetime
import time
from main import *
def commit_init():
os.chdir(REPO_DIR)
git_dir = subprocess.run(['git rev-parse --git-dir'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True, shell=True)
if git_dir.stderr:
print("Not a git repo")
exit()
git_signing = subprocess.run(['git config commit.gpgsign false'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True, shell=True)
if git_signing.stderr:
print(git_signing.stderr)
exit()
def commit(date):
commit_init()
message = float.hex(time.time())
with open('file', "w") as f:
f.write(message)
git_stage = subprocess.run(['git add .'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
if git_stage.stderr:
print(git_stage.stderr)
exit()
else:
print("Staged!" + str(date))
git_commit = subprocess.run([f'git commit --author="{USERFULLNAME} <{USEREMAIL}>" -m "{message}"'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
if git_commit.stderr:
print(git_commit.stderr)
exit()
else:
print("Commited!" + str(date))
commit_time = f"{date.year}-{date.month}-{date.day} 12:00:00"
git_ammend = subprocess.run([f'git commit --amend --no-edit --date="{commit_time}"'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
if git_ammend.stderr:
print(git_ammend.stderr)
exit()
else:
print("Ammended!" + str(date))
print()