|
6 | 6 |
|
7 | 7 | from .. import _types as _t
|
8 | 8 | from .._log import log as parent_log
|
9 |
| -from .._node_utils import _format_node_for_output |
10 | 9 | from .._version_cls import _version_as_tuple
|
11 | 10 | from ..version import ScmVersion
|
12 | 11 |
|
13 | 12 | log = parent_log.getChild("dump_version")
|
14 | 13 |
|
15 | 14 |
|
16 |
| -class _TemplateScmVersion: |
17 |
| - """Wrapper for ScmVersion that formats node for template output.""" |
18 |
| - |
19 |
| - def __init__(self, scm_version: ScmVersion) -> None: |
20 |
| - self._scm_version = scm_version |
21 |
| - |
22 |
| - def __getattr__(self, name: str) -> object: |
23 |
| - # Delegate all attribute access to the wrapped ScmVersion |
24 |
| - return getattr(self._scm_version, name) |
25 |
| - |
26 |
| - @property |
27 |
| - def node(self) -> str | None: |
28 |
| - """Return the node formatted for output.""" |
29 |
| - return _format_node_for_output(self._scm_version.node) |
30 |
| - |
31 |
| - |
32 | 15 | TEMPLATES = {
|
33 | 16 | ".py": """\
|
34 | 17 | # file generated by setuptools-scm
|
@@ -64,7 +47,7 @@ def node(self) -> str | None:
|
64 | 47 | __version__ = version = {version!r}
|
65 | 48 | __version_tuple__ = version_tuple = {version_tuple!r}
|
66 | 49 |
|
67 |
| -__commit_id__ = commit_id = {scm_version.node!r} |
| 50 | +__commit_id__ = commit_id = {scm_version.short_node!r} |
68 | 51 | """,
|
69 | 52 | ".txt": "{version}",
|
70 | 53 | }
|
@@ -119,12 +102,10 @@ def write_version_to_path(
|
119 | 102 | log.debug("dump %s into %s", version, target)
|
120 | 103 | version_tuple = _version_as_tuple(version)
|
121 | 104 | if scm_version is not None:
|
122 |
| - # Wrap ScmVersion to provide formatted node for templates |
123 |
| - template_scm_version = _TemplateScmVersion(scm_version) |
124 | 105 | content = final_template.format(
|
125 | 106 | version=version,
|
126 | 107 | version_tuple=version_tuple,
|
127 |
| - scm_version=template_scm_version, |
| 108 | + scm_version=scm_version, |
128 | 109 | )
|
129 | 110 | else:
|
130 | 111 | content = final_template.format(version=version, version_tuple=version_tuple)
|
|
0 commit comments