|
9 | 9 |
|
10 | 10 | import pytest
|
11 | 11 |
|
| 12 | +from setuptools_scm import Configuration |
| 13 | +from setuptools_scm import format_version |
12 | 14 | from setuptools_scm import git
|
13 | 15 | from setuptools_scm import integration
|
14 | 16 | from setuptools_scm import NonNormalizedVersion
|
15 | 17 | from setuptools_scm.file_finder_git import git_find_files
|
| 18 | +from setuptools_scm.git import archival_to_version |
16 | 19 | from setuptools_scm.utils import do
|
17 | 20 | from setuptools_scm.utils import has_command
|
18 | 21 |
|
@@ -395,9 +398,7 @@ def parse_date():
|
395 | 398 | assert meta.node_date == today
|
396 | 399 |
|
397 | 400 |
|
398 |
| -def test_git_getdate_badgit( |
399 |
| - wd, |
400 |
| -): |
| 401 | +def test_git_getdate_badgit(wd): |
401 | 402 | wd.commit_testfile()
|
402 | 403 | git_wd = git.GitWorkdir(os.fspath(wd.cwd))
|
403 | 404 | with patch.object(git_wd, "do_ex", Mock(return_value=("%cI", "", 0))):
|
@@ -435,3 +436,34 @@ def test_git_getdate_signed_commit(signed_commit_wd):
|
435 | 436 | signed_commit_wd.commit_testfile(signed=True)
|
436 | 437 | git_wd = git.GitWorkdir(os.fspath(signed_commit_wd.cwd))
|
437 | 438 | assert git_wd.get_head_date() == today
|
| 439 | + |
| 440 | + |
| 441 | +@pytest.mark.parametrize( |
| 442 | + "expected, from_data", |
| 443 | + [ |
| 444 | + ( |
| 445 | + "1.0", |
| 446 | + {"describe-name": "1.0-0-g0000"}, |
| 447 | + ), |
| 448 | + ( |
| 449 | + "1.1.dev3+g0000", |
| 450 | + { |
| 451 | + "describe-name": "1.0-3-g0000", |
| 452 | + "node": "0" * 20, |
| 453 | + }, |
| 454 | + ), |
| 455 | + ("0.0", {"node": "0" * 20}), |
| 456 | + ("1.2.2", {"describe-name": "release-1.2.2-0-g00000"}), |
| 457 | + ("1.2.2.dev0", {"ref-names": "tag: release-1.2.2.dev"}), |
| 458 | + ], |
| 459 | +) |
| 460 | +@pytest.mark.filterwarnings("ignore:git archive did not support describe output") |
| 461 | +def test_git_archival_to_version(expected, from_data): |
| 462 | + config = Configuration() |
| 463 | + version = archival_to_version(from_data, config=config) |
| 464 | + assert ( |
| 465 | + format_version( |
| 466 | + version, version_scheme="guess-next-dev", local_scheme="node-and-date" |
| 467 | + ) |
| 468 | + == expected |
| 469 | + ) |
0 commit comments