Merge pull request #622 from pre-commit/staged_files_only_patch_dir_does_not_exist

Do not crash in staged_files_only if patch_dir does not exist
This commit is contained in:
Anthony Sottile
2017-09-17 17:03:28 -07:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import time
from pre_commit.util import CalledProcessError
from pre_commit.util import cmd_output
from pre_commit.util import mkdirp
logger = logging.getLogger('pre_commit')
@@ -43,6 +44,7 @@ def staged_files_only(patch_dir):
'Stashing unstaged files to {}.'.format(patch_filename),
)
# Save the current unstaged changes as a patch
mkdirp(patch_dir)
with io.open(patch_filename, 'wb') as patch_file:
patch_file.write(diff_stdout_binary)