uuid.uuid4()))
try:
+ # TODO: clean up this interface.
+ b.ensureValidPackage(package)
+ commit = b.canonicalize_commit(package, commit)
b.validateBuild(pocket, package, commit)
except b.InvalidBuild, e:
print >>sys.stderr, "E: %s" % e
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))
"""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
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)
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)