setuptools-git-versioning 1.13.6__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {setuptools-git-versioning-1.13.6/setuptools_git_versioning.egg-info → setuptools_git_versioning-2.1.0}/PKG-INFO +25 -10
  2. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/README.rst +9 -7
  3. setuptools_git_versioning-2.1.0/requirements.txt +3 -0
  4. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setup.py +3 -3
  5. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0/setuptools_git_versioning.egg-info}/PKG-INFO +25 -10
  6. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/entry_points.txt +1 -2
  7. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/requires.txt +1 -1
  8. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.py +47 -77
  9. setuptools-git-versioning-1.13.6/requirements.txt +0 -3
  10. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/LICENSE +0 -0
  11. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/MANIFEST.in +0 -0
  12. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setup.cfg +0 -0
  13. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/SOURCES.txt +0 -0
  14. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/dependency_links.txt +0 -0
  15. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/not-zip-safe +0 -0
  16. {setuptools-git-versioning-1.13.6 → setuptools_git_versioning-2.1.0}/setuptools_git_versioning.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: setuptools-git-versioning
3
- Version: 1.13.6
3
+ Version: 2.1.0
4
4
  Summary: Use git repo data for building a version number according PEP-440
5
5
  Home-page: https://setuptools-git-versioning.readthedocs.io
6
6
  Author: dolfinus
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
24
25
  Classifier: License :: OSI Approved :: MIT License
25
26
  Classifier: Operating System :: OS Independent
26
27
  Requires-Python: >=3.7
@@ -28,7 +29,19 @@ Description-Content-Type: text/x-rst
28
29
  License-File: LICENSE
29
30
  Requires-Dist: packaging
30
31
  Requires-Dist: setuptools
31
- Requires-Dist: toml>=0.10.2; python_version < "3.11"
32
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11"
33
+ Dynamic: author
34
+ Dynamic: author-email
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: license
41
+ Dynamic: project-url
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
32
45
 
33
46
  *************************
34
47
  setuptools-git-versioning
@@ -72,14 +85,16 @@ version number according :pep:`440`.
72
85
 
73
86
  - Well-documented
74
87
 
75
- See `difference <https://setuptools-git-versioning.readthedocs.io/en/latest/differences.html>`_
88
+ See `comparison <https://setuptools-git-versioning.readthedocs.io/en/stable/comparison.html>`_
76
89
  between ``setuptools-git-versioning`` and other tools.
77
90
 
78
91
  **Limitations:**
79
92
 
80
93
  - Currently the only supported VCS is *Git*
81
94
 
82
- - Only git v2 is supported
95
+ - Only Git v2 is supported
96
+
97
+ - Only Setuptools build backend is supported (no Poetry & others)
83
98
 
84
99
  - Currently does not support automatic exporting of package version to a file for runtime use
85
100
  (but you can use ``setuptools-git-versioning > file`` redirect instead)
@@ -113,7 +128,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
113
128
  .. code:: toml
114
129
 
115
130
  [build-system]
116
- requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning<2", ]
131
+ requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3", ]
117
132
  build-backend = "setuptools.build_meta"
118
133
 
119
134
  [tool.setuptools-git-versioning]
@@ -122,7 +137,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
122
137
  [project]
123
138
  dynamic = ["version"]
124
139
 
125
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
140
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
126
141
 
127
142
  .. code:: bash
128
143
 
