@@ -900,67 +900,10 @@ gomod-pseudo-version() {
900900 local commit_ts
901901 commit_ts=" $( TZ=UTC git show -s --date=' format-local:%Y%m%d%H%M%S' --format=%cd HEAD) "
902902
903- # Get tag pointing at HEAD (the current commit), if any
904- local commit_tag
905- commit_tag=" $( git tag --points-at HEAD 2> /dev/null || true) "
906-
907- # We assume that tags will always be valid semver tags starting with 'v'.
908- # Repositories cloned by the publishing-bot always have two remotes:
909- # - origin: the published repository (e.g. github.com/kcp-dev/apimachinery)
910- # - upstream: the local source repository (e.g. ../kcp)
911- # We only consider tags from the published repository (origin).
912- if [[ -n " ${commit_tag:- } " ]]; then
913- commit_tag=$( echo " ${commit_tag} " | grep -E ' v|origin\/v' | sed ' s|^origin/||' | sort -V | tail -n1)
914- echo " ${commit_tag} "
915- return
916- fi
917-
918- # Get the latest tag from the published repository (origin).
919- # This tag does not point at HEAD, otherwise the previous case would handle it.
920- local latest_tag
921- latest_tag=" $( git ls-remote --tags origin 2> /dev/null || true) "
922-
923- if [[ -z " ${latest_tag:- } " ]]; then
924- # No tag exists, generate and return a pseudo-version string.
925- echo " v0.0.0-${commit_ts} -${commit_sha} "
926- return
927- fi
928-
929- # "git ls-remote" returns a bit more data than needed, so we parse it take valid semver tag.
930- latest_tag=" $( echo " ${latest_tag} " | awk -F/ ' {print $3}' | grep -v ' \^{}' | grep ' v' | sort -V | tail -n1) "
931-
932- # This returns the module major version as defined in go.mod.
933903 local module_major
934904 module_major=" $( gomod-module-major) "
935905
936- # Parse the latest tag and determine the semver elements.
937- if [[ " $latest_tag " =~ ^v([0-9]+)\. ([0-9]+)\. ([0-9]+)(-.+)? $ ]]; then
938- local major=" ${BASH_REMATCH[1]} "
939- local minor=" ${BASH_REMATCH[2]} "
940- local patch=" ${BASH_REMATCH[3]} "
941- local pre=" ${BASH_REMATCH[4]} "
942-
943- # If the module's major version matches the latest tag's major version.
944- if [[ " $module_major " == " v$major " ]]; then
945- if [[ -z " ${pre} " ]]; then
946- # Stable tags are handled by incrementing the patch version
947- # and appending the pseudo-version suffix.
948- echo " v${major} .${minor} .$(( patch+ 1 )) -0.${commit_ts} -${commit_sha} "
949- else
950- # Pre-release tags are handled by appending the pseudo-version suffix
951- # to the pre-release tag.
952- echo " ${latest_tag} .0.${commit_ts} -${commit_sha} "
953- fi
954- else
955- # Otherwise, Go handles this in a little strange way. It takes the latest tag
956- # and appends "+incompatible" to it.
957- echo " ${latest_tag} +incompatible"
958- fi
959- else
960- # If we hit this case, the latest tag is not a valid semver tag.
961- # We just generate v0.0.0 pseudo-version string instead.
962- echo " v0.0.0-${commit_ts} -${commit_sha} "
963- fi
906+ echo " ${module_major} .0.0-${commit_ts} -${commit_sha} "
964907}
965908
966909# checkout the dependencies to the versions corresponding to the kube commit of HEAD
0 commit comments