7b27f00602
Our logic for converting npm style versions to PEP-440 style versions was not correct in some cases. This change fixes this. As part of this change we no longer produce a NPM version that would be just X.Y.Z-dev, instead for development versions we always include both the timestamp of the commit and the commit hash. Instead of trying to use a bunch of sed logic to do our conversions, we now have a small go program that uses a newly added library in pkg/util. A side effect of this is that we can more easily write tests to ensure the conversion works as expected. Fixes #1243
28 lines
1.1 KiB
Bash
Executable file
28 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
set -o nounset -o errexit -o pipefail
|
|
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
COMMITISH=${1:-HEAD}
|
|
DIRTY_TAG=""
|
|
|
|
# Figure out if the worktree is dirty, we run update-index first
|
|
# as we've seen cases in Travis where not doing so causes git to
|
|
# treat the worktree as dirty when it is not.
|
|
git update-index -q --refresh
|
|
if ! git diff-files --quiet; then
|
|
DIRTY_TAG="-dirty"
|
|
fi
|
|
|
|
# If we have an exact tag, and it is not a -dev tag, just use it.
|
|
if git describe --tags --exact-match "${COMMITISH}" >/dev/null 2>&1; then
|
|
TAG="$(git describe --tags --exact-match "${COMMITISH}")"
|
|
if [[ ! "${TAG}" =~ -dev$ ]]; then
|
|
echo "$(git describe --tags --exact-match "${COMMITISH}")${DIRTY_TAG}"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Otherwise we want to include some additional information. To the
|
|
# base tag we add a timestamp and commit hash. We use the timestamp of
|
|
# the commit itself, not the date it was authored (so it will change
|
|
# when someone rebases a PR into master, for example).
|
|
echo "$(git describe --tags --abbrev=0 ${COMMITISH})-$(git show -s --format='%ct-g%h' ${COMMITISH})${DIRTY_TAG}"
|