[damned-lies] Try recovering from frequent -25 command failures



commit a03954370283ac2fd6d157b4cfb2d249fc9a729f
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon Jun 4 17:28:40 2018 +0200

    Try recovering from frequent -25 command failures

 common/utils.py | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/common/utils.py b/common/utils.py
index d6d89040..f7948728 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -42,6 +42,12 @@ def run_shell_command(cmd, input_data=None, raise_on_error=False, env=None,
     status = pipe.returncode
     logging.debug(output + errout)
     if raise_on_error and status != STATUS_OK:
+        is_git_command = cmd.startswith('git') if isinstance(cmd, str) else cmd[0] == 'git'
+        if is_git_command and status == -25:
+            # Try to reset the git repository to an usable state
+            run_shell_command(['rm', '.git/index.lock'], cwd=cwd)
+            run_shell_command(['git', 'clean', '-dfq'], cwd=cwd)
+            run_shell_command(['git', 'reset', '--hard'], cwd=cwd)
         raise OSError(
             status,
             'Command: "%s", Error: %s' % (cmd, errout.decode('utf-8') if errout else output)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]