query
On this page

shortRev

lib.sources.shortRev

Docs pulled from | This Revision | 4 days ago


Given a package revision (like "refs/tags/v12.0"), produce a short revision ("12.0").


Noogle detected

Implementation

The following is the current implementation of this function.

shortRev =
    rev:
    let
      baseRev = baseNameOf (toString rev);
      matchHash = match "[a-f0-9]+" baseRev;
      matchVer = match "([A-Za-z]+[-_. ]?)*(v)?([0-9.]+.*)" baseRev;
    in
    if matchHash != null then
      builtins.substring 0 7 baseRev
    else if matchVer != null then
      lib.last matchVer
    else
      baseRev;