def delete_old_builds(history):
''' Auto delete unnecessary build directories from the filesystem. '''
build_path = get_release_dir()
kept_builds = map(lambda x: get_build_name(x['id']), history['builds'])
found_builds = fs.glob(build_path)
to_be_deleted_builds = [x for x in found_builds if x not in kept_builds]
deletion_count = len(to_be_deleted_builds)
# Skip, if there are no builds to be deleted.
if deletion_count == 0:
return
# Remove directories to be deleted.
with cd(build_path):
fs.rm_rf(to_be_deleted_builds)
remote_info(
'Deleted {} old build(s) from the remote'.format(deletion_count)
)
评论列表
文章目录