Skip to content

Commit f98dcf5

Browse files
feat(test1): PEG111 PEG222 PEG333 test2
test3 BREAKING CHANGE: break1 break2
1 parent 4969236 commit f98dcf5

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

commitizen/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import io
33
import logging
44
import argparse
5-
from pathlib import Path
5+
# from pathlib import Path
66
from configparser import RawConfigParser
77
from commitizen import (registered, run, set_commiter, show_example,
88
show_info, show_schema)
@@ -33,7 +33,10 @@ def get_parser(config):
3333
lscz = subparser.add_parser('ls', help='show available commitizens')
3434
lscz.set_defaults(func=registered)
3535

36-
commit = subparser.add_parser('commit', aliases=['c'],
36+
# commit = subparser.add_parser('commit', aliases=['c'],
37+
# help='create new commit')
38+
39+
commit = subparser.add_parser('commit',
3740
help='create new commit')
3841
commit.set_defaults(func=run)
3942

@@ -55,7 +58,7 @@ def load_cfg():
5558
}
5659
config = RawConfigParser('')
5760

58-
home = str(Path.home())
61+
home = str(os.path.expanduser("~"))
5962
config_file = '.cz'
6063

6164
# load cfg from home folder

commitizen/cz/cz_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
logger = logging.getLogger(__name__)
1111

1212

13-
class BaseCommitizen(metaclass=ABCMeta):
14-
13+
class BaseCommitizen(object):
14+
__metaclass__ = ABCMeta
1515
style = style_from_dict({
1616
Token.Separator: '#6C6C6C',
1717
Token.QuestionMark: '#FF9D00 bold',

commitizen/cz/cz_conventional_changelog.py

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
22
from commitizen.cz.cz_base import BaseCommitizen
3-
3+
import re
4+
import textwrap
45

56
__all__ = ['ConventionalChangelogCz']
67

78

89
class ConventionalChangelogCz(BaseCommitizen):
9-
1010
def questions(self):
1111
questions = [
1212
{
@@ -57,49 +57,75 @@ def questions(self):
5757
{
5858
'type': 'input',
5959
'name': 'scope',
60-
'message': ('Scope. Could be anything specifying place of the '
61-
'commit change (users, db, poll):\n')
60+
'message': ('What is the scope of this change (e.g. component or file name)? (press enter to skip)\n')
6261
},
6362
{
6463
'type': 'input',
6564
'name': 'subject',
66-
'message': ('Subject. Concise description of the changes. '
67-
'Imperative, lower case and no final dot:\n')
65+
'message': ('Write a short, imperative tense description of the change:\n')
6866
},
6967
{
7068
'type': 'input',
7169
'name': 'body',
72-
'message': ('Body. Motivation for the change and contrast this '
73-
'with previous behavior:\n')
70+
'message': ('Provide a longer description of the change: (press enter to skip)\n')
7471
},
7572
{
76-
'type': 'input',
77-
'name': 'footer',
78-
'message': ('Footer. Information about Breaking Changes and '
79-
'reference issues that this commit closes:\n')
73+
'type': 'confirm',
74+
'name': 'isBreaking',
75+
'message': 'Are there any breaking changes?',
76+
'default': False
77+
},
78+
{
79+
"type": "input",
80+
"name": "breaking",
81+
"message": "Describe the breaking changes:\n",
82+
"when": self.is_breaking_answers
83+
},
84+
{
85+
"type": 'confirm',
86+
"name": 'isIssueAffected',
87+
"message": 'Does this change affect any open issues?',
88+
"default": False
89+
},
90+
{
91+
"type": 'input',
92+
"name": 'issues',
93+
"message": 'Add issue refere nces (e.g. "fix #123", "re #123".):\n',
94+
"when": self.is_issued_affected
8095
}
8196
]
8297
return questions
8398

8499
def message(self, answers):
100+
wrapper = textwrap.TextWrapper(width=100)
85101
prefix = answers['prefix']
86102
scope = answers['scope']
103+
issues = ' '.join(wrapper.wrap(answers.get('issues'))) if 'issues' in answers else ''
87104
subject = answers['subject']
88105
body = answers['body']
89-
footer = answers['footer']
106+
# footer = answers['footer']
107+
breaking = answers['breaking'] if 'breaking' in answers else ''
108+
if len(breaking) > 0:
109+
breaking = 'BREAKING CHANGE: ' + re.sub(r'/^BREAKING CHANGE: /', '', breaking)
110+
breaking = ' '.join(wrapper.wrap(breaking))
111+
# breaking = wrapper.fill(breaking)
112+
footer = '{}\n\n'.format(breaking)
90113
message = ''
91114

92115
if prefix:
93116
message += '{0}'.format(prefix)
94117
if scope:
95118
message += '({0})'.format(scope)
96119
message += ': '
120+
if issues:
121+
message += '{} '.format(issues)
97122
if subject:
98123
message += '{0}'.format(subject)
99124
if body:
100125
message += '\n\n{0}'.format(body)
101126
if footer:
102127
message += '\n\n{0}'.format(footer)
128+
print message
103129
return message
104130

105131
def example(self):
@@ -124,3 +150,9 @@ def info(self):
124150
with open(filepath, 'r') as f:
125151
content = f.read()
126152
return content
153+
154+
def is_breaking_answers(self, answers):
155+
return answers.get('isBreaking')
156+
157+
def is_issued_affected(self, answers):
158+
return answers.get('isIssueAffected')

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ def run(self):
8585
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
8686
'License :: OSI Approved :: MIT License',
8787
'Programming Language :: Python',
88-
'Programming Language :: Python :: 3.5',
89-
'Programming Language :: Python :: 3.6',
90-
'Programming Language :: Python :: Implementation :: CPython',
91-
'Programming Language :: Python :: Implementation :: PyPy'
88+
'Programming Language :: Python :: 2.7',
89+
'Programming Language :: Python :: Implementation :: CPython'
9290
],
9391
# $ setup.py publish support.
9492
cmdclass={

0 commit comments

Comments
 (0)