Skip to content

Commit 05c0c2b

Browse files
authored
Merge branch 'master' into install-script
2 parents 2ef50a1 + 3134567 commit 05c0c2b

File tree

3 files changed

+59
-43
lines changed

3 files changed

+59
-43
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Just follow the commands below:
3232
$ pip3 install -r ~/.commit-helper/requirements.txt
3333

3434
# create a function in your .bashrc
35-
$ echo "commit(){ python3 ~/.commit-helper/generator.py; }" >> ~/.bashrc
35+
$ echo "alias commit='python3 ~/.commit-helper/generator.py'" >> ~/.bashrc
3636

3737
# reload terminal
3838
$ source ~/.bashrc
@@ -108,4 +108,3 @@ Supported conventions available:
108108
| **Name** | **Username** |
109109
| :------: | :----------: |
110110
| Arthur José Benedito de Oliveira Assis | @arthur120496 |
111-

generator.py

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,58 @@
1414
# utils imports
1515
from utils import parser_cli
1616
from utils import create_file
17+
from utils import debug
1718

1819

20+
def main(debug_mode=False):
21+
file_path = Path('commiter.yml')
22+
debug('file_path', file_path, debug_mode)
23+
if file_path.is_file():
24+
with open(str(file_path), 'r') as stream:
25+
try:
26+
config = safe_load(stream)
27+
debug('convention from file', config['convention'], debug_mode)
28+
if config['convention'] is not None:
29+
convention = str(config['convention']).lower()
30+
else:
31+
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)
43+
except YAMLError as exc:
44+
print(exc)
45+
46+
elif args.convention is not '':
47+
convention = str(args.convention)
48+
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)
60+
create_file('none', args.no_file)
61+
62+
else:
63+
debug('parser full return', parser.parse_args(), debug_mode)
64+
parser.print_help()
65+
66+
67+
debug_option = False
1968
parser = parser_cli()
2069
args = parser.parse_args()
21-
22-
file_path = Path('commiter.yml')
23-
if file_path.is_file():
24-
with open(str(file_path), 'r') as stream:
25-
try:
26-
config = safe_load(stream)
27-
if config['convention'] is not None:
28-
convention = str(config['convention']).lower()
29-
else:
30-
convention = 'none'
31-
if convention == 'angular' or convention == 'karma':
32-
print('You are using the %s convention' % convention)
33-
angular_convention(args.co_author)
34-
elif convention == 'changelog':
35-
print('You are using the %s convention' % convention)
36-
changelog_convention(args.co_author)
37-
elif convention == 'symphony':
38-
print('You are using the %s convention' % convention)
39-
symphony_convention(args.co_author)
40-
elif convention == 'none':
41-
just_message(args.co_author)
42-
except YAMLError as exc:
43-
print(exc)
44-
45-
elif args.convention is not '':
46-
convention = str(args.convention)
47-
if convention == 'angular' or convention == 'karma':
48-
angular_convention(args.co_author)
49-
create_file(convention, args.no_file)
50-
elif convention == 'changelog':
51-
changelog_convention(args.co_author)
52-
create_file(convention, args.no_file)
53-
elif convention == 'symphony':
54-
symphony_convention(args.co_author)
55-
create_file(convention, args.no_file)
56-
elif convention == 'message':
57-
just_message(convention)
58-
create_file('none', args.no_file)
59-
60-
else:
61-
parser.print_help()
70+
debug('args variable', args, debug_option)
71+
main(debug_option)

utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ def change_if_none(string):
6464
if string is None:
6565
return ''
6666
return string
67+
68+
69+
def debug(message, value, show=False):
70+
if show:
71+
print("\n-------DEBUG--------")
72+
print("%s: %s" % (message, value))
73+
print("--------END---------\n")

0 commit comments

Comments
 (0)