Git processes can be killed using CTRL + C
authorFrederic Massart <fred@moodle.com>
Mon, 14 Apr 2014 02:54:35 +0000 (10:54 +0800)
committerFrederic Massart <fred@moodle.com>
Mon, 14 Apr 2014 02:54:35 +0000 (10:54 +0800)
lib/git.py

index da7ee3b..d3733e3 100644 (file)
@@ -129,12 +129,17 @@ class Git(object):
 
         logging.debug(' '.join(cmd))
 
-        proc = subprocess.Popen(cmd,
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE,
-            cwd=path
-        )
-        (stdout, stderr) = proc.communicate()
+        try:
+            proc = subprocess.Popen(cmd,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.PIPE,
+                cwd=path
+            )
+            (stdout, stderr) = proc.communicate()
+        except KeyboardInterrupt as e:
+            proc.kill()
+            raise e
+
         return (proc.returncode, stdout, stderr)
 
     def fetch(self, remote='', ref=''):