Skip to content

Commit ea3ecce

Browse files
committed
refactor(commit): change type of write_message_to_file to path
1 parent 4e28075 commit ea3ecce

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

commitizen/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import logging
33
import sys
4+
from pathlib import Path
45
from functools import partial
56
from types import TracebackType
67
from typing import List
@@ -64,6 +65,7 @@
6465
},
6566
{
6667
"name": "--write-message-to-file",
68+
"type": Path,
6769
"metavar": "FILE_PATH",
6870
"help": "write message to file before commiting (can be combined with --dry-run)",
6971
},

commitizen/commands/commit.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ def __call__(self):
6969
if git.is_staging_clean() and not dry_run:
7070
raise NothingToCommitError("No files added to staging!")
7171

72-
if write_message_to_file is not None:
73-
if not isinstance(write_message_to_file, str):
74-
raise NotAllowed(
75-
"Commit message file name is broken.\n"
76-
"Check the flag `--write-message-to-file` in the terminal"
77-
)
72+
if write_message_to_file is not None and write_message_to_file.is_dir():
73+
raise NotAllowed(f"{write_message_to_file} is a directory")
7874

7975
retry: bool = self.arguments.get("retry")
8076

hooks/prepare-commit-msg.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)