Add checkout command.
authorCarl Hetherington <cth@carlh.net>
Sun, 19 Apr 2015 13:29:33 +0000 (14:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 19 Apr 2015 13:29:33 +0000 (14:29 +0100)
cdist

diff --git a/cdist b/cdist
index 8990440d0c5c390574f2843be16e029fa6c260cc..300f308f417e1fbb06e5a498548921c576f78106 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -645,6 +645,7 @@ def main():
         "latest": "print out the latest version",
         "test": "run the project's unit tests",
         "shell": "build the project then start a shell in its chroot",
+        "checkout": "check out the project",
         "revision": "print the head git revision number"
     }
 
@@ -898,6 +899,17 @@ def main():
             print command_and_read('git rev-parse HEAD').readline().strip()[:7]
         target.cleanup()
 
+    elif globals.command == 'checkout':
+
+        if args.output is None:
+            raise Error('you must specify -o or --output')
+
+        target = SourceTarget()
+        tree = globals.trees.get(args.project, args.checkout, target)
+        with TreeDirectory(tree):
+            shutil.copytree('.', args.output)
+        target.cleanup()
+
     else:
         raise Error('invalid command %s' % globals.command)