]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/prepare_pristine.py
Make wizard force-add all files in case upstream includes .gitignore files
[wizard.git] / wizard / command / prepare_pristine.py
index 729ebb6586f72ce035dd394ce62d28d0f3896e06..ad660720ed5890ce641ace80c997f68df2b625dd 100644 (file)
@@ -1,6 +1,7 @@
 import urllib
 import shutil
 import os
+import os.path
 
 from wizard import app, command, shell
 
@@ -32,7 +33,11 @@ def main(argv, baton):
             if "/.git" in dirpath: continue
             if not filenames and not dirnames:
                 open(os.path.join(dirpath, ".preserve-dir"), "w").write("")
-        shell.call("git", "add", ".")
+        # stage all changes
+        shell.call("git", "add", "-f", ".")
+        for f in shell.call("git", "ls-files", "-d", "-z")[0].split("\0"):
+            if f != "":
+                shell.call("git", "rm", "--", f)
 
 def parse_args(argv, baton):
     usage = """usage: %prog prepare-pristine APP-VERSION
@@ -56,6 +61,8 @@ local diffs: you can override this safety mechanism with --force.
     return options, args
 
 def check_directory(options):
+    if not os.path.exists(".git"):
+        raise Exception("Not in root directory of Git repository")
     files = shell.eval("git", "ls-files", "-o")
     if files:
         raise Exception("Unversioned files exist, refusing to remove (override with --force)")