~edwargix/git.sr.ht

5f60b49c89e42709180be5f29d2a7c61bb5e36d8 — Peter Grayson 7 years ago ee3bcdc
Manifest files in .builds must use .yml or .yaml

Only process files (blobs) in the .builds directory as manifests that use
either '.yml' or '.yaml' extensions.

This allows other files without YAML extensions to exist in this directory.
One use case for a non-YAML file would be a README file.

Limiting manifests to just files with YAML extensions may also aid in
future extensibility.

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
1 files changed, 10 insertions(+), 5 deletions(-)

M gitsrht/worker.py
M gitsrht/worker.py => gitsrht/worker.py +10 -5
@@ 45,11 45,16 @@ def submit_builds(repo, git_repo, commit):
    elif ".builds"  in commit.tree:
        build_dir = commit.tree[".builds"]
        if build_dir.type == 'tree':
            build_dir = git_repo.get(build_dir.id)
            for blob in build_dir:
                if blob.type != "blob":
                    continue
                manifests[blob.name] = blob
            manifests.update(
                {
                    blob.name: blob
                    for blob in git_repo.get(build_dir.id)
                    if blob.type == 'blob' and (
                        blob.name.endswith('.yml')
                        or blob.name.endswith('.yaml')
                    )
                }
            )
    if not any(manifests):
        return
    for name, blob in iter(manifests.items()):