|
1 | 1 | import os
|
2 | 2 |
|
3 |
| -opt = int(input(""" |
4 |
| -what type of commit convention are you using? |
| 3 | +from pathlib import Path |
| 4 | +from yaml import safe_load |
| 5 | +from yaml import YAMLError |
5 | 6 |
|
6 |
| -1- Karma/Angular |
7 |
| -2- Conventional changelog |
8 |
| -3- Symfony CMF |
9 |
| -""")) |
| 7 | +from utils import run_config |
| 8 | +from utils import angular_convention |
| 9 | +from utils import changelog_convention |
| 10 | +from utils import symphony_convention |
10 | 11 |
|
11 |
| -tag = str(input("type the tag: ")) |
12 |
| -msg = str(input("type the commit message: ")).lower() |
| 12 | +tag = '' |
| 13 | +tag_is_lowercase = False |
| 14 | +tag_is_uppercase = False |
| 15 | +tag_is_capitalized = False |
| 16 | +convention = '' |
13 | 17 |
|
14 |
| -if opt == 1: |
15 |
| - context = str(input('type the context: ')).lower() |
16 |
| - tag = tag.lower() |
17 |
| - os.system("git commit -m '%s(%s): %s'" % (tag, context, msg)) |
| 18 | +file_path = Path("commiter.yml") |
18 | 19 |
|
19 |
| -elif opt == 2: |
20 |
| - tag = tag.upper() |
21 |
| - os.system("git commit -m '%s: %s'" % (tag, msg)) |
| 20 | +if file_path.is_file(): |
| 21 | + with open(str(file_path), 'r') as stream: |
| 22 | + try: |
| 23 | + 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 != '' or convention != 'custom': |
| 26 | + if convention == 'angular': |
| 27 | + print('You are using the %s convention' % convention) |
| 28 | + angular_convention() |
| 29 | + elif convention == 'changelog': |
| 30 | + print('You are using the %s convention' % convention) |
| 31 | + changelog_convention() |
| 32 | + elif convention == 'symphony': |
| 33 | + print('You are using the %s convention' % convention) |
| 34 | + symphony_convention() |
| 35 | + else: |
| 36 | + custom_convention() |
| 37 | + except YAMLError as exc: |
| 38 | + print(exc) |
22 | 39 |
|
23 |
| -elif opt == 3: |
24 |
| - tag = tag.capitalize() |
25 |
| - os.system("git commit -m '[%s] %s'" % (tag, msg)) |
| 40 | +else: |
| 41 | + print("No config files found!\nRunning default script...") |
| 42 | + opt = int(input(""" |
| 43 | + what type of commit convention are you using? |
| 44 | +
|
| 45 | + 1- Karma/Angular |
| 46 | + 2- Conventional changelog |
| 47 | + 3- Symfony CMF |
| 48 | + """)) |
| 49 | + |
| 50 | + if opt == 1: |
| 51 | + angular_convention() |
| 52 | + elif opt == 2: |
| 53 | + changelog_convention() |
| 54 | + elif opt == 3: |
| 55 | + symphony_convention() |
0 commit comments