X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/4d5f24159d7b9048bdb635899363a15277aa8c48..7bc450adac529e07b594f2b38d268c056563ac9e:/python/invirt/builder.py diff --git a/python/invirt/builder.py b/python/invirt/builder.py index f2cb421..68d56c8 100644 --- a/python/invirt/builder.py +++ b/python/invirt/builder.py @@ -28,7 +28,7 @@ def getRepo(package): """Return the path to the git repo for a given package.""" 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 such as submitting a package like '../prod/...git'. Also ensures that @@ -42,6 +42,14 @@ def ensureValidRepo(package): 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): """Map a pocket in the configuration to a git branch.""" return getattr(getattr(config.build.pockets, pocket), 'git', pocket) @@ -98,7 +106,7 @@ def validateBuild(pocket, package, commit): another pocket, then this function returns that pocket. Otherwise, it returns True. """ - ensureValidRepo(package) + ensureValidPackage(package) package_repo = getRepo(package) new_version = getVersion(package, commit)