Index: trunk/packages/invirt-dev/invirt-submit-build
===================================================================
--- trunk/packages/invirt-dev/invirt-submit-build	(revision 3034)
+++ trunk/packages/invirt-dev/invirt-submit-build	(revision 3035)
@@ -42,4 +42,7 @@
 
     try:
+        # TODO: clean up this interface.
+        b.ensureValidPackage(package)
+        commit = b.canonicalize_commit(package, commit)
         b.validateBuild(pocket, package, commit)
     except b.InvalidBuild, e:
Index: trunk/packages/invirt-dev/invirtibuilder
===================================================================
--- trunk/packages/invirt-dev/invirtibuilder	(revision 3034)
+++ trunk/packages/invirt-dev/invirtibuilder	(revision 3035)
@@ -289,9 +289,9 @@
         try:
             db.failed_stage = 'validating job'
-            src = b.validateBuild(pocket, package, commit)
             # Don't expand the commit in the DB until we're sure the user
             # isn't trying to be tricky.
-            db.commit = commit = c.captureOutput(['git', 'rev-parse', commit],
-                                                 cwd=b.getRepo(package)).strip()
+            b.ensureValidPackage(package)
+            db.commit = commit = b.canonicalize_commit(package, commit)
+            src = b.validateBuild(pocket, package, commit)
 
             db.version = str(b.getVersion(package, commit))
Index: trunk/packages/invirt-dev/python/invirt/builder.py
===================================================================
--- trunk/packages/invirt-dev/python/invirt/builder.py	(revision 3034)
+++ trunk/packages/invirt-dev/python/invirt/builder.py	(revision 3035)
@@ -29,5 +29,5 @@
     return os.path.join(_REPO_DIR, 'invirt/packages', '%s.git' % package)
 
-def ensureValidRepo(package):
+def ensureValidPackage(package):
     """Perform some basic sanity checks that the requested repo is in a
     subdirectory of _REPO_DIR/invirt/packages.  This prevents weirdness
@@ -42,4 +42,12 @@
     elif not os.path.exists(repo):
         raise InvalidBuild('Nonexisting package %s' % package)
+
+def canonicalize_commit(package, commit, shorten=False):
+    if shorten:
+        flags = ['--short']
+    else:
+        flags = []
+    return c.captureOutput(['git', 'rev-parse'] + flags + [commit],
+                           cwd=getRepo(package)).strip()
 
 def pocketToGit(pocket):
@@ -99,5 +107,5 @@
     it returns True.
     """
-    ensureValidRepo(package)
+    ensureValidPackage(package)
     package_repo = getRepo(package)
     new_version = getVersion(package, commit)
