File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
2- import os
3- import tempfile
42from pathlib import Path
53
4+ try :
5+ from commitizen .cz .utils import get_backup_file_path
6+ except ImportError as error :
7+ print ("could not import commitizen:" )
8+ print (error )
9+ exit (1 )
10+
611
712def post_commit ():
8- backup_file = Path (
9- tempfile .gettempdir (), f"cz.commit{ os .environ .get ('USER' , '' )} .backup"
10- )
13+ backup_file = Path (get_backup_file_path ())
1114
1215 # remove backup file if it exists
1316 if backup_file .is_file ():
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
2- import os
32import shutil
43import subprocess
54import sys
6- import tempfile
75from pathlib import Path
86from subprocess import CalledProcessError
97
8+ try :
9+ from commitizen .cz .utils import get_backup_file_path
10+ except ImportError as error :
11+ print ("could not import commitizen:" )
12+ print (error )
13+ exit (1 )
1014
11- def prepare_commit_msg (commit_msg_file : Path ) -> int :
12- # check that commitizen is installed
13- if shutil .which ("cz" ) is None :
14- print ("commitizen is not installed!" )
15- return 0
1615
16+ def prepare_commit_msg (commit_msg_file : Path ) -> int :
1717 # check if the commit message needs to be generated using commitizen
1818 if (
1919 subprocess .run (
@@ -27,9 +27,7 @@ def prepare_commit_msg(commit_msg_file: Path) -> int:
2727 ).returncode
2828 != 0
2929 ):
30- backup_file = Path (
31- tempfile .gettempdir (), f"cz.commit{ os .environ .get ('USER' , '' )} .backup"
32- )
30+ backup_file = Path (get_backup_file_path ())
3331
3432 if backup_file .is_file ():
3533 # confirm if commit message from backup file should be reused
You can’t perform that action at this time.
0 commit comments