@@ -135,7 +150,7 @@ And check the package version generated (see `command help <https://setuptools-g
135
150
  0.0.1
136
151
 
137
152
  ``setup.py``
138
- ~~~~~~~~~~~~~~
153
+ ~~~~~~~~~~~~
139
154
 
140
155
  Just add ``setuptools-git-versioning`` to ``setup_requires`` argument of ``setuptools.setup`` function call,
141
156
  and then add new argument ``setuptools_git_versioning`` with config options:
@@ -149,10 +164,10 @@ and then add new argument ``setuptools_git_versioning`` with config options:
149
164
  setuptools_git_versioning={
150
165
  "enabled": True,
151
166
  },
152
- setup_requires=["setuptools-git-versioning<2"],
167
+ setup_requires=["setuptools-git-versioning>=2.0,<3"],
153
168
  )
154
169
 
155
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
170
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
156
171
 
157
172
  .. code:: bash
158
173
 
@@ -40,14 +40,16 @@ version number according :pep:`440`.
40
40
 
41
41
  - Well-documented
42
42
 
43
- See `difference <https://setuptools-git-versioning.readthedocs.io/en/latest/differences.html>`_
43
+ See `comparison <https://setuptools-git-versioning.readthedocs.io/en/stable/comparison.html>`_
44
44
  between ``setuptools-git-versioning`` and other tools.
45
45
 
46
46
  **Limitations:**
47
47
 
48
48
  - Currently the only supported VCS is *Git*
49
49
 
50
- - Only git v2 is supported
50
+ - Only Git v2 is supported
51
+
52
+ - Only Setuptools build backend is supported (no Poetry & others)
51
53
 
52
54
  - Currently does not support automatic exporting of package version to a file for runtime use
53
55
  (but you can use ``setuptools-git-versioning > file`` redirect instead)
@@ -81,7 +83,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
81
83
  .. code:: toml
82
84
 
83
85
  [build-system]
84
- requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning<2", ]
86
+ requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3", ]
85
87
  build-backend = "setuptools.build_meta"
86
88
 
87
89
  [tool.setuptools-git-versioning]
@@ -90,7 +92,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
90
92
  [project]
91
93
  dynamic = ["version"]
92
94
 
93
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
95
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
94
96
 
95
97
  .. code:: bash
96
98
 
@@ -103,7 +105,7 @@ And check the package version generated (see `command help <https://setuptools-g
103
105
  0.0.1
104
106
 
105
107
  ``setup.py``
106
- ~~~~~~~~~~~~~~
108
+ ~~~~~~~~~~~~
107
109
 
108
110
  Just add ``setuptools-git-versioning`` to ``setup_requires`` argument of ``setuptools.setup`` function call,
109
111
  and then add new argument ``setuptools_git_versioning`` with config options:
@@ -117,10 +119,10 @@ and then add new argument ``setuptools_git_versioning`` with config options:
117
119
  setuptools_git_versioning={
118
120
  "enabled": True,
119
121
  },
120
- setup_requires=["setuptools-git-versioning<2"],
122
+ setup_requires=["setuptools-git-versioning>=2.0,<3"],
121
123
  )
122
124
 
123
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
125
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
124
126
 
125
127
  .. code:: bash
126
128
 
@@ -0,0 +1,3 @@
1
+ packaging
2
+ setuptools
3
+ tomli>=2.0.1; python_version<"3.11"
@@ -19,7 +19,7 @@ setup(
19
19
  name="setuptools-git-versioning",
20
20
  # +local version is not allowed in PyPI
21
21
  # https://github.com/pypa/pypi-legacy/issues/731#issuecomment-345461596
22
- version='1.13.6',
22
+ version='2.1.0',
23
23
  author="dolfinus",
24
24
  author_email="martinov.m.s.8@gmail.com",
25
25
  description="Use git repo data for building a version number according PEP-440",
@@ -39,6 +39,7 @@ setup(
39
39
  "Programming Language :: Python :: 3.10",
40
40
  "Programming Language :: Python :: 3.11",
41
41
  "Programming Language :: Python :: 3.12",
42
+ "Programming Language :: Python :: 3.13",
42
43
  "License :: OSI Approved :: MIT License",
43
44
  "Operating System :: OS Independent",
44
45
  ],
@@ -55,8 +56,7 @@ setup(
55
56
  setup_requires=requirements,
56
57
  entry_points={
57
58
  "distutils.setup_keywords": [
58
- "version_config = setuptools_git_versioning:_parse_config",
59
- "setuptools_git_versioning = setuptools_git_versioning:_parse_config",
59
+ "setuptools_git_versioning = setuptools_git_versioning:parse_config",
60
60
  ],
61
61
  "setuptools.finalize_distribution_options": [
62
62
  "setuptools_git_versioning = setuptools_git_versioning:infer_version",
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: setuptools-git-versioning
3
- Version: 1.13.6
3
+ Version: 2.1.0
4
4
  Summary: Use git repo data for building a version number according PEP-440
5
5
  Home-page: https://setuptools-git-versioning.readthedocs.io
6
6
  Author: dolfinus
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
24
25
  Classifier: License :: OSI Approved :: MIT License
25
26
  Classifier: Operating System :: OS Independent
26
27
  Requires-Python: >=3.7
@@ -28,7 +29,19 @@ Description-Content-Type: text/x-rst
28
29
  License-File: LICENSE
29
30
  Requires-Dist: packaging
30
31
  Requires-Dist: setuptools
31
- Requires-Dist: toml>=0.10.2; python_version < "3.11"
32
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11"
33
+ Dynamic: author
34
+ Dynamic: author-email
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: license
41
+ Dynamic: project-url
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
32
45
 
33
46
  *************************
34
47
  setuptools-git-versioning
@@ -72,14 +85,16 @@ version number according :pep:`440`.
72
85
 
73
86
  - Well-documented
74
87
 
75
- See `difference <https://setuptools-git-versioning.readthedocs.io/en/latest/differences.html>`_
88
+ See `comparison <https://setuptools-git-versioning.readthedocs.io/en/stable/comparison.html>`_
76
89
  between ``setuptools-git-versioning`` and other tools.
77
90
 
78
91
  **Limitations:**
79
92
 
80
93
  - Currently the only supported VCS is *Git*
81
94
 
82
- - Only git v2 is supported
95
+ - Only Git v2 is supported
96
+
97
+ - Only Setuptools build backend is supported (no Poetry & others)
83
98
 
84
99
  - Currently does not support automatic exporting of package version to a file for runtime use
85
100
  (but you can use ``setuptools-git-versioning > file`` redirect instead)
@@ -113,7 +128,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
113
128
  .. code:: toml
114
129
 
115
130
  [build-system]
116
- requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning<2", ]
131
+ requires = [ "setuptools>=41", "wheel", "setuptools-git-versioning>=2.0,<3", ]
117
132
  build-backend = "setuptools.build_meta"
118
133
 
119
134
  [tool.setuptools-git-versioning]
@@ -122,7 +137,7 @@ add a section ``tool.setuptools-git-versioning`` with config options, and mark t
122
137
  [project]
123
138
  dynamic = ["version"]
124
139
 
125
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
140
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
126
141
 
127
142
  .. code:: bash
128
143
 
@@ -135,7 +150,7 @@ And check the package version generated (see `command help <https://setuptools-g
135
150
  0.0.1
136
151
 
137
152
  ``setup.py``
138
- ~~~~~~~~~~~~~~
153
+ ~~~~~~~~~~~~
139
154
 
140
155
  Just add ``setuptools-git-versioning`` to ``setup_requires`` argument of ``setuptools.setup`` function call,
141
156
  and then add new argument ``setuptools_git_versioning`` with config options:
@@ -149,10 +164,10 @@ and then add new argument ``setuptools_git_versioning`` with config options:
149
164
  setuptools_git_versioning={
150
165
  "enabled": True,
151
166
  },
152
- setup_requires=["setuptools-git-versioning<2"],
167
+ setup_requires=["setuptools-git-versioning>=2.0,<3"],
153
168
  )
154
169
 
155
- And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`__):
170
+ And check the package version generated (see `command help <https://setuptools-git-versioning.readthedocs.io/en/stable/command.html>`_):
156
171
 
157
172
  .. code:: bash
158
173
 
@@ -2,8 +2,7 @@
2
2
  setuptools-git-versioning = setuptools_git_versioning:__main__
3
3
 
4
4
  [distutils.setup_keywords]
5
- setuptools_git_versioning = setuptools_git_versioning:_parse_config
6
- version_config = setuptools_git_versioning:_parse_config
5
+ setuptools_git_versioning = setuptools_git_versioning:parse_config
7
6
 
8
7
  [setuptools.finalize_distribution_options]
9
8
  setuptools_git_versioning = setuptools_git_versioning:infer_version
@@ -2,4 +2,4 @@ packaging
2
2
  setuptools
3
3
 
4
4
  [:python_version < "3.11"]
5
- toml>=0.10.2
5
+ tomli>=2.0.1
@@ -9,7 +9,6 @@ import re
9
9
  import subprocess # nosec
10
10
  import sys
11
11
  import textwrap
12
- import warnings
13
12
  from datetime import datetime
14
13
  from pathlib import Path
15
14
  from pprint import pformat
@@ -104,18 +103,6 @@ def get_all_tags(sort_by: str = DEFAULT_SORT_BY, root: str | os.PathLike | None
104
103
  return []
105
104
 
106
105
 
107
- def get_branch_tags(*args, **kwargs) -> list[str]:
108
- warnings.warn(
109
- "`get_branch_tags` function is deprecated "
110
- "since setuptools-git-versioning v1.8.0 "
111
- "and will be dropped in v2.0.0\n"
112
- "Please use `get_tags` instead",
113
- category=UserWarning,
114
- )
115
-
116
- return get_tags(*args, **kwargs)
117
-
118
-
119
106
  def get_tags(
120
107
  sort_by: str = DEFAULT_SORT_BY,
121
108
  filter_callback: Callable[[str], str | None] | None = None,
@@ -194,9 +181,10 @@ def _read_toml(name_or_path: str | os.PathLike = "pyproject.toml", root: str | o
194
181
  with file_path.open("rb") as file:
195
182
  parsed_file = tomllib.load(file)
196
183
  except (ImportError, NameError):
197
- import toml # type: ignore[no-redef]
184
+ import tomli
198
185
 
199
- parsed_file = toml.load(file_path)
186
+ with file_path.open("rb") as file:
187
+ parsed_file = tomli.load(file)
200
188
 
201
189
  result = parsed_file.get("tool", {}).get("setuptools-git-versioning", None)
202
190
  if result:
@@ -232,24 +220,9 @@ def _infer_setup_py(name_or_path: str = "setup.py", root: str | os.PathLike | No
232
220
  os.chdir(original_cwd)
233
221
 
234
222
 
235
- # TODO: remove along with version_config
236
- def _parse_config(dist: Distribution, attr: Any, value: Any) -> None:
237
- from distutils.errors import DistutilsOptionError
238
-
239
- if attr == "version_config" and value is not None:
240
- warnings.warn(
241
- "'version_config' option is deprecated "
242
- "since setuptools-git-versioning v1.8.0 "
243
- "and will be dropped in v2.0.0\n"
244
- "Please rename it to 'setuptools_git_versioning'",
245
- category=UserWarning,
246
- )
247
-
248
- if getattr(dist, "setuptools_git_versioning", None) is not None:
249
- raise DistutilsOptionError(
250
- "You can set either 'version_config' or 'setuptools_git_versioning' "
251
- "but not both of them at the same time"
252
- )
223
+ def parse_config(dist: Distribution, attr: Any, value: Any) -> None:
224
+ "Dummy function used only to register in distutils"
225
+ return None
253
226
 
254
227
 
255
228
  def infer_version(dist: Distribution, root: str | os.PathLike | None = None) -> str | None:
@@ -257,18 +230,7 @@ def infer_version(dist: Distribution, root: str | os.PathLike | None = None) ->
257
230
 
258
231
  from distutils.errors import DistutilsOptionError, DistutilsSetupError
259
232
 
260
- config = getattr(dist, "setuptools_git_versioning", None) or getattr(dist, "version_config", None)
261
-
262
- if isinstance(config, bool):
263
- warnings.warn(
264
- "Passing boolean value to 'version_config'/'setuptools_git_versioning' option is deprecated "
265
- "since setuptools-git-versioning 1.8.0 "
266
- "and will be dropped in v2.0.0\n"
267
- "Please change value to '{'enabled': False/True}'",
268
- category=UserWarning,
269
- )
270
- config = {"enabled": config}
271
-
233
+ config = getattr(dist, "setuptools_git_versioning", None)
272
234
  toml_config = _read_toml(root=root)
273
235
 
274
236
  if config is None:
@@ -545,6 +507,9 @@ def version_from_git(
545
507
  )
546
508
  return _get_version_from_callback(version_callback, package_name, root=root)
547
509
 
510
+ head_sha = get_sha(root=root)
511
+ log.log(INFO, "HEAD SHA-256: %r", head_sha)
512
+
548
513
  filter_callback = None
549
514
  if tag_filter:
550
515
  filter_callback = _callable_factory(
@@ -555,16 +520,22 @@ def version_from_git(
555
520
  root=root,
556
521
  )
557
522
 
558
- from_file = False
559
523
  log.log(INFO, "Getting latest tag")
560
524
  log.log(DEBUG, "Sorting tags by %r", sort_by)
561
525
  tag = get_tag(sort_by=sort_by, root=root, filter_callback=filter_callback)
526
+ if not tag:
527
+ log.log(INFO, "No tags found")
528
+ tag_sha = None
529
+ on_tag = False
530
+ else:
531
+ tag_sha = get_sha(tag, root=root)
532
+ log.log(INFO, "Tag SHA-256: %r", tag_sha)
533
+
534
+ on_tag = head_sha is not None and head_sha == tag_sha
535
+ log.log(INFO, "HEAD is tagged: %r", on_tag)
562
536
 
563
- if tag is None:
564
- log.log(INFO, "No tag, checking for 'version_file'")
565
- if version_file is None:
566
- log.log(INFO, "No 'version_file' set, return starting_version %r", starting_version)
567
- return _sanitize_version(starting_version)
537
+ if version_file:
538
+ log.log(INFO, "Checking for 'version_file'")
568
539
 
569
540
  if not Path(version_file).exists():
570
541
  log.log(
@@ -573,26 +544,30 @@ def version_from_git(
573
544
  version_file,
574
545
  starting_version,
575
546
  )
576
- return _sanitize_version(starting_version)
547
+ tag = None
548
+ else:
549
+ log.log(INFO, "Reading version_file '%s' content", version_file)
550
+ tag = _read_version_from_file(version_file, root=root) or None
577
551
 
578
- log.log(INFO, "version_file '%s' does exist, reading its content", version_file)
579
- from_file = True
580
- tag = _read_version_from_file(version_file, root=root)
552
+ if not tag:
553
+ log.log(INFO, "File %r is empty", version_file)
554
+ else:
555
+ log.log(DEBUG, "File content: %r", tag)
556
+ if not count_commits_from_version_file:
557
+ return _sanitize_version(tag)
581
558
 
582
- if not tag:
583
- log.log(INFO, "File is empty, return starting_version %r", version_file, starting_version)
584
- return _sanitize_version(starting_version)
559
+ file_sha = get_latest_file_commit(version_file, root=root)
560
+ log.log(DEBUG, "File SHA-256: %r", file_sha)
585
561
 
586
- log.log(DEBUG, "File content: %r", tag)
587
- if not count_commits_from_version_file:
588
- return _sanitize_version(tag)
562
+ ccount = count_since(file_sha, root=root) if file_sha is not None else None
563
+ log.log(INFO, "Commits count between HEAD and last version file change: %r", ccount)
589
564
 
590
- tag_sha = get_latest_file_commit(version_file, root=root)
591
- log.log(DEBUG, "File SHA-256: %r", tag_sha)
592
- else:
593
- log.log(INFO, "Latest tag: %r", tag)
594
- tag_sha = get_sha(tag, root=root)
595
- log.log(INFO, "Tag SHA-256: %r", tag_sha)
565
+ elif not head_sha:
566
+ log.log(INFO, "Not a git repo, or repo without any branch")
567
+
568
+ elif tag_sha:
569
+ ccount = count_since(tag_sha, root=root)
570
+ log.log(INFO, "Commits count between HEAD and last tag: %r", ccount)
596
571
 
597
572
  if tag_formatter is not None:
598
573
  tag_format_callback = _callable_factory(
@@ -606,19 +581,13 @@ def version_from_git(
606
581
  tag = tag_format_callback(tag)
607
582
  log.log(DEBUG, "Tag after formatting: %r", tag)
608
583
 
584
+ if not tag:
585
+ log.log(INFO, "No source for version, return starting_version %r", starting_version)
586
+ return _sanitize_version(starting_version)
587
+
609
588
  dirty = is_dirty(root=root)
610
589
  log.log(INFO, "Is dirty: %r", dirty)
611
590
 
612
- head_sha = get_sha(root=root)
613
- log.log(INFO, "HEAD SHA-256: %r", head_sha)
614
-
615
- full_sha = head_sha if head_sha is not None else ""
616
- ccount = count_since(tag_sha, root=root) if tag_sha is not None else None
617
- log.log(INFO, "Commits count between HEAD and latest tag: %r", ccount)
618
-
619
- on_tag = head_sha is not None and head_sha == tag_sha and not from_file
620
- log.log(INFO, "HEAD is tagged: %r", on_tag)
621
-
622
591
  branch = get_branch(root=root)
623
592
  log.log(INFO, "Current branch: %r", branch)
624
593
 
@@ -644,6 +613,7 @@ def version_from_git(
644
613
  log.log(INFO, "Using template from 'template' option")
645
614
  t = template
646
615
 
616
+ full_sha = head_sha if head_sha is not None else ""
647
617
  version = _resolve_substitutions(t, sha=full_sha[:8], tag=tag, ccount=ccount, branch=branch, full_sha=full_sha)
648
618
  log.log(INFO, "Version number after resolving substitutions: %r", version)
649
619
  return _sanitize_version(version)
@@ -1,3 +0,0 @@
1
- packaging
2
- setuptools
3
- toml>=0.10.2; python_version<"3.11"