diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 649629714c3b1..7fb87d31fb469 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -185,7 +185,7 @@ Other Enhancements - :class:`Resampler` now is iterable like :class:`GroupBy` (:issue:`15314`). - :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`). - :meth:`Index.to_frame` now supports overriding column name(s) (:issue:`22580`). - +- New attribute :attr:`__git_version__` will return git commit sha of current build (:issue:`21295`). .. _whatsnew_0240.api_breaking: Backwards incompatible API changes 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 868525e818b62..ae46bee901ff2 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -1,11 +1,13 @@ # -*- coding: utf-8 -*- import collections +import string from functools import partial import numpy as np import pytest +import pandas as pd from pandas import Series, Timestamp from pandas.core import ( common as com, @@ -110,3 +112,10 @@ def test_standardize_mapping(): dd = collections.defaultdict(list) assert isinstance(com.standardize_mapping(dd), partial) + + +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)