Skip to content

Commit

Permalink
git describe --tags faild , when latest commit is not tag commit, bec…
Browse files Browse the repository at this point in the history
…ase we use shallow clone (clone with depth==1), so this fix clone necessary commit to get git describe --tag works
  • Loading branch information
k-okada committed Aug 16, 2024
1 parent 3195af6 commit 68c1ddf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ build_deb(){
# Set the version based on the checked out tag that contain at least on digit
# strip any leading non digits as they are not part of the version number
description=`( git describe --tag --match "*[0-9]*" 2>/dev/null || echo 0 ) | sed 's@^[^0-9]*@@'`
if [ "$description" = "0" ]; then
# git describe --tags faild, clone necessary commits
# https://stackoverflow.com/questions/66349002/get-latest-tag-git-describe-tags-when-repo-is-cloned-with-depth-1
# '[0-9]*' matches any tags start from number, to find tag like v0.1.1, we added '??'
TAG=$(git ls-remote origin "refs/tags/??[0-9]*" | cut -f 2- | sort -V | tail -1)
BRANCH_NAME=$(git symbolic-ref HEAD 2>/dev/null | sed s@refs/heads/@@)
git fetch --filter=tree:0 --shallow-exclude $TAG origin $BRANCH_NAME
git fetch --filter=tree:0 --deepen=1 origin $BRANCH_NAME
git fetch --filter=tree:0 --depth=1 origin $TAG:$TAG
description=`( git describe --tag --match "*[0-9]*" 2>/dev/null || echo 0 ) | sed 's@[^.0-9].*$@@'`
fi

bloom_log=${pkg_name}_${description}-bloom_generate.log

Expand Down

0 comments on commit 68c1ddf

Please sign in to comment.