diff --git a/.forgejo/workflows/pre-commit.yaml b/.forgejo/workflows/pre-commit.yaml index 5bf97eb..9bcbce9 100644 --- a/.forgejo/workflows/pre-commit.yaml +++ b/.forgejo/workflows/pre-commit.yaml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Install deps run: | apt update diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e564da8..d30e2da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,9 +22,9 @@ repos: entry: make fmt language: system pass_filenames: false - - id: make-version - name: Run make version - entry: make version + - id: make-check-version + name: Run make check-version + entry: make check-version language: system pass_filenames: false - id: make-compatibility diff --git a/CHANGELOG.md b/CHANGELOG.md index 3401010..c934954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [3.0] - 2024-10-08 - Oryukdo (오륙도, 五六島) +## [3.0] - 2024-10-08 - Potanin Glacier ### Added - Version compatibility information diff --git a/Makefile b/Makefile index c31aa89..f22250e 100755 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SHELL=bash include help.mk -.PHONY: doc fmt version compatibility pre-commit unpre-commit pre-commit-run +.PHONY: doc fmt check-version compatibility pre-commit unpre-commit pre-commit-run # Regenerate documentation for proto files: doc: @@ -22,15 +22,33 @@ fmt: clang-format -i $$f; \ done -# 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 +# Run version update check in version.json file +check-version: + @version=$$(git show remotes/origin/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 +# Run a compatibility information check \ +Checks that the files that describe compatibility in the compatibility package \ +have the current version information added in the version.json file compatibility: @version=$$(jq -r '.milestone' version.json).$$(jq -r '.patch' version.json); \ conflicts=0; \