File tree Expand file tree Collapse file tree 6 files changed +49
-26
lines changed Expand file tree Collapse file tree 6 files changed +49
-26
lines changed Original file line number Diff line number Diff line change 1
1
from os import system
2
2
from utils import get_text
3
- from utils import change_if_none
3
+ from utils import sanitize_as_empty_string
4
+ from utils import gen_co_author
4
5
5
6
6
- def changelog_convention (co_author = '' ):
7
+ def changelog_convention (co_author ):
7
8
tag , msg = get_text ()
8
9
tag = tag .upper ()
9
- co_author = change_if_none ( co_author )
10
- composed_message = """%s: %s \n \n Co-authored-by: """ % ( tag , msg )
11
- system ("git commit -m '%s%s '" % ( composed_message , co_author ) )
10
+ composed_message = "%s: %s \n " % ( tag , msg )
11
+ composed_message += gen_co_author ( co_author )
12
+ system ("git commit -m '%s'" % composed_message )
Original file line number Diff line number Diff line change 1
1
from os import system
2
2
from utils import get_text
3
- from utils import change_if_none
3
+ from utils import sanitize_as_empty_string
4
+ from utils import gen_co_author
4
5
5
6
6
- def angular_convention (co_author = '' ):
7
+ def angular_convention (co_author ):
7
8
tag , msg , context = get_text (context = True )
8
9
tag = tag .lower ()
9
- co_author = change_if_none (co_author )
10
- composed_message = """%s(%s): %s\n \n Co-authored-by:
11
- """ % (tag , context , msg )
12
- system ('git commit -m "%s%s"' % (composed_message , co_author ))
10
+ co_author = sanitize_as_empty_string (co_author )
11
+ if context is '' :
12
+ composed_message = composed_message = "%s: %s\n " % (tag , msg )
13
+ composed_message = "%s(%s): %s\n " % (tag , context , msg )
14
+ composed_message += gen_co_author (co_author )
15
+ system ('git commit -m "%s"' % composed_message )
Original file line number Diff line number Diff line change 1
1
from os import system
2
- from utils import change_if_none
2
+ from utils import sanitize_as_empty_string
3
+ from utils import gen_co_author
3
4
4
5
5
- def just_message (co_author = '' ):
6
+ def just_message (co_author ):
6
7
msg = str (input ("commit message: " ))
7
- co_author = change_if_none ( co_author )
8
- composed = """%s \n \n Co-authored-by: """ % msg . capitalize ( )
9
- system ("git commit -m '%s%s '" % ( composed , co_author ) )
8
+ composed = "%s \n " % msg . capitalize ( )
9
+ composed += gen_co_author ( co_author )
10
+ system ("git commit -m '%s'" % composed )
Original file line number Diff line number Diff line change 1
1
from os import system
2
2
from utils import get_text
3
- from utils import change_if_none
3
+ from utils import sanitize_as_empty_string
4
+ from utils import gen_co_author
4
5
5
6
6
- def symphony_convention (co_author = '' ):
7
+ def symphony_convention (co_author ):
7
8
tag , msg = get_text ()
8
9
tag = tag .capitalize ()
9
- co_author = change_if_none ( co_author )
10
- composed = """[%s] %s \n \n Co-authored-by: """ % ( tag , msg )
11
- system ("git commit -m '%s%s '" % ( composed , co_author ) )
10
+ composed = "[%s] %s \n " % ( tag , msg )
11
+ composed += gen_co_author ( co_author )
12
+ system ("git commit -m '%s'" % composed )
Original file line number Diff line number Diff line change @@ -37,14 +37,24 @@ def mock_input(s):
37
37
raise AssertionError ()
38
38
39
39
40
- def test_change_if_none ():
40
+ def test_sanitize_as_empty_string ():
41
41
string = 'asopdfha'
42
42
string2 = None
43
- string = utils .change_if_none (string )
44
- string2 = utils .change_if_none (string2 )
43
+ string = utils .sanitize_as_empty_string (string )
44
+ string2 = utils .sanitize_as_empty_string (string2 )
45
45
if not (string == 'asopdfha' and string2 == '' ):
46
46
raise AssertionError ()
47
47
48
+
49
+ def test_gen_co_author ():
50
+ arg = utils .
gen_co_author (
'kiryto <[email protected] >' )
51
+ if not arg == "Co-authored-by: kiryto <[email protected] >" :
52
+ raise AssertionError ()
53
+
54
+ arg2 = utils .gen_co_author ('' )
55
+ if not arg2 == '' :
56
+ raise AssertionError ()
57
+
48
58
# FIXME
49
59
# def test_create_file(tmpdir):
50
60
# test_file = tmpdir.mkdir('test').join('commiter.yml')
Original file line number Diff line number Diff line change 3
3
4
4
supported_conventions = [
5
5
"angular" ,
6
+ "karma" ,
6
7
"changelog" ,
7
8
"symphony" ,
8
9
"message" ,
@@ -23,14 +24,20 @@ def get_text(context=False):
23
24
if context :
24
25
tag = str (input ("type the tag: " ))
25
26
msg = str (input ("type the commit message: " )).lower ()
26
- context = str (input ('type the context: ' )).lower ()
27
+ context = str (input ('type the context: ' ) or '' ).lower ()
27
28
return tag , msg , context
28
29
else :
29
30
tag = str (input ("type the tag: " ))
30
31
msg = str (input ("type the commit message: " )).lower ()
31
32
return tag , msg
32
33
33
34
35
+ def gen_co_author (co_author ):
36
+ if co_author is '' :
37
+ return ''
38
+ return "Co-authored-by: %s" % co_author
39
+
40
+
34
41
def create_file (convention_name , dont_create = False ):
35
42
if not dont_create :
36
43
data = dict (
@@ -62,7 +69,7 @@ def parser_cli():
62
69
return parser
63
70
64
71
65
- def change_if_none (string ):
72
+ def sanitize_as_empty_string (string ):
66
73
if string is None :
67
74
return ''
68
75
return string
You can’t perform that action at this time.
0 commit comments