4
4
from pathlib import Path
5
5
from yaml import safe_load
6
6
from yaml import YAMLError
7
+ from os import system
7
8
8
9
# conventions imports
9
10
from conventions .karma_angular import angular_convention
15
16
from utils import parser_cli
16
17
from utils import create_file
17
18
from utils import debug
19
+ from utils import get_text
20
+ from utils import get_context
21
+ from utils import gen_co_author
18
22
19
23
20
24
def main (debug_mode = False ):
@@ -29,36 +33,56 @@ def main(debug_mode=False):
29
33
convention = str (config ['convention' ]).lower ()
30
34
else :
31
35
convention = 'none'
32
- if convention == 'angular' or convention == 'karma' :
33
- print ('You are using the %s convention' % convention )
34
- angular_convention (args .co_author )
35
- elif convention == 'changelog' :
36
- print ('You are using the %s convention' % convention )
37
- changelog_convention (args .co_author )
38
- elif convention == 'symphony' :
39
- print ('You are using the %s convention' % convention )
40
- symphony_convention (args .co_author )
41
- elif convention == 'none' :
42
- just_message (args .co_author )
36
+
37
+ if convention == 'none' :
38
+ commit_message = just_message ()
39
+
40
+ else :
41
+ tag , msg = get_text ()
42
+ if convention == 'angular' or convention == 'karma' :
43
+ print ('You are using the %s convention' % convention )
44
+ context = get_context ()
45
+ commit_message = angular_convention (tag , msg , context )
46
+ elif convention == 'changelog' :
47
+ print ('You are using the %s convention' % convention )
48
+ commit_message = changelog_convention (tag , msg )
49
+ elif convention == 'symphony' :
50
+ print ('You are using the %s convention' % convention )
51
+ commit_message = symphony_convention (tag , msg )
52
+
53
+ commit_message += gen_co_author (args .co_author )
54
+ debug ('commit message' , commit_message , debug_mode )
55
+ system ('git commit -m "%s"' % commit_message )
56
+
43
57
except YAMLError as exc :
44
58
print (exc )
45
59
46
60
elif args .convention is not '' :
47
61
convention = str (args .convention )
48
62
debug ('convention flag' , convention , debug_mode )
49
- if convention == 'angular' or convention == 'karma' :
50
- angular_convention (args .co_author )
51
- create_file (convention , args .no_file )
52
- elif convention == 'changelog' :
53
- changelog_convention (args .co_author )
54
- create_file (convention , args .no_file )
55
- elif convention == 'symphony' :
56
- symphony_convention (args .co_author )
57
- create_file (convention , args .no_file )
58
- elif convention == 'message' :
59
- just_message (convention )
63
+
64
+ if convention == 'message' :
65
+ commit_message = just_message ()
60
66
create_file ('none' , args .no_file )
61
67
68
+ else :
69
+ tag , msg = get_text ()
70
+
71
+ if convention == 'angular' or convention == 'karma' :
72
+ context = get_context ()
73
+ commit_message = angular_convention (tag , msg , context )
74
+ create_file (convention , args .no_file )
75
+ elif convention == 'changelog' :
76
+ commit_message = changelog_convention (tag , msg )
77
+ create_file (convention , args .no_file )
78
+ elif convention == 'symphony' :
79
+ commit_message = symphony_convention (tag , msg )
80
+ create_file (convention , args .no_file )
81
+
82
+ commit_message += gen_co_author (args .co_author )
83
+ debug ('commit message' , commit_message , debug_mode )
84
+ system ('git commit -m "%s"' % commit_message )
85
+
62
86
else :
63
87
debug ('parser full return' , parser .parse_args (), debug_mode )
64
88
parser .print_help ()
0 commit comments