diff options
author | Devan Carpenter <git@dvn.me> | 2023-11-27 22:36:51 -0500 |
---|---|---|
committer | Devan Carpenter <git@dvn.me> | 2023-11-27 22:47:10 -0500 |
commit | 9dd915b5a0b59dfa2589ffc7f8e4ce3b60bdeafb (patch) | |
tree | fda3bf7ee9c89d7166652914fd03690f36e8b36f | |
parent | d11add3f588b18e20382646005721fc673ba2624 (diff) |
ci: update version script to work on detached headdev/dvn/2023-buildbot-ci
git version 2.4.4 changed the way rev-parsing worked in a detached head
state
-rwxr-xr-x | contrib/ci/jobs/2-deb-package/version.sh | 19 | ||||
-rwxr-xr-x | contrib/ci/jobs/5-arm64-deb-package/version.sh | 19 |
2 files changed, 24 insertions, 14 deletions
diff --git a/contrib/ci/jobs/2-deb-package/version.sh b/contrib/ci/jobs/2-deb-package/version.sh index 74d0099a2..c5b4e395a 100755 --- a/contrib/ci/jobs/2-deb-package/version.sh +++ b/contrib/ci/jobs/2-deb-package/version.sh @@ -1,12 +1,17 @@ #!/bin/sh set -ex -git fetch origin $(git rev-parse --abbrev-ref HEAD) --depth=1000 --tags -RECENT_VERSION_TAG=$(git describe --tags --match 'v*.*.*' --always --abbrev=0 HEAD) - -commits="$(git rev-list ${RECENT_VERSION_TAG}..HEAD --count)" -if [ "${commits}" = "0" ]; then - git describe --tag HEAD +BRANCH=$(git name-rev --name-only HEAD) +if [ -z "${BRANCH}" ]; then + exit 1 else - echo $(echo ${RECENT_VERSION_TAG} | cut -d'v' -f2)-${commits}-$(git rev-parse --short=8 HEAD) + # "Unshallow" our checkout, but only our current branch, and exclude the submodules. + git fetch --no-recurse-submodules --tags --depth=1000 origin "${BRANCH}" + RECENT_VERSION_TAG=$(git describe --tags --match 'v*.*.*' --always --abbrev=0 HEAD) + commits="$(git rev-list ${RECENT_VERSION_TAG}..HEAD --count)" + if [ "${commits}" = "0" ]; then + git describe --tag HEAD + else + echo $(echo ${RECENT_VERSION_TAG} | sed -r 's/^v//')-${commits}-$(git rev-parse --short=8 HEAD) + fi fi diff --git a/contrib/ci/jobs/5-arm64-deb-package/version.sh b/contrib/ci/jobs/5-arm64-deb-package/version.sh index 74d0099a2..c5b4e395a 100755 --- a/contrib/ci/jobs/5-arm64-deb-package/version.sh +++ b/contrib/ci/jobs/5-arm64-deb-package/version.sh @@ -1,12 +1,17 @@ #!/bin/sh set -ex -git fetch origin $(git rev-parse --abbrev-ref HEAD) --depth=1000 --tags -RECENT_VERSION_TAG=$(git describe --tags --match 'v*.*.*' --always --abbrev=0 HEAD) - -commits="$(git rev-list ${RECENT_VERSION_TAG}..HEAD --count)" -if [ "${commits}" = "0" ]; then - git describe --tag HEAD +BRANCH=$(git name-rev --name-only HEAD) +if [ -z "${BRANCH}" ]; then + exit 1 else - echo $(echo ${RECENT_VERSION_TAG} | cut -d'v' -f2)-${commits}-$(git rev-parse --short=8 HEAD) + # "Unshallow" our checkout, but only our current branch, and exclude the submodules. + git fetch --no-recurse-submodules --tags --depth=1000 origin "${BRANCH}" + RECENT_VERSION_TAG=$(git describe --tags --match 'v*.*.*' --always --abbrev=0 HEAD) + commits="$(git rev-list ${RECENT_VERSION_TAG}..HEAD --count)" + if [ "${commits}" = "0" ]; then + git describe --tag HEAD + else + echo $(echo ${RECENT_VERSION_TAG} | sed -r 's/^v//')-${commits}-$(git rev-parse --short=8 HEAD) + fi fi |