From c439340bec24e4e2b79fca78cd5635f53f1f055e Mon Sep 17 00:00:00 2001 From: David Meybohm Date: Sun, 25 Mar 2018 14:29:50 -0400 Subject: [PATCH] Check for errors and skip commit hooks --- editorconfig_git_preserve_history/git.py | 2 +- editorconfig_git_preserve_history/main.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/editorconfig_git_preserve_history/git.py b/editorconfig_git_preserve_history/git.py index 11d0e06..f8d03b5 100644 --- a/editorconfig_git_preserve_history/git.py +++ b/editorconfig_git_preserve_history/git.py @@ -38,7 +38,7 @@ def impersonate_and_write_commit(self, files: List[str]) -> None: impersonator_name = run(['git', 'config', 'user.name'])[0] message = self.message + "\n\nOriginal-Commit: " + self.commit + "\n" + \ "Impersonator: {} <{}>".format(impersonator_name, impersonator_email) - args = ['git', 'commit', '--date', self.date, '--author', self.author, + args = ['git', 'commit', '-n', '--date', self.date, '--author', self.author, '--message', message] run(args + files) diff --git a/editorconfig_git_preserve_history/main.py b/editorconfig_git_preserve_history/main.py index fdf4cd1..dc74c1c 100644 --- a/editorconfig_git_preserve_history/main.py +++ b/editorconfig_git_preserve_history/main.py @@ -68,7 +68,11 @@ def find_and_write_commits(): change_file, line_numbers) with open(change_file, 'wb') as f: - f.write(new_contents) + try: + f.write(new_contents) + except IOError as e: + print("Error writing "+change_file) + raise e gitinfo.impersonate_and_write_commit(change.files())