[scripts] commit-to-changelog fails if git fails
authorMark Probst <mark.probst@gmail.com>
Wed, 4 Aug 2010 21:40:47 +0000 (23:40 +0200)
committerMark Probst <mark.probst@gmail.com>
Wed, 4 Aug 2010 22:01:27 +0000 (00:01 +0200)
The commit-to-changelog script now fails if git fails for whatever
reason.  The most important reasons would be that git isn't installed,
and that the script is called without a repository.

scripts/commits-to-changelog.py

index ba68a6f67e807c81b0b6060600a01fc4795e3fc2..744528fffb1f673cdbdd496465224976af86b334 100755 (executable)
@@ -6,6 +6,7 @@ import re
 import os.path
 import fnmatch
 import os
+import sys
 
 # subtract 8 for the leading tabstop
 fill_column = 74 - 8
@@ -15,7 +16,12 @@ path_to_root = None
 all_changelogs = {}
 
 def git (command, *args):
-    return subprocess.Popen (["git", command] + list (args), stdout = subprocess.PIPE).communicate () [0]
+    popen = subprocess.Popen (["git", command] + list (args), stdout = subprocess.PIPE)
+    output = popen.communicate () [0]
+    if popen.returncode != 0:
+        print >> sys.stderr, "Error: git failed"
+        exit (1)
+    return output
 
 def changelog_path (changelog):
     global path_to_root