AutoGitSemVer 0.8.4__tar.gz → 0.9.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.
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/PKG-INFO +1 -1
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/__init__.py +1 -1
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/scripts/UpdatePythonVersion.py +27 -13
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/tests/scripts/UpdatePythonVersion_UnitTest.py +65 -9
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.copier-answers.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/CODEOWNERS +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/ISSUE_TEMPLATE/custom.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/actions/release_impl/action.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/pull_request_template.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/release_sources.yaml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/workflows/CICD.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/workflows/CICD_impl.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.github/workflows/codeql.yml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.gitignore +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.pre-commit-config.yaml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/.python-version +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/CODE_OF_CONDUCT.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/CONTRIBUTING.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/DEVELOPMENT.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/GOVERNANCE.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/LICENSE +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/MAINTAINERS.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/README.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/SECURITY.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/minisign_key.pub +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/pyproject.toml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/AutoGitSemVerSchema.json +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/EntryPoint.py +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/Lib.py +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/py.typed +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/scripts/__init__.py +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer.yaml +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/ConfigurationSchema/AutoGitSemVerSchema.SimpleSchema +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/ConfigurationSchema/README.md +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/tests/EntryPoint_UnitTest.py +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/tests/Lib_UnitTest.py +0 -0
- {autogitsemver-0.8.4 → autogitsemver-0.9.0}/uv.lock +0 -0
{autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/AutoGitSemVer/scripts/UpdatePythonVersion.py
RENAMED
|
@@ -46,13 +46,13 @@ app = typer.Typer(
|
|
|
46
46
|
# ----------------------------------------------------------------------
|
|
47
47
|
@app.command("EntryPoint", help=__doc__, no_args_is_help=True)
|
|
48
48
|
def EntryPoint(
|
|
49
|
-
|
|
49
|
+
filename: Annotated[
|
|
50
50
|
Path,
|
|
51
51
|
typer.Argument(
|
|
52
52
|
dir_okay=False,
|
|
53
53
|
exists=True,
|
|
54
54
|
resolve_path=True,
|
|
55
|
-
help="Name of the python file that contains the __version__ variable.",
|
|
55
|
+
help="Name of the python file that contains the __version__ variable or the pyproject.toml file that contains the version variable.",
|
|
56
56
|
),
|
|
57
57
|
],
|
|
58
58
|
working_dir: Annotated[
|
|
@@ -76,7 +76,7 @@ def EntryPoint(
|
|
|
76
76
|
with DoneManager.CreateCommandLine(
|
|
77
77
|
flags=DoneManagerFlags.Create(verbose=verbose, debug=debug),
|
|
78
78
|
) as dm:
|
|
79
|
-
working_dir = working_dir or
|
|
79
|
+
working_dir = working_dir or filename.parent
|
|
80
80
|
|
|
81
81
|
version = GetSemanticVersion(
|
|
82
82
|
dm,
|
|
@@ -89,17 +89,31 @@ def EntryPoint(
|
|
|
89
89
|
|
|
90
90
|
dm.WriteLine("")
|
|
91
91
|
|
|
92
|
-
with dm.Nested(f"Updating '{
|
|
93
|
-
with
|
|
92
|
+
with dm.Nested(f"Updating '{filename}'...") as update_dm:
|
|
93
|
+
with filename.open(encoding="utf-8") as f:
|
|
94
94
|
content = f.read()
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if filename.suffix == ".py":
|
|
97
|
+
variable_name = "__version__"
|
|
98
|
+
|
|
99
|
+
regex = re.compile(
|
|
100
|
+
rf"^(?P<prefix>\s*{variable_name}\s*=\s*)(?P<quote>['\"])\S*?(?P=quote)(?P<newline>\r?\n)",
|
|
101
|
+
flags=re.MULTILINE,
|
|
102
|
+
)
|
|
103
|
+
elif filename.suffix == ".toml":
|
|
104
|
+
variable_name = "version"
|
|
105
|
+
|
|
106
|
+
regex = re.compile(
|
|
107
|
+
rf"^(?P<prefix>{variable_name}\s*=\s*)(?P<quote>['\"])\S*?(?P=quote)(?P<newline>\r?\n)",
|
|
108
|
+
flags=re.MULTILINE,
|
|
109
|
+
)
|
|
110
|
+
else:
|
|
111
|
+
error = f"'{filename}' is not a recognized file type."
|
|
112
|
+
raise Exception(error)
|
|
113
|
+
|
|
114
|
+
match = regex.search(content)
|
|
101
115
|
if not match:
|
|
102
|
-
update_dm.WriteError("A '
|
|
116
|
+
update_dm.WriteError(f"A '{variable_name}' variable was not found.\n")
|
|
103
117
|
return
|
|
104
118
|
|
|
105
119
|
content = "".join(
|
|
@@ -114,7 +128,7 @@ def EntryPoint(
|
|
|
114
128
|
],
|
|
115
129
|
)
|
|
116
130
|
|
|
117
|
-
with
|
|
131
|
+
with filename.open("w", encoding="utf-8", newline=match.group("newline")) as f:
|
|
118
132
|
f.write(content)
|
|
119
133
|
|
|
120
134
|
|
|
@@ -122,4 +136,4 @@ def EntryPoint(
|
|
|
122
136
|
# ----------------------------------------------------------------------
|
|
123
137
|
# ----------------------------------------------------------------------
|
|
124
138
|
if __name__ == "__main__":
|
|
125
|
-
app()
|
|
139
|
+
app() # pragma: no cover
|
|
@@ -18,15 +18,14 @@ import textwrap
|
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from unittest.mock import MagicMock as Mock, mock_open, patch
|
|
20
20
|
|
|
21
|
-
import
|
|
22
|
-
|
|
21
|
+
from click.testing import Result
|
|
23
22
|
from typer.testing import CliRunner
|
|
24
23
|
from AutoGitSemVer import GetSemanticVersionResult
|
|
25
24
|
from AutoGitSemVer.scripts.UpdatePythonVersion import app
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
# ----------------------------------------------------------------------
|
|
29
|
-
def
|
|
28
|
+
def test_Python():
|
|
30
29
|
_Execute(
|
|
31
30
|
textwrap.dedent(
|
|
32
31
|
"""\
|
|
@@ -46,7 +45,7 @@ def test_Default():
|
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
# ----------------------------------------------------------------------
|
|
49
|
-
def
|
|
48
|
+
def test_NoPythonVersion():
|
|
50
49
|
_Execute(
|
|
51
50
|
textwrap.dedent(
|
|
52
51
|
"""\
|
|
@@ -58,6 +57,53 @@ def test_NoVersion():
|
|
|
58
57
|
)
|
|
59
58
|
|
|
60
59
|
|
|
60
|
+
# ----------------------------------------------------------------------
|
|
61
|
+
def test_Toml():
|
|
62
|
+
_Execute(
|
|
63
|
+
textwrap.dedent(
|
|
64
|
+
"""\
|
|
65
|
+
# Line Before
|
|
66
|
+
version = ""
|
|
67
|
+
# Line After
|
|
68
|
+
""",
|
|
69
|
+
),
|
|
70
|
+
textwrap.dedent(
|
|
71
|
+
"""\
|
|
72
|
+
# Line Before
|
|
73
|
+
version = "1.2.3"
|
|
74
|
+
# Line After
|
|
75
|
+
""",
|
|
76
|
+
),
|
|
77
|
+
file_extension=".toml",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# ----------------------------------------------------------------------
|
|
82
|
+
def test_NoTomlVersion():
|
|
83
|
+
_Execute(
|
|
84
|
+
textwrap.dedent(
|
|
85
|
+
"""\
|
|
86
|
+
# No version in this file
|
|
87
|
+
""",
|
|
88
|
+
),
|
|
89
|
+
"",
|
|
90
|
+
file_extension=".toml",
|
|
91
|
+
expected_failure=True,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# ----------------------------------------------------------------------
|
|
96
|
+
def test_UnsupportedFileType():
|
|
97
|
+
result = _Execute(
|
|
98
|
+
"",
|
|
99
|
+
"",
|
|
100
|
+
file_extension=".md",
|
|
101
|
+
expected_failure=True,
|
|
102
|
+
)
|
|
103
|
+
exception_message = str(result.exception)
|
|
104
|
+
assert "README.md' is not a recognized file type." in exception_message
|
|
105
|
+
|
|
106
|
+
|
|
61
107
|
# ----------------------------------------------------------------------
|
|
62
108
|
# ----------------------------------------------------------------------
|
|
63
109
|
# ----------------------------------------------------------------------
|
|
@@ -65,8 +111,9 @@ def _Execute(
|
|
|
65
111
|
original: str,
|
|
66
112
|
expected: str,
|
|
67
113
|
*,
|
|
114
|
+
file_extension: str = ".py",
|
|
68
115
|
expected_failure: bool = False,
|
|
69
|
-
) ->
|
|
116
|
+
) -> Result:
|
|
70
117
|
# ----------------------------------------------------------------------
|
|
71
118
|
def MyWrite(value):
|
|
72
119
|
assert value == expected
|
|
@@ -86,11 +133,20 @@ def _Execute(
|
|
|
86
133
|
),
|
|
87
134
|
patch.object(Path, "open", file_mock),
|
|
88
135
|
):
|
|
89
|
-
|
|
136
|
+
if file_extension == ".py":
|
|
137
|
+
placeholder_filename = Path(__file__)
|
|
138
|
+
elif file_extension == ".toml":
|
|
139
|
+
placeholder_filename = Path(__file__).parent.parent.parent / "pyproject.toml"
|
|
140
|
+
elif file_extension == ".md":
|
|
141
|
+
placeholder_filename = Path(__file__).parent.parent.parent / "README.md"
|
|
142
|
+
else:
|
|
143
|
+
assert False, file_extension
|
|
144
|
+
|
|
145
|
+
result = CliRunner().invoke(app, [str(placeholder_filename)])
|
|
90
146
|
|
|
91
147
|
if expected_failure:
|
|
92
|
-
assert result.exit_code != 0
|
|
148
|
+
assert result.exit_code != 0, result.output
|
|
93
149
|
else:
|
|
94
|
-
assert result.exit_code == 0
|
|
150
|
+
assert result.exit_code == 0, result.output
|
|
95
151
|
|
|
96
|
-
return result
|
|
152
|
+
return result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{autogitsemver-0.8.4 → autogitsemver-0.9.0}/src/ConfigurationSchema/AutoGitSemVerSchema.SimpleSchema
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|