-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_commit.py
50 lines (42 loc) · 1.31 KB
/
git_commit.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
import subprocess
import os
import sys
from celerymanagementapp.util import cma_minifier
def start():
minify_js()
success = True
if "--no-tests" not in sys.argv:
success = run_tests()
if success:
commit()
if "--no-pull" not in sys.argv:
pull()
if "--no-tests" not in sys.argv:
success = run_tests()
if "--no-push" not in sys.argv and success:
push()
def minify_js():
minified = cma_minifier.run()
if not minified:
print "There was an error during minification. Skipping this test."
def run_tests():
current_dir = os.getcwd()
output = subprocess.Popen(["python manage.py test celerymanagementapp"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()
if output[1].find("FAILED") != -1:
print output[1]
return False
else:
print output[1]
return True
def pull():
subprocess.call("git pull", shell=True)
def push():
subprocess.call("git push", shell=True)
def commit():
if '-m' in sys.argv:
index = sys.argv.index('-m')
subprocess.call("git commit -m \'" + sys.argv[index+1] + '\' -a', shell=True)
else:
subprocess.call("git commit -a", shell=True)
if __name__ == "__main__":
start()