-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.py
32 lines (26 loc) · 1.08 KB
/
git.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
import subprocess
def init(repopath):
gitprocess = subprocess.run(
['git', '-C', repopath, 'init'])
gitprocess = subprocess.run(
['git', '-C', repopath, 'config', 'user.email', 'null'])
gitprocess = subprocess.run(
['git', '-C', repopath, 'config', 'user.name', 'null'])
stamp(repopath, 'create pki')
def stamp(repopath, msg):
print(repopath)
gitprocess = subprocess.run(
['git', '-C', repopath, 'add', '-A'], encoding='ascii',
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if gitprocess.returncode != 0:
raise Exception()
gitprocess = subprocess.run(
['git', '-C', repopath, 'commit', '--allow-empty', '-a', '-m', msg], encoding='ascii',
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if gitprocess.returncode != 0:
raise Exception()
def abort(repopath):
gitprocess = subprocess.run(['git', '-C', repopath, 'reset', 'HEAD^'], encoding='ascii',
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if gitprocess.returncode != 0:
raise Exception()