diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 3b04d9937d7f2..7eb6204387337 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -180,6 +180,8 @@ Other Enhancements - :func:`~DataFrame.to_csv` and :func:`~DataFrame.to_json` now support ``compression='infer'`` to infer compression based on filename (:issue:`15008`) - :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`) - :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`) +- New attribute :attr:`__git_version__` will return git commit sha of current build +- .. _whatsnew_0240.api_breaking: diff --git a/pandas/__init__.py b/pandas/__init__.py index 97ae73174c09c..05b502f8b281b 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -83,6 +83,7 @@ from ._version import get_versions v = get_versions() __version__ = v.get('closest-tag', v['version']) +__git_version__ = v.get('full-revisionid') del get_versions, v # module level doc-string diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index e1c9202189972..7f41058a8c5d5 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -3,6 +3,7 @@ import pytest import os import collections +import string from functools import partial import numpy as np @@ -12,6 +13,7 @@ from pandas.core import ops from pandas.io.common import _get_handle import pandas.util.testing as tm +import pandas as pd def test_get_callable_name(): @@ -165,3 +167,10 @@ def test_compression_warning(compression_only): check_stacklevel=False): with f: df.to_csv(f, compression=compression_only) + + +def test_git_version(): + # GH 21295 + git_version = pd.__git_version__ + assert len(git_version) == 40 + assert all(c in string.hexdigits for c in git_version)