Skip to content

Commit 921a2d9

Browse files
alimcmaster1victor
authored and
victor
committed
API: Git version (pandas-dev#22745)
1 parent a51e7f1 commit 921a2d9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Other Enhancements
185185
- :class:`Resampler` now is iterable like :class:`GroupBy` (:issue:`15314`).
186186
- :meth:`Series.resample` and :meth:`DataFrame.resample` have gained the :meth:`Resampler.quantile` (:issue:`15023`).
187187
- :meth:`Index.to_frame` now supports overriding column name(s) (:issue:`22580`).
188-
188+
- New attribute :attr:`__git_version__` will return git commit sha of current build (:issue:`21295`).
189189
.. _whatsnew_0240.api_breaking:
190190

191191
Backwards incompatible API changes

pandas/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
from ._version import get_versions
8181
v = get_versions()
8282
__version__ = v.get('closest-tag', v['version'])
83+
__git_version__ = v.get('full-revisionid')
8384
del get_versions, v
8485

8586
# module level doc-string

pandas/tests/test_common.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# -*- coding: utf-8 -*-
22

33
import collections
4+
import string
45
from functools import partial
56

67
import numpy as np
78
import pytest
89

10+
import pandas as pd
911
from pandas import Series, Timestamp
1012
from pandas.core import (
1113
common as com,
@@ -110,3 +112,10 @@ def test_standardize_mapping():
110112

111113
dd = collections.defaultdict(list)
112114
assert isinstance(com.standardize_mapping(dd), partial)
115+
116+
117+
def test_git_version():
118+
# GH 21295
119+
git_version = pd.__git_version__
120+
assert len(git_version) == 40
121+
assert all(c in string.hexdigits for c in git_version)

0 commit comments

Comments
 (0)