Skip to content

Support packages in subdirs #157

@christopher-dG

Description

@christopher-dG

Starting from Julia 1.5, packages are no longer required to be rooted at the Git repo root.

A couple of things to consider here:

Currently we just look for Project.toml or JuliaProject.toml at the repo root, but now we need to look everywhere for those files.
We can still do that without a Git clone by looking through the Git tree:

head = repo.get_commit("HEAD")
tree = repo.get_git_tree(head.commit.tree.sha, recursive=True)
projects = []
for el in tree.tree:
    parts = el.path.split("/")
    if el.type == "blob" and parts[-1] in ["Project.toml", "JuliaProject.toml"]:
        project = toml.loads(repo.get_contents(el.path).decoded_content.decode())
        if "name" in project and "uuid" in project:
            projects.append({"name": project["name"], "uuid": project["uuid"], "path": "/".join(parts[:-1]}))
return projects

Then we need to check for new versions and make tags for all of these projects.

Conversion of Git tree SHA to commit SHA will have to change, because we're currently looking at each commit's tree SHA which is computed from the root. We'll have to look through the tree for each commit:

for commit in repo.get_commits():
    sha = commit.commit.tree.sha
    if sha == expected:  # Happy path, package is at repo root
        return commit.sha
    tree = repo.get_git_tree(sha, recursive=True)
    for el in tree.tree:
        if el.path == project["path"]:
            if el.sha == expected:
                return commit.sha
            else:  # This commit isn't it, skip to next
                break
return None  # Commit not found

We also need to name tags differently if there are multiple packages, maybe we can just expose a config option for this. We can probably do some nifty templating in the default to get vVERSION for packages at the repo root and PACKAGE-vVERSION otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rewriteWill be done in the Julia rewrite of TagBot (see #55), but not before.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions