Split with some tests.
[cdist.git] / cdist / cmd_revision.py
diff --git a/cdist/cmd_revision.py b/cdist/cmd_revision.py
new file mode 100644 (file)
index 0000000..ea5f2ea
--- /dev/null
@@ -0,0 +1,11 @@
+class CmdRevision(object):
+    def __init__(self):
+        self.name = 'revision'
+        self.help = 'print the head git revision number'
+
+    def run(self, args):
+        target = SourceTarget()
+        tree = globals.trees.get(args.project, args.checkout, target)
+        with TreeDirectory(tree):
+            print command_and_read('git rev-parse HEAD').readline().strip()[:7]
+        target.cleanup()