From 5f36a56d486bb8feab6237263af0064b456978df Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 21 Nov 2024 01:50:01 +0100 Subject: [PATCH] CI: fix handling shallow clone --- .gitlab-ci.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f0d57cd..24002c9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -124,6 +124,9 @@ build:debian-stable: - .cache/pip only: - tags + before_script: + # Gitlab CI use shallow clone, but we need full history to generate changelog + - git fetch --unshallow script: - ./build-deb.sh --install-build-deps - rm -fr dist/ldapsaisie-* @@ -140,6 +143,9 @@ build:debian-sid: - .cache/pip only: - master + before_script: + # Gitlab CI use shallow clone, but we need full history to generate changelog + - git fetch --unshallow script: - ./build-deb.sh --install-build-deps --sid - rm -fr dist/ldapsaisie-* @@ -171,11 +177,14 @@ build:doc:html: - apk add make git - git config user.name $GITLAB_USER_NAME - git config user.email $GITLAB_USER_EMAIL + # Compute current version + # Note: Gitlab CI use shallow clone, be sure to have all commits since latest tag - | - VERSION=$( - git describe --tags 2> /dev/null || \ - echo "0.0-$( git log --oneline|wc -l )-$( git describe --tags --always )" - ) + git fetch --tags + latest_tag_commit=$(git rev-list --tags --max-count=1) + commit_date=$(git show -s --format="%ad" --date=short $latest_tag_commit) + git fetch --shallow-since=$commit_date + VERSION=$(git describe --tags) - cd doc - git fetch origin $DOC_BRANCH - git rev-parse --verify $DOC_BRANCH && git branch -D $DOC_BRANCH || echo "No existing local git $DOC_BRANCH branch" @@ -240,11 +249,14 @@ build:doc:append_additional_versions: - apk add git - git config user.name $GITLAB_USER_NAME - git config user.email $GITLAB_USER_EMAIL + # Compute current version + # Note: Gitlab CI use shallow clone, be sure to have all commits since latest tag - | - VERSION=$( - git describe --tags 2> /dev/null || \ - echo "0.0-$( git log --oneline|wc -l )-$( git describe --tags --always )" - ) + git fetch --tags + latest_tag_commit=$(git rev-list --tags --max-count=1) + commit_date=$(git show -s --format="%ad" --date=short $latest_tag_commit) + git fetch --shallow-since=$commit_date + VERSION=$(git describe --tags) - cd doc - git fetch origin $DOC_BRANCH - git rev-parse --verify $DOC_BRANCH && git branch -D $DOC_BRANCH || echo "No existing local git $DOC_BRANCH branch"