summarylogtreecommitdiffstats
path: root/script_slug.jl
blob: 5ae01d653617786c73d9a8f5ec71c058b18d8b23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

## From https://github.com/cdluminate/DistroHelper.jl

using Pkg

function slug(package::AbstractString, versions::AbstractString, version::Any = nothing)
    if !any(map(isfile, (package, versions)))
        uuid = Base.UUID(package)
        sha1 = Base.SHA1(hex2bytes(versions))
    else
        Package  = Pkg.TOML.parsefile(package)
        Versions = Pkg.TOML.parsefile(versions)
        latest_ver = maximum(VersionNumber.(keys(Versions)))
        version = string((version == nothing) ? latest_ver : version)
        uuid = Base.UUID(Package["uuid"])
        sha1 = Base.SHA1(hex2bytes(Versions[version]["git-tree-sha1"]))
    end
    return Base.version_slug(uuid,sha1)
end

println(slug(ARGS...))