Skip to content

Commit fda915f

Browse files
committed
add(co-author): implemented the co-author support
Co-authored-by: None
1 parent 1e01d38 commit fda915f

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

conventions/changelog.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from utils import get_text
33

44

5-
def changelog_convention():
5+
def changelog_convention(co_author=''):
66
tag, msg = get_text()
77
tag = tag.upper()
8-
system("git commit -m '%s: %s'" % (tag, msg))
8+
composed_message = """%s: %s\n\nCo-authored-by: """ % (tag, context)
9+
system("git commit -m '%s%s'" % (composed_message, co_author))
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# FUTURE: implement
2-
def custom_convention():
3-
pass
2+
# def custom_convention():
3+
# pass

conventions/karma_angular.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from utils import get_text
33

44

5-
def angular_convention():
5+
def angular_convention(co_author=''):
66
tag, msg, context = get_text(context=True)
77
tag = tag.lower()
8-
system("git commit -m '%s(%s): %s'" % (tag, context, msg))
8+
composed_message = """%s(%s): %s\n\nCo-authored-by:
9+
""" % (tag, context, msg)
10+
system('git commit -m "%s%s"' % (composed_message, co_author))

conventions/no_convention.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from os import system
22

33

4-
def just_message():
4+
def just_message(co_author=''):
55
msg = str(input("commit message: "))
6-
system("git commit -m '%s'" % msg.capitalize())
6+
composed = """%s\n\nCo-authored-by: """ % msg.capitalize()
7+
system("git commit -m '%s%s'" % (composed, co_author))

conventions/symphony_cmf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from utils import get_text
33

44

5-
def symphony_convention():
5+
def symphony_convention(co_author=''):
66
tag, msg = get_text()
77
tag = tag.capitalize()
8-
system("git commit -m '[%s] %s'" % (tag, msg))
8+
composed = """[%s] %s\n\nCo-authored-by: """ % (tag, msg)
9+
system("git commit -m '%s%s'" % (composed, co_author))

generator.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
from conventions.no_convention import just_message
1313

1414
# utils imports
15-
from utils import create_file
1615
from utils import menu
1716
from utils import parser_cli
17+
from utils import create_file
18+
from utils import supported_conventions
1819

1920

2021
parser = parser_cli()
22+
args = parser.parse_args()
2123

2224
file_path = Path('commiter.yml')
2325
if file_path.is_file():
@@ -30,33 +32,33 @@
3032
convention = 'none'
3133
if convention == 'angular' or convention == 'karma':
3234
print('You are using the %s convention' % convention)
33-
angular_convention()
35+
angular_convention(args.co_author)
3436
elif convention == 'changelog':
3537
print('You are using the %s convention' % convention)
36-
changelog_convention()
38+
changelog_convention(args.co_author)
3739
elif convention == 'symphony':
3840
print('You are using the %s convention' % convention)
39-
symphony_convention()
41+
symphony_convention(args.co_author)
4042
elif convention == 'none':
41-
just_message()
43+
just_message(args.co_author)
4244
except YAMLError as exc:
4345
print(exc)
4446
else:
4547
print("No config files found!\nRunning default script...")
4648
opt = int(input(menu) or 4)
4749
if opt == 1:
4850
print("You're using the angular convention")
49-
angular_convention()
51+
angular_convention(parser.co_author)
5052
create_file('angular')
5153
elif opt == 2:
5254
print("You're using the changelog convention")
53-
changelog_convention()
55+
changelog_convention(args.co_author)
5456
create_file('changelog')
5557
elif opt == 3:
5658
print("You're using the symphony convention")
57-
symphony_convention()
59+
symphony_convention(args.co_author)
5860
create_file('symphony')
5961
elif opt == 4:
6062
print("You're not using a convention")
61-
just_message()
63+
just_message(args.co_author)
6264
create_file('none')

test/test_conventions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# import convention.symphony_cmf as symphony
55
# import conventions.no_convention as no_convention
66

7+
78
def test_angular_convention():
89
pass
910

utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010

1111
menu = """
12-
what type of commit convention are you using?
12+
What type of commit convention are you using?
1313
1414
default: Just the message
1515
1: Karma/Angular
@@ -18,6 +18,7 @@
1818
1919
"""
2020

21+
2122
def get_text(context=False):
2223
if context:
2324
tag = str(input("type the tag: "))
@@ -46,7 +47,7 @@ def parser_cli():
4647
parser.add_argument("--no-generate", dest="no_file",
4748
help="disables the creation of a commiter.yml file",
4849
default=True, type=bool)
49-
parser.add_argument('--convention', choices=supported_conventions,
50+
parser.add_argument("--convention", choices=supported_conventions,
5051
dest="convention",
5152
help="selects a convention to be used for the commit")
52-
parser.parse_args()
53+
return parser

0 commit comments

Comments
 (0)