GunnarFarneback/LocalRegistry.jl

Tagging

GunnarFarneback opened this issue · 2 comments

The Julia registries identify the registered package versions by the tree hashes of their content, which can be retrieved from the package's git repository. Whereas this is all that the Julia package manager needs to know, it's not overly practical for interactive exploration or browsing of the package repository. What you typically want is to have git tags on commits corresponding to the registered tree hashes. LocalRegistry should help with this.

Ideas:

  • Add a function tag to retrospectively add tags corresponding to already registered versions.
  • Add a keyword to register to immediately tag the version being registered.

Design questions:

  • Git supports two different kinds of tags; lightweight and annotated. The latter seems to be the more popular option.
  • Should the tag naming convention be hardcoded or is there any need to have that configurable?

Starting from the documentation rather than the implementation, this is how it may look, subject to changes when the reality of implementation indicates that something is not such a great idea after all.


tag(package)
tag(package, registry)

Tag the latest registered version of package with a lightweight
tag. Many variations on this are available through the keyword
arguments. package and registry can be specified in the same way
as for register.

Keyword arguments

tag(package, registry = nothing; push = false, repo = nothing,
    version = nothing, tag_name = nothing, annotation = nothing,
    gitconfig = Dict())
  • push: If true, push the tag(s) to the package repository automatically.
  • repo: Specify the package repository explicitly. Otherwise looked
    up in the registry.
  • version: Specify which version(s) to tag. If nothing, tag the
    latest release. If a string, tag that version. If a vector of
    strings, tag those versions. If :all, tag all registered versions.
  • tag_name: If nothing, use tags of the form v1.2.3 for
    normal packages and Package_v1.2.3 for packages in
    subdirectories. If set to a function, call that function with the
    version number and use the returned string as tag name.
  • annotation: If not nothing, create an annotated tag instead of a
    lightweight tag. If set to a string, use that as annotation
    message. If set to a function, call that function with the version
    number and use the returned string as annotation message.
  • gitconfig: Optional configuration parameters for the git command.

I have a local fork of LocalRegistry where I've added the keyword argument tag::Union{Nothing, AbstractString} = nothing, and the following in the end of register

    if tag !== nothing
        @info "Tagging, push tags with `git push --tags`" version=pkg.version
        git = gitcmd(package_path, gitconfig)
        run(`$git tag -a $(pkg.version) -m $(tag)`)
    end

This works quite well and is very simple.