Skip to content

Deleting a ref does not work. #426

@adam-arold

Description

@adam-arold

I can query a repo for its refs:

val toDelete = repo.listRefs().asList().filter { it.ref == "refs/heads/$version" || it.ref == "refs/heads/$otherVersion" }

but when I try to delete a ref:

toDelete.forEach {
    it.delete()
}

I get a NullPointerException because root is null within the GHRef for some reason.

What is the proper way of deleting a ref?

A workaround I found is to do this:

toDelete.forEach {
    repo.getRef(it.ref.replace("refs/", "")).delete()
}

This highlights another discrepancy: when I call getRef I have to remove the refs/ part to properly fetch the ref.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions