mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
unstableGitUpdater: Add option to apply a pattern to found tags, to ignore non-matching tags
This commit is contained in:
parent
c145f59d48
commit
e30288bced
@ -11,6 +11,7 @@
|
|||||||
{ url ? null # The git url, if empty it will be set to src.gitRepoUrl
|
{ url ? null # The git url, if empty it will be set to src.gitRepoUrl
|
||||||
, branch ? null
|
, branch ? null
|
||||||
, hardcodeZeroVersion ? false # Use a made-up version "0" instead of latest tag. Use when there is no previous release, or the project's tagging system is incompatible with what we expect from versions
|
, hardcodeZeroVersion ? false # Use a made-up version "0" instead of latest tag. Use when there is no previous release, or the project's tagging system is incompatible with what we expect from versions
|
||||||
|
, tagFormat ? ".*" # A grep -Eo pattern that tags must match to be considered valid
|
||||||
, tagPrefix ? "" # strip this prefix from a tag name
|
, tagPrefix ? "" # strip this prefix from a tag name
|
||||||
, tagConverter ? null # A command to convert more complex tag formats. It receives the git tag via stdin and should convert it into x.y.z format to stdout
|
, tagConverter ? null # A command to convert more complex tag formats. It receives the git tag via stdin and should convert it into x.y.z format to stdout
|
||||||
, shallowClone ? true
|
, shallowClone ? true
|
||||||
@ -23,6 +24,7 @@ let
|
|||||||
url=""
|
url=""
|
||||||
branch=""
|
branch=""
|
||||||
hardcode_zero_version=""
|
hardcode_zero_version=""
|
||||||
|
tag_format=""
|
||||||
tag_prefix=""
|
tag_prefix=""
|
||||||
tag_converter=""
|
tag_converter=""
|
||||||
shallow_clone=""
|
shallow_clone=""
|
||||||
@ -40,6 +42,9 @@ let
|
|||||||
--hardcode-zero-version)
|
--hardcode-zero-version)
|
||||||
hardcode_zero_version=1
|
hardcode_zero_version=1
|
||||||
;;
|
;;
|
||||||
|
--tag-format=*)
|
||||||
|
tag_format="''${flag#*=}"
|
||||||
|
;;
|
||||||
--tag-prefix=*)
|
--tag-prefix=*)
|
||||||
tag_prefix="''${flag#*=}"
|
tag_prefix="''${flag#*=}"
|
||||||
;;
|
;;
|
||||||
@ -90,6 +95,11 @@ let
|
|||||||
while (( $depth < 10000 )); do
|
while (( $depth < 10000 )); do
|
||||||
last_tag="$(${git}/bin/git describe --tags --abbrev=0 2> /dev/null || true)"
|
last_tag="$(${git}/bin/git describe --tags --abbrev=0 2> /dev/null || true)"
|
||||||
if [[ -n "$last_tag" ]]; then
|
if [[ -n "$last_tag" ]]; then
|
||||||
|
tag_matched="$(echo ''${last_tag} | grep -Eo ''${tag_format} || true)"
|
||||||
|
if [[ -z "$tag_matched" ]]; then
|
||||||
|
${lib.getExe git} tag -d ''${last_tag}
|
||||||
|
continue
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
${git}/bin/git fetch --depth="$depth" --tags
|
${git}/bin/git fetch --depth="$depth" --tags
|
||||||
@ -108,13 +118,15 @@ let
|
|||||||
last_tag="0"
|
last_tag="0"
|
||||||
fi
|
fi
|
||||||
if [[ -n "$tag_prefix" ]]; then
|
if [[ -n "$tag_prefix" ]]; then
|
||||||
|
echo "Stripping prefix '$tag_prefix' from tag '$last_tag'"
|
||||||
last_tag="''${last_tag#$tag_prefix}"
|
last_tag="''${last_tag#$tag_prefix}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "$tag_converter" ]]; then
|
if [[ -n "$tag_converter" ]]; then
|
||||||
|
echo "Running '$last_tag' through: $tag_converter"
|
||||||
last_tag="$(echo ''${last_tag#$tag_prefix} | ''${tag_converter})"
|
last_tag="$(echo ''${last_tag#$tag_prefix} | ''${tag_converter})"
|
||||||
fi
|
fi
|
||||||
if [[ ! "$last_tag" =~ ^[[:digit:]] ]]; then
|
if [[ ! "$last_tag" =~ ^[[:digit:]] ]]; then
|
||||||
echo "Last tag '$last_tag' (after removing prefix '$tag_prefix') does not start with a digit" > /dev/stderr
|
echo "Last tag '$last_tag' does not start with a digit" > /dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -135,6 +147,7 @@ in
|
|||||||
[
|
[
|
||||||
updateScript
|
updateScript
|
||||||
"--url=${builtins.toString url}"
|
"--url=${builtins.toString url}"
|
||||||
|
"--tag-format=${tagFormat}"
|
||||||
"--tag-prefix=${tagPrefix}"
|
"--tag-prefix=${tagPrefix}"
|
||||||
] ++ lib.optionals (branch != null) [
|
] ++ lib.optionals (branch != null) [
|
||||||
"--branch=${branch}"
|
"--branch=${branch}"
|
||||||
|
Loading…
Reference in New Issue
Block a user