44from pathlib import Path
55from yaml import safe_load
66from yaml import YAMLError
7+ from os import system
78
89# conventions imports
910from conventions .karma_angular import angular_convention
1516from utils import parser_cli
1617from utils import create_file
1718from utils import debug
19+ from utils import get_text
20+ from utils import get_context
21+ from utils import gen_co_author
1822
1923
2024def main (debug_mode = False ):
@@ -29,36 +33,56 @@ def main(debug_mode=False):
2933 convention = str (config ['convention' ]).lower ()
3034 else :
3135 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+
4357 except YAMLError as exc :
4458 print (exc )
4559
4660 elif args .convention is not '' :
4761 convention = str (args .convention )
4862 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 ()
6066 create_file ('none' , args .no_file )
6167
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+
6286 else :
6387 debug ('parser full return' , parser .parse_args (), debug_mode )
6488 parser .print_help ()
0 commit comments