From 68eee8bfbc1e04e250e1cbc67de4a89b47eb276e Mon Sep 17 00:00:00 2001 From: Bruk Ori Date: Tue, 8 Oct 2024 17:42:00 +0300 Subject: [PATCH] [#68] Fix version linter. Signed-off-by: Ori Bruk --- Makefile | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c31aa89..9410486 100755 --- a/Makefile +++ b/Makefile @@ -24,11 +24,27 @@ fmt: # Run version update check version: - @diff=$$(git diff-index master version.json); \ - if [[ -z "$$diff" ]]; then \ - echo "⇒ You need to update the api version in the version.json file"; \ - exit 1;\ - fi + @version=$$(wget -qO- "https://git.frostfs.info/TrueCloudLab/frostfs-api/raw/branch/master/version.json"); \ + if [ -z "$$version" ]; then \ + exit; \ + fi; \ + masterMilestone=$$(jq -n --argjson data "$$version" '$$data.milestone'); \ + masterPatch=$$(jq -n --argjson data "$$version" '$$data.patch'); \ + milestone=$$(jq -r '.milestone' version.json); \ + patch=$$(jq -r '.patch' version.json); \ + if [ "$$masterMilestone" -eq "$$milestone" -a "$$masterPatch" -eq "$$patch" ]; then \ + echo "⇒ You need to update the api version in the version.json file"; \ + exit 1; \ + elif [ "$$masterMilestone" -gt "$$milestone" ]; then \ + echo "⇒ The milestone cannot be decrement in the version.json file"; \ + exit 1; \ + elif [ "$$masterMilestone" -eq "$$milestone" -a "$$masterPatch" -gt "$$patch" ]; then \ + echo "⇒ The patch cannot be decrement without milestone increment in the version.json file"; \ + exit 1; \ + elif [ "$$masterMilestone" -lt "$$milestone" -a "$$patch" -ne 0 ]; then \ + echo "⇒ The patch should be 0 after milestone increment in the version.json file"; \ + exit 1; \ + fi # Run compatibility information check compatibility: