File tree Expand file tree Collapse file tree 3 files changed +67
-1
lines changed Expand file tree Collapse file tree 3 files changed +67
-1
lines changed Original file line number Diff line number Diff line change
1
+
2
+ ### Added
3
+
4
+ - fix #960 : add a `` --force-write-version-files `` flag for the cli
5
+
6
+ -->
7
+ <!--
8
+ ### Changed
9
+
10
+ - A bullet item for the Changed category.
11
+
12
+ -->
13
+ <!--
14
+ ### Deprecated
15
+
16
+ - A bullet item for the Deprecated category.
17
+
18
+ -->
19
+ <!--
20
+ ### Fixed
21
+
22
+ - A bullet item for the Fixed category.
23
+
24
+ -->
25
+ <!--
26
+ ### Security
27
+
28
+ - A bullet item for the Security category.
29
+
30
+ -->
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ def main(args: list[str] | None = None) -> None:
31
31
)
32
32
config = Configuration (inferred_root )
33
33
34
- version = _get_version (config , force_write_version_files = False )
34
+ version = _get_version (
35
+ config , force_write_version_files = opts .force_write_version_files
36
+ )
35
37
if version is None :
36
38
raise SystemExit ("ERROR: no version found for" , opts )
37
39
if opts .strip_dev :
@@ -67,6 +69,12 @@ def _get_cli_opts(args: list[str] | None) -> argparse.Namespace:
67
69
action = "store_true" ,
68
70
help = "remove the dev/local parts of the version before printing the version" ,
69
71
)
72
+ parser .add_argument (
73
+ "--force-write-version-files" ,
74
+ action = "store_true" ,
75
+ help = "trigger to write the content of the version files\n "
76
+ "its recommended to use normal/editable installation instead)" ,
77
+ )
70
78
sub = parser .add_subparsers (title = "extra commands" , dest = "command" , metavar = "" )
71
79
# We avoid `metavar` to prevent printing repetitive information
72
80
desc = "List files managed by the SCM"
Original file line number Diff line number Diff line change @@ -56,3 +56,31 @@ def test_cli_find_pyproject(
56
56
with warns_cli_root_override :
57
57
out = get_output (["-c" , PYPROJECT_TOML , "--root=." ])
58
58
assert out .startswith ("0.1.dev1+" )
59
+
60
+
61
+ def test_cli_force_version_files (
62
+ wd : WorkDir , monkeypatch : pytest .MonkeyPatch , debug_mode : DebugMode
63
+ ) -> None :
64
+ debug_mode .disable ()
65
+ wd .commit_testfile ()
66
+ wd .write (
67
+ PYPROJECT_TOML ,
68
+ """
69
+ [project]
70
+ name = "test"
71
+ [tool.setuptools_scm]
72
+ version_file = "ver.py"
73
+ """ ,
74
+ )
75
+ monkeypatch .chdir (wd .cwd )
76
+
77
+ version_file = wd .cwd .joinpath ("ver.py" )
78
+ assert not version_file .exists ()
79
+
80
+ get_output ([])
81
+ assert not version_file .exists ()
82
+
83
+ output = get_output (["--force-write-version-files" ])
84
+ assert version_file .exists ()
85
+
86
+ assert output [:5 ] in version_file .read_text ("utf-8" )
You can’t perform that action at this time.
0 commit comments