Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions giticket/giticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def main(argv=None):
default=underscore_split_mode,
choices=[underscore_split_mode, regex_match_mode])
args = parser.parse_args(argv)
if not args.conventionalcommits and not args.format:
parser.error('You must provide --format if not using --conventionalcommits')
if not args.conventionalcommits and not args.format and not args.to_trailer:
parser.error('You must provide --format if not using --conventionalcommits and not --to_trailer')
return 1
regex = args.regex or r'[A-Z]+-\d+' # noqa
format_string = args.format or '{ticket} {commit_msg}' # noqa
Expand Down
16 changes: 16 additions & 0 deletions tests/test_giticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,19 @@ def test_main(mock_update_commit_message, mock_argparse):
True,
0,
False)


@mock.patch(TESTING_MODULE + '.update_commit_message')
def test_main_to_trailer_only_is_allowed(mock_update_commit_message):
main(['foo.txt', '--to_trailer'])
mock_update_commit_message.assert_called_once_with('foo.txt', r'[A-Z]+-\d+',
'underscore_split',
'{ticket} {commit_msg}',
False,
0,
True)


def test_main_errors_without_format_or_conventionalcommits_or_to_trailer():
with pytest.raises(SystemExit):
main(['foo.txt'])
Loading