Skip to content

Commit 62259fe

Browse files
authored
merge(#12): refacts and cleansed code
Code cleaning
2 parents efafe5c + 34cbf0b commit 62259fe

File tree

11 files changed

+40
-65
lines changed

11 files changed

+40
-65
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Just follow the commands below:
2020
# make sure you have the dependencies installed in your machine and
2121
# have git ready to use
2222

23-
$ apt install python3-pip git
23+
$ sudo apt install python3-pip git
2424

2525
$ pip3 install pyyaml
2626

conventions/__init__.py

Whitespace-only changes.

conventions/changelog.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from os import system
2+
from utils import get_text
3+
4+
def changelog_convention():
5+
tag, msg = get_text()
6+
tag = tag.upper()
7+
system("git commit -m '%s: %s'" % (tag, msg))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# FUTURE: implement
2+
def custom_convention():
3+
pass

conventions/karma_angular.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from os import system
2+
from utils import get_text
3+
4+
def angular_convention():
5+
tag, msg, context = get_text(context=True)
6+
tag = tag.lower()
7+
system("git commit -m '%s(%s): %s'" % (tag, context, msg))

conventions/no_convention.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from os import system
2+
from utils import get_text
3+
4+
def just_message():
5+
msg = str(input("commit message: "))
6+
system("git commit -m '%s'" % msg.capitalize())

conventions/symphony_cmf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from os import system
2+
from utils import get_text
3+
4+
def symphony_convention():
5+
tag, msg = get_text()
6+
tag = tag.capitalize()
7+
system("git commit -m '[%s] %s'" % (tag, msg))

generator.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,24 @@
22
from yaml import safe_load
33
from yaml import YAMLError
44

5-
from utils import run_config
6-
from utils import angular_convention
7-
from utils import changelog_convention
8-
from utils import symphony_convention
9-
from utils import just_message
10-
from utils import create_file
5+
# conventions imports
6+
from conventions.karma_angular import angular_convention
7+
from conventions.changelog import changelog_convention
8+
from conventions.symphony_cmf import symphony_convention
9+
from conventions.no_convention import just_message
1110

12-
tag = ''
13-
tag_is_lowercase = False
14-
tag_is_uppercase = False
15-
tag_is_capitalized = False
16-
convention = ''
11+
from utils import create_file
1712

1813
file_path = Path('commiter.yml')
19-
2014
if file_path.is_file():
2115
with open(str(file_path), 'r') as stream:
2216
try:
2317
config = safe_load(stream)
24-
tag, tag_is_capitalized, tag_is_lowercase, tag_is_uppercase, convention = run_config(config, tag, tag_is_capitalized, tag_is_lowercase, tag_is_uppercase, convention)
25-
if convention == 'angular':
18+
convention = str(config['convention']).lower() if config['convention'] != None else ''
19+
if convention == 'angular' or convention == 'karma':
2620
print('You are using the %s convention' % convention)
2721
angular_convention()
28-
elif convention == 'changelog':
22+
elif convention == 'changelog':
2923
print('You are using the %s convention' % convention)
3024
changelog_convention()
3125
elif convention == 'symphony':
@@ -37,7 +31,6 @@
3731
custom_convention()
3832
except YAMLError as exc:
3933
print(exc)
40-
4134
else:
4235
print("No config files found!\nRunning default script...")
4336
opt = int(input("""

test/__init__.py

Whitespace-only changes.

test/test.py

Whitespace-only changes.

0 commit comments

Comments
 (0)