Skip to content

Commit

Permalink
add(co-author): implemented the co-author support
Browse files Browse the repository at this point in the history
Co-authored-by:
None
  • Loading branch information
andre-filho committed Oct 6, 2018
1 parent 1e01d38 commit fda915f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
5 changes: 3 additions & 2 deletions conventions/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from utils import get_text


def changelog_convention():
def changelog_convention(co_author=''):
tag, msg = get_text()
tag = tag.upper()
system("git commit -m '%s: %s'" % (tag, msg))
composed_message = """%s: %s\n\nCo-authored-by: """ % (tag, context)
system("git commit -m '%s%s'" % (composed_message, co_author))
4 changes: 2 additions & 2 deletions conventions/custom_convention_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# FUTURE: implement
def custom_convention():
pass
# def custom_convention():
# pass
6 changes: 4 additions & 2 deletions conventions/karma_angular.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from utils import get_text


def angular_convention():
def angular_convention(co_author=''):
tag, msg, context = get_text(context=True)
tag = tag.lower()
system("git commit -m '%s(%s): %s'" % (tag, context, msg))
composed_message = """%s(%s): %s\n\nCo-authored-by:
""" % (tag, context, msg)
system('git commit -m "%s%s"' % (composed_message, co_author))
5 changes: 3 additions & 2 deletions conventions/no_convention.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import system


def just_message():
def just_message(co_author=''):
msg = str(input("commit message: "))
system("git commit -m '%s'" % msg.capitalize())
composed = """%s\n\nCo-authored-by: """ % msg.capitalize()
system("git commit -m '%s%s'" % (composed, co_author))
5 changes: 3 additions & 2 deletions conventions/symphony_cmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from utils import get_text


def symphony_convention():
def symphony_convention(co_author=''):
tag, msg = get_text()
tag = tag.capitalize()
system("git commit -m '[%s] %s'" % (tag, msg))
composed = """[%s] %s\n\nCo-authored-by: """ % (tag, msg)
system("git commit -m '%s%s'" % (composed, co_author))
20 changes: 11 additions & 9 deletions generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
from conventions.no_convention import just_message

# utils imports
from utils import create_file
from utils import menu
from utils import parser_cli
from utils import create_file
from utils import supported_conventions


parser = parser_cli()
args = parser.parse_args()

file_path = Path('commiter.yml')
if file_path.is_file():
Expand All @@ -30,33 +32,33 @@
convention = 'none'
if convention == 'angular' or convention == 'karma':
print('You are using the %s convention' % convention)
angular_convention()
angular_convention(args.co_author)
elif convention == 'changelog':
print('You are using the %s convention' % convention)
changelog_convention()
changelog_convention(args.co_author)
elif convention == 'symphony':
print('You are using the %s convention' % convention)
symphony_convention()
symphony_convention(args.co_author)
elif convention == 'none':
just_message()
just_message(args.co_author)
except YAMLError as exc:
print(exc)
else:
print("No config files found!\nRunning default script...")
opt = int(input(menu) or 4)
if opt == 1:
print("You're using the angular convention")
angular_convention()
angular_convention(parser.co_author)
create_file('angular')
elif opt == 2:
print("You're using the changelog convention")
changelog_convention()
changelog_convention(args.co_author)
create_file('changelog')
elif opt == 3:
print("You're using the symphony convention")
symphony_convention()
symphony_convention(args.co_author)
create_file('symphony')
elif opt == 4:
print("You're not using a convention")
just_message()
just_message(args.co_author)
create_file('none')
1 change: 1 addition & 0 deletions test/test_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# import convention.symphony_cmf as symphony
# import conventions.no_convention as no_convention


def test_angular_convention():
pass

Expand Down
7 changes: 4 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]

menu = """
what type of commit convention are you using?
What type of commit convention are you using?
default: Just the message
1: Karma/Angular
Expand All @@ -18,6 +18,7 @@
"""


def get_text(context=False):
if context:
tag = str(input("type the tag: "))
Expand Down Expand Up @@ -46,7 +47,7 @@ def parser_cli():
parser.add_argument("--no-generate", dest="no_file",
help="disables the creation of a commiter.yml file",
default=True, type=bool)
parser.add_argument('--convention', choices=supported_conventions,
parser.add_argument("--convention", choices=supported_conventions,
dest="convention",
help="selects a convention to be used for the commit")
parser.parse_args()
return parser

0 comments on commit fda915f

Please sign in to comment.