Skip to content

Commit 13957ca

Browse files
qwhelanquintusdias
authored andcommitted
[BLD] Add script that fails build if git tags do not exist (pandas-dev#27770)
1 parent ffc0d65 commit 13957ca

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121

2222
git:
2323
# for cloning
24-
depth: 2000
24+
depth: false
2525

2626
matrix:
2727
fast_finish: true
@@ -63,7 +63,7 @@ before_install:
6363
- pwd
6464
- uname -a
6565
- git --version
66-
- git tag
66+
- ./ci/check_git_tags.sh
6767
# Because travis runs on Google Cloud and has a /etc/boto.cfg,
6868
# it breaks moto import, see:
6969
# https://github.com/spulec/moto/issues/1771

ci/check_git_tags.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set -e
2+
3+
if [[ ! $(git tag) ]]; then
4+
echo "No git tags in clone, please sync your git tags with upstream using:"
5+
echo " git fetch --tags upstream"
6+
echo " git push --tags origin"
7+
echo ""
8+
echo "If the issue persists, the clone depth needs to be increased in .travis.yml"
9+
exit 1
10+
fi
11+
12+
# This will error if there are no tags and we omit --always
13+
DESCRIPTION=$(git describe --long --tags)
14+
echo "$DESCRIPTION"
15+
16+
if [[ "$DESCRIPTION" == *"untagged"* ]]; then
17+
echo "Unable to determine most recent tag, aborting build"
18+
exit 1
19+
else
20+
if [[ "$DESCRIPTION" != *"g"* ]]; then
21+
# A good description will have the hash prefixed by g, a bad one will be
22+
# just the hash
23+
echo "Unable to determine most recent tag, aborting build"
24+
exit 1
25+
else
26+
echo "$(git tag)"
27+
fi
28+
fi

pandas/tests/test_common.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections
2+
from distutils.version import LooseVersion
23
from functools import partial
34
import string
45

@@ -117,3 +118,13 @@ def test_git_version():
117118
git_version = pd.__git_version__
118119
assert len(git_version) == 40
119120
assert all(c in string.hexdigits for c in git_version)
121+
122+
123+
def test_version_tag():
124+
version = pd.__version__
125+
try:
126+
version > LooseVersion("0.0.1")
127+
except TypeError:
128+
raise ValueError(
129+
"No git tags exist, please sync tags between upstream and your repo"
130+
)

0 commit comments

Comments
 (0)